正文
增加 994 行删除 55 行
12345678910111213141516171819203 行未改动2425262728293031323334353637383940414243443 行未改动4849505152535455565758596061626364656667686970717273747576777879808182838436 行未改动1211221231241251261271281291301311321331341351361372 行未改动1401411421431441451461476 行未改动15415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220365 行未改动2692702712722732742752762772782792802812822 行未改动28528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132215 行未改动33833934034134234334434536 行未改动3823833843853863873883893903913923933943953963973988 行未改动4074084094104114124134144154164174184194204214224234244254264274284294304314324334347 行未改动44244344444544644744844945045145245345445545645745845965 行未改动5255265275285295305315322 行未改动53553653753853954054154254354454554654754854955055155255317 行未改动57157257357457557657757857916 行未改动596597598599600601602603604605606607608609610611612613614615616// ==UserScript==// @name JXYCOI Display Better// @namespace https://www.jxycoi.cn/// @version 1.0.0// @description 育才信奥界面美化脚本// @author zhanjinghan// @icon https://cdn.jxycoi.cn/dist/favicon.ico// @match https://www.jxycoi.cn/*// @match http://www.jxycoi.cn/*// @match https://jxycoi.cn/*// @match http://jxycoi.cn/*// @grant GM_addStyle// @grant GM_getValue// @grant GM_setValue// @run-at document-start// @noframes// ==/UserScript==(function () {'use strict';3 行未改动* ============================================================ */const DEFAULT_CONFIG = {enabled: true, // 总开关themeName: '洛谷经典蓝', // 当前主题名dark: false, // 暗色模式primary: '#3498db', // 主色primaryHover: '#2980b9', // 主色 hoverbgColor: '#f0f2f5', // 页面背景色bgImage: '', // 背景图片 URL(留空则纯色)blur: 12, // 背景模糊度 px (0-40)opacity: 0.86, // 卡片透明度 0.3-1radius: 10, // 卡片圆角 pxtextColor: '#1f2733', // 正文颜色secondaryColor: '#6b7280', // 次要文字颜色cardColor: '#ffffff', // 卡片底色navbarColor: '#ffffff', // 顶栏底色shadow: true, // 卡片阴影customCSS: '' // 用户自定义 CSS};/* ============================================================3 行未改动'洛谷经典蓝': {primary: '#3498db', primaryHover: '#2980b9',bgColor: '#f0f2f5', bgImage: '', blur: 12, opacity: 0.86,radius: 10, textColor: '#1f2733', secondaryColor: '#6b7280',cardColor: '#ffffff', navbarColor: '#ffffff', dark: false, shadow: true},'洛谷翠绿': {primary: '#27ae60', primaryHover: '#1e8449',bgColor: '#f0f4f2', bgImage: '', blur: 14, opacity: 0.87,radius: 12, textColor: '#1f2733', secondaryColor: '#5f7a6e',cardColor: '#ffffff', navbarColor: '#ffffff', dark: false, shadow: true},'洛谷暮紫': {primary: '#8e44ad', primaryHover: '#732d91',bgColor: '#f3eff6', bgImage: '', blur: 16, opacity: 0.85,radius: 14, textColor: '#2c2433', secondaryColor: '#7a6b8a',cardColor: '#ffffff', navbarColor: '#ffffff', dark: false, shadow: true},'洛谷暗夜': {primary: '#61afef', primaryHover: '#4a9be0',bgColor: '#1a1f2b', bgImage: '', blur: 10, opacity: 0.92,radius: 10, textColor: '#d8dee9', secondaryColor: '#9aa5b8',cardColor: '#232a38', navbarColor: '#1e2530', dark: true, shadow: false},'毛玻璃亚克力': {primary: '#5b8def', primaryHover: '#4a76d6',bgColor: '#eef2fb', bgImage: '', blur: 22, opacity: 0.55,radius: 16, textColor: '#1f2733', secondaryColor: '#6b7280',cardColor: '#ffffff', navbarColor: '#ffffff', dark: false, shadow: false}};/* ============================================================* 存储封装(优先 GM,回退 localStorage)* ============================================================ */const STORE_KEY = 'jxycoi_display_better_config';function loadConfig() {36 行未改动const c = hexToRgb(hex);const f = v => Math.max(0, Math.round(v * (1 - amt)));return `rgb(${f(c.r)}, ${f(c.g)}, ${f(c.b)})`;}/* ============================================================* 样式生成* ============================================================ */const CARD_SELECTORS = '.card-container, .card, .panel, .module-card, [class*="card"], [class*="Card"]';function buildCSS(cfg) {const cardBg = rgba(cfg.cardColor, cfg.opacity);const navbarBg = rgba(cfg.navbarColor, cfg.opacity);const textColor = cfg.textColor;const secColor = cfg.secondaryColor;const primary = cfg.primary;const primaryHover = cfg.primaryHover;2 行未改动const shadow = cfg.shadow? '0 1px 3px rgba(0,0,0,.04), 0 2px 8px rgba(0,0,0,.08)': 'none';return `/* ===== JXYCOI Display Better ===== */html {background: ${cfg.bgColor} !important;6 行未改动content: '' !important;position: fixed !important;inset: 0 !important;z-index: -1 !important;background: url('${cfg.bgImage || ''}') no-repeat fixed center/cover !important;filter: blur(${cfg.blur > 0 ? blurPx : '0px'}) !important;transform: scale(1.06) !important;pointer-events: none !important;display: ${cfg.bgImage ? 'block' : 'none'} !important;}/* 顶栏 */.top-navbar, header, nav, .navbar {background: ${navbarBg} !important;backdrop-filter: blur(${blurPx}) saturate(140%) !important;-webkit-backdrop-filter: blur(${blurPx}) saturate(140%) !important;border-bottom: 1px solid ${rgba(cfg.cardColor, 0.15)} !important;box-shadow: 0 1px 4px rgba(0,0,0,.06) !important;}.top-navbar a, header a, nav a, .navbar a {color: ${cfg.dark ? textColor : primary} !important;}.top-navbar a:hover, header a:hover, nav a:hover, .navbar a:hover {color: ${primaryHover} !important;}/* 卡片容器 */${CARD_SELECTORS} {background: ${cardBg} !important;backdrop-filter: blur(${blurPx}) !important;-webkit-backdrop-filter: blur(${blurPx}) !important;border-radius: ${radius} !important;border: 1px solid ${rgba(cfg.cardColor, 0.12)} !important;box-shadow: ${shadow} !important;color: ${textColor} !important;}/* 表格 */table, .table {background: transparent !important;color: ${textColor} !important;}th {color: ${secColor} !important;background: ${rgba(cfg.primary, 0.06)} !important;}tr:nth-child(even) td {background: ${rgba(cfg.cardColor, 0.35)} !important;}/* 输入框 */input, textarea, select {background: ${rgba(cfg.cardColor, 0.85)} !important;color: ${textColor} !important;65 行未改动if (!config.enabled) {if (styleEl) styleEl.textContent = '';return;}const css = buildCSS(config);if (styleEl) styleEl.textContent = css;else styleEl = GM_addStyle(css);}/* ============================================================* 主题导入 / 导出* ============================================================ */function normalizeTheme(obj) {const t = obj || {};2 行未改动primary: t.primary || t.mainColor || t.accent || DEFAULT_CONFIG.primary,primaryHover: t.primaryHover || DEFAULT_CONFIG.primaryHover,bgColor: t.bgColor || t.background || t.backgroundColor || DEFAULT_CONFIG.bgColor,bgImage: t.bgImage || t.backgroundImage || '',blur: clampNum(t.blur, 0, 40, DEFAULT_CONFIG.blur),opacity: clampNum(t.opacity, 0.3, 1, DEFAULT_CONFIG.opacity),radius: clampNum(t.radius, 0, 30, DEFAULT_CONFIG.radius),textColor: t.textColor || DEFAULT_CONFIG.textColor,secondaryColor: t.secondaryColor || DEFAULT_CONFIG.secondaryColor,cardColor: t.cardColor || DEFAULT_CONFIG.cardColor,navbarColor: t.navbarColor || DEFAULT_CONFIG.navbarColor,dark: !!t.dark,shadow: t.shadow !== false,customCSS: t.customCSS || ''};}function clampNum(v, min, max, def) {const n = Number(v);if (Number.isNaN(n)) return def;return Math.min(max, Math.max(min, n));}function parseTheme(text) {let obj = null;try { obj = JSON.parse(text); } catch (e) { /* not json */ }if (!obj) {const m = text.match(/\{[\s\S]*\}/);if (m) { try { obj = JSON.parse(m[0]); } catch (e2) { /* ignore */ } }}if (!obj) throw new Error('无法解析主题:请输入 JSON 格式的主题配置');return normalizeTheme(obj);}function exportTheme() {const { themeName, ...rest } = config;return JSON.stringify({ name: themeName, ...rest }, null, 2);}function copyText(text) {try {if (navigator.clipboard && navigator.clipboard.writeText) {15 行未改动return Promise.resolve(ok);}/* ============================================================* 设置面板 UI* ============================================================ */let panelEl = null, btnEl = null;36 行未改动]);P.appendChild(title);// 开关const enabledWrap = el('div', { style: rowStyle() }, [el('label', { style: 'flex:1;' }, ['启用美化']),el('input', { type: 'checkbox', id: 'cfg-enabled', checked: config.enabled, onchange: e => {config.enabled = e.target.checked;saveConfig(config);applyStyle();} })]);P.appendChild(enabledWrap);// 主题选择P.appendChild(sectionTitle('主题'));const themeRow = el('div', { style: 'display:flex; gap:6px; flex-wrap:wrap; margin-bottom:10px;' });8 行未改动}, [name]));});P.appendChild(themeRow);P.appendChild(sectionTitle('主色'));P.appendChild(colorRow('primary', '主题色', () => {config.primary = valueOf('cfg-primary');config.primaryHover = darken(config.primary, 0.12);refreshAll();}));P.appendChild(sectionTitle('背景'));P.appendChild(colorRow('bgColor', '背景色', () => {config.bgColor = valueOf('cfg-bgColor');refreshAll();}));const bgImgWrap = el('div', { style: rowStyle() }, [el('label', { style: 'flex:1;' }, ['背景图片 URL']),el('input', { type: 'text', id: 'cfg-bgImage', value: config.bgImage, placeholder: '留空为纯色', style: inputStyle(), onchange: e => {config.bgImage = e.target.value.trim();refreshAll();} })]);P.appendChild(bgImgWrap);P.appendChild(sectionTitle('效果'));P.appendChild(sliderRow('blur', '背景模糊', 0, 40, 'px', () => {config.blur = Number(valueOf('cfg-blur'));7 行未改动config.radius = Number(valueOf('cfg-radius'));refreshAll();}));P.appendChild(sectionTitle('导入 / 导出'));const importWrap = el('div', { style: 'margin-bottom:8px;' }, [el('textarea', { id: 'cfg-import', placeholder: '粘贴主题 JSON 配置(可导入洛谷主题配置)', style: 'width:100%; height:56px; box-sizing:border-box; font-size:12px; border:1px solid #d0d7de; border-radius:6px; padding:6px;' }),el('div', { style: 'display:flex; gap:6px; margin-top:6px;' }, [el('button', { style: btnStyle(false), onclick: () => {try {const theme = parseTheme(valueOf('cfg-import'));config = Object.assign({}, config, theme, { themeName: theme.name || config.themeName });refreshAll();toast('主题导入成功');} catch (e) {toast('导入失败:' + e.message, true);}} }, ['导入主题']),65 行未改动el('label', { style: 'flex:1;' }, [label]),input, out]);}function valueOf(id) {const n = document.getElementById(id);return n ? n.value : '';}2 行未改动saveConfig(config);syncPanelValues();applyStyle();syncThemeButtons();}function syncPanelValues() {if (!panelEl) return;const set = (id, v) => { const n = document.getElementById(id); if (n) n.value = v; };set('cfg-enabled', config.enabled);set('cfg-primary', config.primary);set('cfg-bgColor', config.bgColor);set('cfg-bgImage', config.bgImage);set('cfg-blur', String(config.blur));set('cfg-opacity', String(Math.round(config.opacity * 100)));set('cfg-radius', String(config.radius));set('cfg-customCSS', config.customCSS);}function syncThemeButtons() {if (!panelEl) return;17 行未改动toastEl.textContent = msg;toastEl.style.background = isError ? 'rgba(180,60,60,.92)' : 'rgba(0,0,0,.78)';toastEl.style.opacity = '1';clearTimeout(toastEl._t);toastEl._t = setTimeout(() => { toastEl.style.opacity = '0'; }, 2000);}function buildButton() {if (btnEl) return btnEl;16 行未改动return btnEl;}/* ============================================================* 初始化* ============================================================ */function init() {if (!document.body) {document.addEventListener('DOMContentLoaded', init);return;}applyStyle();buildButton();}if (document.readyState === 'loading') {document.addEventListener('DOMContentLoaded', init);} else {init();}})();1234567891011121314151617181920212223243 行未改动282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172733 行未改动777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932036 行未改动3573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626632 行未改动6666676686696706716726736746756766776786796806816826 行未改动68969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485565 行未改动9219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110322 行未改动103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113415 行未改动115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118636 行未改动1223122412251226122712281229123012311232123312348 行未改动1243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513267 行未改动13341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136365 行未改动142914301431143214331434143514361437143814391440144114422 行未改动144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147517 行未改动14931494149514961497149814991500150116 行未改动15181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555```java// ==UserScript==// @name JXYCOI Display Better// @namespace https://github.com/zhanjinghan// @version 1.2.0// @description 育才信奥界面美化脚本// @author zhanjinghan// @icon https://cdn.jxycoi.cn/dist/favicon.ico// @match https://www.jxycoi.cn/*// @match http://www.jxycoi.cn/*// @match https://jxycoi.cn/*// @match http://jxycoi.cn/*// @match https://www.ycgeek.top/oj/*// @match http://www.ycgeek.top/oj/*// @grant GM_addStyle// @grant GM_getValue// @grant GM_setValue// @run-at document-start// @noframes// @license MIT// ==/UserScript==(function () {'use strict';3 行未改动* ============================================================ */const DEFAULT_CONFIG = {enabled: true, // 总开关themeName: '洛谷经典蓝', // 当前主题名// ---- 洛谷主题原始数据(导入时完整保留,可加字段不可少字段)----luoguTheme: null, // 原始洛谷主题 JSON(lNavi/lBody/dNavi/dBody...)luoguExtra: {}, // 扩展字段(name/author/css 等)// ---- 颜色 ----dark: false, // 暗色模式primary: '#3498db', // 主色primaryHover: '#2980b9', // 主色 hoverbgColor: '#f0f2f5', // 页面背景色naviBack: '#ffffff', // 导航背景naviFore: '#333333', // 导航前景navbarColor: '#ffffff', // 导航背景(旧格式兼容别名)textColor: '#1f2733', // 正文颜色secondaryColor: '#6b7280', // 次要文字颜色cardColor: '#ffffff', // 卡片底色// ---- 背景图片设置(以洛谷 midOpts 为标准)----bgImage: '', // 背景图片 URL(留空则纯色)bgPosX: 50, // 图片位置 X(0-100 %)bgPosY: 0, // 图片位置 Y(0-100 %)bgSize: 'cover', // 图片尺寸:auto 自动 / cover 填充 / contain 适应 / custom 自定义bgSizeCustom: '', // 自定义尺寸,如 "100% 100%" 或 "800px 600px"bgRepeat: 'no-repeat', // 图片重复:no-repeat 不重复 / repeat 全部 / repeat-x 横向 / repeat-y 纵向bgBrightness: 0, // 亮度(-100 ~ 100)bgDegree: 0, // 旋转角度(0 ~ 360)bgFade: 0, // 洛谷 fade 语义:0 无 / 1 顶部 400px 渐隐 / -1 底部 400px 渐隐// ---- 效果 ----blur: 12, // 背景模糊度 px (0-40)opacity: 0.86, // 卡片透明度 0-1(0=完全透明,1=不透明)radius: 10, // 卡片圆角 pxshadow: true, // 卡片阴影// ---- 功能开关 ----hideHomeImages: false, // 去除首页图片(轮播/公告大图)cardMode: true, // 卡片化(做题页面自动豁免)customCSS: '' // 用户自定义 CSS};/* ============================================================3 行未改动'洛谷经典蓝': {primary: '#3498db', primaryHover: '#2980b9',bgColor: '#f0f2f5', bgImage: '', blur: 12, opacity: 0.86,radius: 10, textColor: '#1f2733', secondaryColor: '#6b7280',cardColor: '#ffffff', naviBack: '#ffffff', naviFore: '#333333',navbarColor: '#ffffff', dark: false, shadow: true,bgSize: 'cover', bgRepeat: 'no-repeat', bgPosX: 50, bgPosY: 0},'洛谷翠绿': {primary: '#27ae60', primaryHover: '#1e8449',bgColor: '#f0f4f2', bgImage: '', blur: 14, opacity: 0.87,radius: 12, textColor: '#1f2733', secondaryColor: '#5f7a6e',cardColor: '#ffffff', naviBack: '#ffffff', naviFore: '#2c3e2f',navbarColor: '#ffffff', dark: false, shadow: true,bgSize: 'cover', bgRepeat: 'no-repeat', bgPosX: 50, bgPosY: 0},'洛谷暮紫': {primary: '#8e44ad', primaryHover: '#732d91',bgColor: '#f3eff6', bgImage: '', blur: 16, opacity: 0.85,radius: 14, textColor: '#2c2433', secondaryColor: '#7a6b8a',cardColor: '#ffffff', naviBack: '#ffffff', naviFore: '#3a2f40',navbarColor: '#ffffff', dark: false, shadow: true,bgSize: 'cover', bgRepeat: 'no-repeat', bgPosX: 50, bgPosY: 0},'洛谷暗夜': {primary: '#61afef', primaryHover: '#4a9be0',bgColor: '#1a1f2b', bgImage: '', blur: 10, opacity: 0.92,radius: 10, textColor: '#d8dee9', secondaryColor: '#9aa5b8',cardColor: '#232a38', naviBack: '#1e2530', naviFore: '#d8dee9',navbarColor: '#1e2530', dark: true, shadow: false,bgSize: 'cover', bgRepeat: 'no-repeat', bgPosX: 50, bgPosY: 0},'毛玻璃亚克力': {primary: '#5b8def', primaryHover: '#4a76d6',bgColor: '#eef2fb', bgImage: '', blur: 22, opacity: 0.55,radius: 16, textColor: '#1f2733', secondaryColor: '#6b7280',cardColor: '#ffffff', naviBack: '#ffffff', naviFore: '#333333',navbarColor: '#ffffff', dark: false, shadow: false,bgSize: 'cover', bgRepeat: 'no-repeat', bgPosX: 50, bgPosY: 0}};/* ============================================================* 彩蛋主题(艾莲·乔)* ============================================================ */const EASTER_EGG_TRIGGERS = ['艾莲', '艾莲乔', '艾莲·乔', '默认'];const EASTER_EGG_THEME = {lNavi: { back: '#ffffff', fore: '#333333' },lBody: {midOpts: { size: 'contain', degree: 0, position: [50, 0], brightness: 0, repeat: 'no-repeat' },back: '#f0f2f5',blur: 0,image: 'https://cdn.luogu.com.cn/upload/image_hosting/h54trnl1.webp'},dNavi: { back: '#ffffff', fore: '#262626' },dBody: { back: '#ffffff', blur: 1000, fade: 1000 },name: '艾莲·乔',__meta: {schema: 'jxycoi-display-better',schemaVersion: 1,appVersion: '1.2.0',exportedAt: '2026-10-19T05:12:04.169Z',name: '艾莲·乔',author: 'zhanjinghan',source: 'luogu-import'},__config: {enabled: true,themeName: '艾莲·乔',luoguTheme: {lNavi: { back: '#ffffff', fore: '#333333' },lBody: { midOpts: { size: 'contain', degree: 0, notEmpty: true, position: [50, 0], brightness: 0 }, back: '#f0f2f5', blur: 1000, image: 'https://cdn.luogu.com.cn/upload/image_hosting/h54trnl1.webp' },dNavi: { back: '#ffffff', fore: '#262626' },dBody: { back: '#ffffff', blur: 1000, fade: 1000 },name: '艾莲·乔'},luoguExtra: { name: '艾莲·乔' },dark: false,primary: '#3498db',primaryHover: '#2980b9',bgColor: '#f0f2f5',naviBack: '#ffffff',naviFore: '#333333',navbarColor: '#ffffff',textColor: '#1f2733',secondaryColor: '#6b7280',cardColor: '#ffffff',bgImage: 'https://cdn.luogu.com.cn/upload/image_hosting/h54trnl1.webp',bgPosX: 50,bgPosY: 0,bgSize: 'contain',bgSizeCustom: '',bgRepeat: 'no-repeat',bgBrightness: 0,bgDegree: 0,bgFade: 0,blur: 0,opacity: 0,radius: 10,shadow: true,hideHomeImages: false,cardMode: true,customCSS: `/* ===== 1. 默认给所有文字加白色描边 ===== */html body * {text-shadow:0.5px 0.5px 0 #fff,-0.5px 0.5px 0 #fff,0.5px -0.5px 0 #fff,-0.5px -0.5px 0 #fff,0 0 4px rgba(255, 255, 255, 0.9) !important;}/* ===== 2. 排除所有本身就是白色文字的区域 ===== *//* 代码块、表单控件 */html body pre,html body pre *,html body code,html body code *,html body kbd,html body kbd *,html body samp,html body samp *,html body button,html body button *,html body input,html body input *,html body textarea,html body textarea *,html body select,html body select *,/* Element UI 标签(难度「简单/中等/困难」等,彩底白字) */html body .el-tag,html body .el-tag *,html body [class*="el-tag--"],html body [class*="el-tag--"] *,/* 下拉导航(你网站里 .subNav 内是白字) */html body .subNav,html body .subNav *,html body .subNav a,/* 顶栏 / 导航 / 页脚 —— 通常是深色背景白字 */html body .navbar,html body .navbar *,html body .top-navbar,html body .top-navbar *,html body header,html body header *,html body nav,html body nav *,html body .footer,html body .footer *,/* 按钮、标签、徽章、主色元素 */html body .btn,html body .btn *,html body .tag,html body .tag *,html body .badge,html body .badge *,html body .label,html body .label *,html body [class*="primary"],html body [class*="primary"] *,html body [class*="button"],html body [class*="button"] *,/* 难度标签(洛谷风格:彩色底 + 白字) */html body .difficulty,html body .difficulty *,html body .problem-difficulty,html body .problem-difficulty *,html body [class*="difficulty"],html body [class*="difficulty"] *,html body [class*="Difficulty"],html body [class*="Difficulty"] *,html body .lg-fg-red,html body .lg-fg-orange,html body .lg-fg-yellow,html body .lg-fg-green,html body .lg-fg-blue,html body .lg-fg-purple,html body .lg-fg-black,html body .lg-fg-gray,html body [class*="lg-fg-"],html body [class*="lg-fg-"] *,/* 状态标签(AC/WA/TLE 等) */html body .status,html body .status *,html body [class*="status"],html body [class*="status"] *,html body .result,html body .result *,html body [class*="result"],html body [class*="result"] *,html body .verdict,html body .verdict *,/* 弹窗、下拉菜单、提示框 */html body .modal,html body .modal *,html body .dropdown,html body .dropdown *,html body .menu,html body .menu *,html body .toast,html body .toast *,html body .alert,html body .alert *,html body .notification,html body .notification *,/* 分页、选项卡 */html body .pagination,html body .pagination *,html body .tab,html body .tab *,/* 暗色/黑色背景容器 */html body [class*="dark"],html body [class*="dark"] *,html body [class*="black"],html body [class*="black"] *,html body [class*="white-text"],html body [class*="white-text"] * {text-shadow: none !important;}/* ===== 3. 选中文字时不要白边 ===== */html body *::selection {text-shadow: none !important;}html body *::-moz-selection {text-shadow: none !important;}`},};/* ============================================================* 存储封装(优先 GM,回退 localStorage)* ============================================================ */const STORE_KEY = 'jxycoi_display_better_config';function loadConfig() {36 行未改动const c = hexToRgb(hex);const f = v => Math.max(0, Math.round(v * (1 - amt)));return `rgb(${f(c.r)}, ${f(c.g)}, ${f(c.b)})`;}function clampNum(v, min, max, def) {const n = Number(v);if (Number.isNaN(n)) return def;return Math.min(max, Math.max(min, n));}/* ============================================================* 样式生成* ============================================================ */// 卡片化选择器:本站真实内容容器(Element el-card / el-tabs + 通用精确类)。// 刻意删除 [class*="card"]/[class*="nav"]/[class*="main"]/[class*="content"]/main > div 等// 子串通杀——它们会误伤 avatar、vxe、el-* 内部类,是头像放大/顶栏不透明/列表行不透明的元凶。const CARD_SELECTORS = ['.card-container', '.card', '.panel', '.module-card','.el-card', '.box-card', '.el-tabs--border-card','.problem-left', '.problem-right'].join(',\n');// 站点识别:ycgeek.top/oj(Hydro OJ)与 jxycoi.cn(HUST 衍生)结构完全不同const IS_GEEK = /ycgeek\.top/.test(location.hostname);// 做题页面(纯白,不做卡片化)——按 URL / data-page 判断function isSolvingPage() {const p = location.pathname;if (IS_GEEK) {// Hydro OJ:优先用 <html data-page>(SSR 稳定写入),URL 正则兜底const dp = (document.documentElement && document.documentElement.getAttribute('data-page')) || '';if (dp === 'problem_detail' || dp === 'contest_problempage' || dp === 'problem_statistics') return true;const path = p.replace(/^\/oj/, '');return /^\/p\/[^/]+$/.test(path) || // /p/1 /p/C0001/^\/contest\/[^/]+\/p\/[^/]+$/.test(path) || // 比赛题/^\/p\/[^/]+\/stat$/.test(path); // 题目统计}return /\/problem\//.test(p) || /\/p\/\d+/.test(p) || /\/contest\/.*\/problem/.test(p) || /\/exam\//.test(p);}/* ============================================================* Hydro OJ(ycgeek.top/oj,cctools)专属样式生成* 结构:页面主体 #panel、顶栏 .nav/.header--mobile、卡片 .section/.geek-*、* 表格 .data-table/.el-table、头像 .el-avatar(Element UI 头像)* ============================================================ */function buildGeekCSS(cfg) {const cardBg = rgba(cfg.cardColor, cfg.opacity);const textColor = cfg.textColor;const secColor = cfg.secondaryColor;const primary = cfg.primary;const primaryHover = cfg.primaryHover;const radius = cfg.radius + 'px';const blurPx = cfg.blur + 'px';const shadow = cfg.shadow? '0 1px 3px rgba(0,0,0,.04), 0 2px 8px rgba(0,0,0,.08)': 'none';// 图片设置(以洛谷 midOpts 为标准)const sizeMap = { auto: 'auto', cover: 'cover', contain: 'contain' };const size = sizeMap[cfg.bgSize] || (cfg.bgSizeCustom || 'cover');const repeatMap = { 'no-repeat': 'no-repeat', repeat: 'repeat', 'repeat-x': 'repeat-x', 'repeat-y': 'repeat-y' };const repeat = repeatMap[cfg.bgRepeat] || 'no-repeat';const pos = `${cfg.bgPosX || 50}% ${cfg.bgPosY || 0}%`;const brightness = cfg.bgBrightness ? ` brightness(${100 + cfg.bgBrightness}%)` : '';const rotate = cfg.bgDegree ? ` rotate(${cfg.bgDegree}deg)` : '';return `/* ===== JXYCOI Display Better (GeekOJ/Hydro) ===== */html {background: ${cfg.bgColor} !important;}body {background: transparent !important;color: ${textColor} !important;}body::before {content: '' !important;position: fixed !important;inset: 0 !important;z-index: -1 !important;background: url('${cfg.bgImage || ''}') ${repeat} ${pos} / ${size} !important;filter: blur(${cfg.blur > 0 ? blurPx : '0px'})${brightness} !important;transform: scale(1.06) ${rotate} !important;pointer-events: none !important;display: ${cfg.bgImage ? 'block' : 'none'} !important;}/* 洛谷 fade 语义:顶部/底部 400px 黑渐隐遮罩(压暗保证文字可读) */body::after {content: '' !important;position: fixed !important;inset: 0 !important;z-index: -1 !important;pointer-events: none !important;background: ${cfg.bgFade > 0? 'linear-gradient(to bottom, rgba(0,0,0,.6) 0, transparent 400px)': cfg.bgFade < 0? 'linear-gradient(to top, rgba(0,0,0,.6) 0, transparent 400px)': 'none'} !important;display: ${cfg.bgFade ? 'block' : 'none'} !important;}/* ============================================================* Hydro OJ(ycgeek.top/oj,cctools):CSS 变量驱动,改 --geek-* 一次解决全站* 关键:--geek-surface 是卡片/表格/弹窗共用的表面色;#panel 是整页包裹层* ============================================================ */:root {--geek-surface: ${cardBg};--geek-bg: transparent;--geek-line: ${rgba(cfg.cardColor, 0.14)};--geek-shadow: ${shadow};--geek-radius-card: ${radius};--geek-ink: ${textColor};--geek-muted: ${secColor};}/* 整页包裹层透明,让 body::before 背景图透出(原 #panel{background:#edf0f2}) */#panel, .main, .main > .row, .main > .row > .columns, html, body {background: transparent !important;}/* 顶栏:精确命中 nav.nav#menu(本体+列表+项),绝不用 header/nav 元素选择器(header 会命中所有 section__header;nav 会命中 .nav--shadow 占位条) */nav.nav#menu {background: ${cardBg} !important;backdrop-filter: blur(${blurPx}) saturate(140%) !important;-webkit-backdrop-filter: blur(${blurPx}) saturate(140%) !important;border-bottom: 1px solid ${rgba(cfg.cardColor, 0.15)} !important;box-shadow: none !important;color: ${textColor} !important;}nav.nav#menu .nav__list,nav.nav#menu .nav__list-item,nav.nav#menu .nav__brand,nav.nav#menu .nav__item {background: transparent !important;border-radius: 0 !important;box-shadow: none !important;}nav.nav#menu .nav__item, nav.nav#menu .nav__brand {color: ${cfg.dark ? textColor : primary} !important;}nav.nav#menu .nav__item:hover, nav.nav#menu .nav__item.nav--active {color: ${primaryHover} !important;background: ${rgba(cfg.primary, 0.10)} !important;}/* 占位条绝对不能上色 */nav.nav--shadow {background: transparent !important;box-shadow: none !important;}/* 移动端顶栏(≤759px)与侧滑抽屉(≤600px 深底) */.header--mobile {background: ${cardBg} !important;backdrop-filter: blur(${blurPx}) !important;-webkit-backdrop-filter: blur(${blurPx}) !important;box-shadow: none !important;}.nav.slideout-menu {background: ${rgba('#252a32', 0.92)} !important;backdrop-filter: blur(${blurPx}) !important;-webkit-backdrop-filter: blur(${blurPx}) !important;}.nav.slideout-menu .nav__item, .nav.slideout-menu .nav__brand { color: #fff !important; }.nav.slideout-menu .nav__item:hover, .nav.slideout-menu .nav__item.nav--active {background: rgba(255,255,255,.12) !important;color: #fff !important;}/* 下拉浮层(导航内 .dropdown-target.menu 是透明的,脱离导航的 .dropdown .menu 是白底) */.dropdown .menu, .dropdown-target.menu,.autocomplete-list, .omnibar-main, .omnibar-content-section {background: ${rgba(cfg.dark ? '#1f2430' : '#ffffff', Math.max(cfg.opacity, 0.96))} !important;backdrop-filter: blur(${blurPx}) !important;-webkit-backdrop-filter: blur(${blurPx}) !important;border-radius: ${radius} !important;box-shadow: 0 8px 32px rgba(0,0,0,.18) !important;}.dropdown .menu a, .dropdown .menu .menu__link, .dropdown-target.menu a,.autocomplete-list a, .autocomplete-list li,.omnibar-main a, .omnibar-content-section a {background: transparent !important;color: ${cfg.dark ? textColor : primary} !important;}.autocomplete-list li[data-focus=true], .omnibar-content-section:hover {background: ${rgba(cfg.primary, 0.10)} !important;}/* 卡片本体:背景已由 --geek-surface 变量控制,这里补毛玻璃与圆角 */.section {backdrop-filter: blur(${blurPx}) saturate(140%) !important;-webkit-backdrop-filter: blur(${blurPx}) saturate(140%) !important;border: 1px solid ${rgba(cfg.cardColor, 0.12)} !important;border-radius: ${radius} !important;box-shadow: ${shadow} !important;color: ${textColor} !important;}/* 卡片内层头部/主体/工具条/元信息全透明,内容落在同一块玻璃上 */.section__header, .section__body, .section__tools,.geek-problem-meta-row, .problem__tags, .problem__tag-item,.geek-panel-head, .geek-announcement__body, .geek-checkin__action,.geek-problem-toolbar, .geek-problem-workspace__head,.geek-class-card__marker, .section__list__item, .contest__item {background: transparent !important;}/* 表格:.data-table(原生 table)透明化;斑马纹/高亮改半透明保留可读性 */.data-table, .data-table thead, .data-table tbody,.data-table th, .data-table td {background: transparent !important;}.data-table tbody tr:nth-child(2n) { background: rgba(255,255,255,.04) !important; }.data-table tbody tr:hover { background: ${rgba(cfg.primary, 0.08)} !important; }.data-table tbody tr.highlight { background: rgba(255,248,220,.45) !important; }.section__table-header {background: ${rgba(cfg.cardColor, 0.55)} !important;backdrop-filter: blur(8px) !important;}.data-table th { color: ${secColor} !important; }/* 头像:本站无头像(纯文本用户名),仅兜底保护文本块不被卡片化误伤 */.user-profile-link, .user-profile-name,nav.nav#menu .nav__item.geek-user-menu-trigger {background: transparent !important;border: 0 !important;border-radius: 0 !important;padding: 0 !important;box-shadow: none !important;backdrop-filter: none !important;-webkit-backdrop-filter: none !important;}/* 代码块:highlight.js pre[class*=language-] 玻璃化,绝不碰 KaTeX 公式 */pre, pre[class*="language-"], :not(pre) > code {background: ${rgba(cfg.cardColor, 0.55)} !important;color: ${textColor} !important;border-radius: 6px !important;}pre { border: 1px solid ${rgba(cfg.cardColor, 0.15)} !important; }.katex, .katex * { background: transparent !important; }/* 输入框 */input, textarea, select {background: ${rgba(cfg.cardColor, 0.85)} !important;color: ${textColor} !important;border: 1px solid ${rgba(primary, 0.3)} !important;border-radius: 6px !important;}input:focus, textarea:focus, select:focus {border-color: ${primary} !important;outline: none !important;box-shadow: 0 0 0 3px ${rgba(primary, 0.15)} !important;}/* 按钮 */button, .btn, [class*="button"], [class*="Button"] {color: ${cfg.dark ? textColor : primary} !important;}button.primary, .btn-primary, [class*="primary"] {background: ${primary} !important;border-color: ${primary} !important;color: #fff !important;border-radius: 6px !important;}button.primary:hover, .btn-primary:hover, [class*="primary"]:hover {background: ${primaryHover} !important;border-color: ${primaryHover} !important;}/* 链接 */a {color: ${primary} !important;}a:hover {color: ${primaryHover} !important;}/* 登录弹窗 */.modal-login, .modal, [class*="modal"] {background: ${rgba(cfg.dark ? cfg.cardColor : '#ffffff', Math.max(cfg.opacity, 0.92))} !important;backdrop-filter: blur(${blurPx}) !important;-webkit-backdrop-filter: blur(${blurPx}) !important;border-radius: ${radius} !important;box-shadow: 0 8px 32px rgba(0,0,0,.18) !important;}/* 状态标签 */[class*="tag"], [class*="label"], [class*="badge"] {border-radius: 4px !important;}/* 滚动条 */::-webkit-scrollbar { width: 10px !important; height: 10px !important; }::-webkit-scrollbar-thumb {background: ${rgba(primary, 0.35)} !important;border-radius: 5px !important;}::-webkit-scrollbar-thumb:hover {background: ${rgba(primary, 0.55)} !important;}::-webkit-scrollbar-track { background: transparent !important; }/* 暗色补充 */${cfg.dark ? `.section, .geek-announcement, .geek-checkin, .geek-class-card,.geek-problem-card, .geek-statistics-card, .geek-statistics-table-card,.geek-generated-pretest-list {border-color: rgba(255,255,255,.08) !important;}.data-table th { background: rgba(255,255,255,.05) !important; }` : ''}/* 自定义 CSS */${cfg.customCSS || ''}`;}function buildCSS(cfg) {if (IS_GEEK) return buildGeekCSS(cfg);const cardBg = rgba(cfg.cardColor, cfg.opacity);const textColor = cfg.textColor;const secColor = cfg.secondaryColor;const primary = cfg.primary;const primaryHover = cfg.primaryHover;2 行未改动const shadow = cfg.shadow? '0 1px 3px rgba(0,0,0,.04), 0 2px 8px rgba(0,0,0,.08)': 'none';// 图片设置(以洛谷 midOpts 为标准)const sizeMap = { auto: 'auto', cover: 'cover', contain: 'contain' };const size = sizeMap[cfg.bgSize] || (cfg.bgSizeCustom || 'cover');const repeatMap = { 'no-repeat': 'no-repeat', repeat: 'repeat', 'repeat-x': 'repeat-x', 'repeat-y': 'repeat-y' };const repeat = repeatMap[cfg.bgRepeat] || 'no-repeat';const pos = `${cfg.bgPosX || 50}% ${cfg.bgPosY || 0}%`;const brightness = cfg.bgBrightness ? ` brightness(${100 + cfg.bgBrightness}%)` : '';const rotate = cfg.bgDegree ? ` rotate(${cfg.bgDegree}deg)` : '';return `/* ===== JXYCOI Display Better ===== */html {background: ${cfg.bgColor} !important;6 行未改动content: '' !important;position: fixed !important;inset: 0 !important;z-index: -1 !important;background: url('${cfg.bgImage || ''}') ${repeat} ${pos} / ${size} !important;filter: blur(${cfg.blur > 0 ? blurPx : '0px'})${brightness} !important;transform: scale(1.06) ${rotate} !important;pointer-events: none !important;display: ${cfg.bgImage ? 'block' : 'none'} !important;}/* 洛谷 fade 语义:顶部/底部 400px 黑渐隐遮罩(压暗保证文字可读) */body::after {content: '' !important;position: fixed !important;inset: 0 !important;z-index: -1 !important;pointer-events: none !important;background: ${cfg.bgFade > 0? 'linear-gradient(to bottom, rgba(0,0,0,.6) 0, transparent 400px)': cfg.bgFade < 0? 'linear-gradient(to top, rgba(0,0,0,.6) 0, transparent 400px)': 'none'} !important;display: ${cfg.bgFade ? 'block' : 'none'} !important;}/* 顶栏(本站真实结构是 <div id="header">,内层 Element el-menu;也视为卡片) */#header,#header .el-menu,#header .el-menu--horizontal,.el-menu--popup,.el-menu--popup .el-menu {background: ${cardBg} !important;backdrop-filter: blur(${blurPx}) saturate(140%) !important;-webkit-backdrop-filter: blur(${blurPx}) saturate(140%) !important;box-shadow: none !important;color: ${textColor} !important;}#header {border-bottom: 1px solid ${rgba(cfg.cardColor, 0.15)} !important;border-radius: 0 0 ${radius} ${radius} !important;box-shadow: ${shadow} !important;}#header a, #header .el-menu-item, #header .el-submenu__title,.el-menu--popup a, .el-menu--popup .el-menu-item {color: ${cfg.dark ? textColor : primary} !important;background: transparent !important;}#header a:hover, #header .el-menu-item:hover, #header .el-submenu__title:hover,#header .el-menu--horizontal > .el-menu-item:hover,#header .el-menu--horizontal > .el-submenu .el-submenu__title:hover,.el-menu--popup .el-menu-item:hover {color: ${primaryHover} !important;background: rgba(64,158,255,.10) !important;}/* 顶栏内部导航项(首页/班级/训练/比赛等)透明,避免白底破坏卡片感 */#header ul, #header li, #header .logo, #header .logo .el-image,#header .drop-menu, #header .drop-score, #header .drop-msg {background: transparent !important;}/* ============================================================* vxe-table(题目/训练/比赛/提交记录/排名列表)* 白底画在 wrapper 层,行/单元格默认透明;因此先打掉 wrapper 白底,* 行/单元格保持透明,整表透出背景图(或外层 el-card 玻璃)* ============================================================ */.vxe-table {background: transparent !important;}.vxe-table--render-default .vxe-table--body-wrapper,.vxe-table--render-default .vxe-table--footer-wrapper,.vxe-table--render-default .vxe-table--header-wrapper,.vxe-table--fixed-left-wrapper,.vxe-table--fixed-right-wrapper,.vxe-table--fixed-left-wrapper .vxe-table--body-wrapper,.vxe-table--fixed-right-wrapper .vxe-table--body-wrapper {background: transparent !important;}.vxe-body--row,.vxe-body--column,.vxe-header--row,.vxe-header--column {background: transparent !important;}/* 保留斑马纹/悬停可读性:半透明,不破坏整体玻璃感 */.vxe-body--row.row--stripe { background: rgba(255,255,255,.04) !important; }.vxe-body--row.row--hover { background: rgba(255,255,255,.08) !important; }.vxe-table .notdone-row { background: rgba(64,158,255,.10) !important; }/* 卡片容器(本站真实内容卡片) */${CARD_SELECTORS} {background: ${cardBg} !important;backdrop-filter: blur(${blurPx}) !important;-webkit-backdrop-filter: blur(${blurPx}) !important;border-radius: ${radius} !important;border: 1px solid ${rgba(cfg.cardColor, 0.12)} !important;box-shadow: ${shadow} !important;color: ${textColor} !important;}/* el-card 内层 body/header 与题目页选项卡内容透明,让一整行小标签落在同一块玻璃上 */.el-card__body,.el-card__header,.el-tabs--border-card > .el-tabs__header,.el-tabs--border-card > .el-tabs__content,.el-tabs__content,.js-left {background: transparent !important;}/* 主内容列只透明,不加边框/圆角(避免整体套一层卡) */#main, .flex-container #main, main {background: transparent !important;}/* 元信息标签保持通透(展示ID/题目/类别/语言等同一行小块),语义彩签保留颜色 */.info-rows, .info-rows > div, .info-rows span,.problem-tag, .category-item, .judge-time, .problem-time {background: transparent !important;}/* ============================================================* 头像修复:<avatar> 自定义元素尺寸由内联 width/height 锁定,* 禁止被卡片化规则误伤(放大/变形根因:祖先被加 border/padding/backdrop-filter)* ============================================================ */avatar, .user-avatar, .drop-avatar, .avatar-container,avatar img, .user-avatar img {background: transparent !important;border: 0 !important;border-radius: 0 !important;padding: 0 !important;box-shadow: none !important;backdrop-filter: none !important;-webkit-backdrop-filter: none !important;}avatar { flex: 0 0 auto !important; }avatar > img, avatar img { width: 100% !important; height: 100% !important; }/* 表格(非 vxe 的普通表格透明化;vxe 已在上方单独处理) */table, .table {background: transparent !important;color: ${textColor} !important;}table:not(.vxe-table) th {color: ${secColor} !important;background: ${rgba(cfg.primary, 0.06)} !important;}table:not(.vxe-table) td {background: ${rgba(cfg.cardColor, 0.45)} !important;}table:not(.vxe-table) tr:nth-child(even) td {background: ${rgba(cfg.cardColor, 0.3)} !important;}/* 提交详情测试点小卡(.test-detail-item)合并为同一块玻璃 */.test-detail-item {background: ${rgba(cfg.cardColor, 0.06)} !important;margin: 4px 0 !important;border-radius: 6px !important;}.test-run-static, .test-detail-item h2 { background: transparent !important; }/* 代码块(提交记录、公告等)透明化 */pre, code, kbd, samp,[class*="code"], [class*="Code"],[class*="highlight"], [class*="Highlight"],[class*="hljs"], .hljs, .CodeMirror {background: ${rgba(cfg.cardColor, 0.55)} !important;color: ${textColor} !important;border-radius: 6px !important;}pre {border: 1px solid ${rgba(cfg.cardColor, 0.15)} !important;}/* 输入框 */input, textarea, select {background: ${rgba(cfg.cardColor, 0.85)} !important;color: ${textColor} !important;65 行未改动if (!config.enabled) {if (styleEl) styleEl.textContent = '';return;}// 做题页面:保持纯白,不应用美化if (config.cardMode && isSolvingPage()) {if (styleEl) styleEl.textContent = '';return;}const css = buildCSS(config);if (styleEl) styleEl.textContent = css;else styleEl = GM_addStyle(css);}/* ============================================================* 洛谷主题格式 ↔ 配置 转换* ============================================================ */// 洛谷 blur 是三态枚举(源码确证):0/缺省=无模糊;1010=弱(2px);1000或其它非0=强(10px)function luoguBlurToPx(v) {const n = Number(v);if (!n) return 0; // 0 / 缺省 → 无模糊if (n === 1010) return 2; // 弱 → 2pxreturn 10; // 1000 或任意非 0 ≠1010 → 强 → 10px}function pxToLuoguBlur(px) {const n = Math.round(Number(px) || 0);if (n <= 0) return 0; // 0 → 0(关闭)if (n <= 2) return 1010; // 1-2px → 弱档return 1000; // ≥3px → 强档}// 洛谷 midOpts.size → 我们的 bgSize('custom' 时保存原始值)function luoguSizeToOurs(size) {if (!size) return 'cover';const s = String(size).toLowerCase();if (s === 'cover') return 'cover';if (s === 'contain') return 'contain';if (s === 'auto') return 'auto';return 'custom';}function convertLuoguToConfig(luoguTheme) {const cfg = {};// 纯暗色主题(无 lNavi/lBody)时以 dNavi/dBody 为来源const isDarkOnly = !luoguTheme.lNavi && !luoguTheme.lBody && (luoguTheme.dNavi || luoguTheme.dBody);const lNavi = isDarkOnly ? (luoguTheme.dNavi || {}) : (luoguTheme.lNavi || {});const lBody = isDarkOnly ? (luoguTheme.dBody || {}) : (luoguTheme.lBody || {});const mo = lBody.midOpts || {};if (lNavi.back) cfg.naviBack = lNavi.back;if (lNavi.fore) cfg.naviFore = lNavi.fore;if (lBody.back) cfg.bgColor = lBody.back;if (typeof lBody.blur === 'number') cfg.blur = luoguBlurToPx(lBody.blur);if (lBody.image) cfg.bgImage = lBody.image; // 有无背景图只由 image 字段决定// 重复方式:现网 repeat 优先,旧版 notEmpty 回落(notEmpty===false → 平铺)let repeat = 'no-repeat';if (mo.repeat === 'all') repeat = 'repeat';else if (mo.repeat === 'x') repeat = 'repeat-x';else if (mo.repeat === 'y') repeat = 'repeat-y';else if (mo.repeat === 'no-repeat') repeat = 'no-repeat';else if (mo.notEmpty === false || mo.notEmpty === 0) repeat = 'repeat';cfg.bgRepeat = repeat;if (mo.size) {const s = String(mo.size).toLowerCase();cfg.bgSize = luoguSizeToOurs(s);if (cfg.bgSize === 'custom') cfg.bgSizeCustom = String(mo.size);}if (Array.isArray(mo.position) && mo.position.length >= 2) {cfg.bgPosX = clampNum(mo.position[0], 0, 100, 50);cfg.bgPosY = clampNum(mo.position[1], 0, 100, 0);}if (typeof mo.brightness === 'number') cfg.bgBrightness = clampNum(mo.brightness, -100, 100, 0);// degree 是 lBody.color 多色渐变底色方向角(不是图片旋转角),不映射为 bgDegree// fade:只看正负号(>0 顶部 400px 渐隐 / <0 底部 / 0 无),仅取当前层(浅色 lBody / 纯暗色 dBody)const fade = Number(lBody.fade) || 0;if (fade !== 0) cfg.bgFade = fade > 0 ? 1 : -1;return cfg;}function configToLuogu(cfg) {// 以原始洛谷主题为基础,保留未知字段(可加字段不能少)const base = cfg.luoguTheme && typeof cfg.luoguTheme === 'object' ? JSON.parse(JSON.stringify(cfg.luoguTheme)) : {};if (!base.lNavi) base.lNavi = {};if (!base.lBody) base.lBody = {};if (!base.dNavi) base.dNavi = { back: '#ffffff', fore: '#262626' };if (!base.dBody) base.dBody = { back: '#ffffff', blur: 1000, fade: 1000 };const lBody = base.lBody;if (!lBody.midOpts) lBody.midOpts = {};const lNavi = base.lNavi;lNavi.back = cfg.naviBack || cfg.navbarColor || '#ffffff';lNavi.fore = cfg.naviFore || '#333333';lBody.back = cfg.bgColor || '#efefef';lBody.blur = pxToLuoguBlur(cfg.blur);if (cfg.bgImage) lBody.image = cfg.bgImage;lBody.midOpts.size = cfg.bgSize === 'custom' ? (cfg.bgSizeCustom || 'cover') : (cfg.bgSize || 'cover');// degree 是洛谷渐变底色方向角,非图片旋转:有原值则保留,无则不写if (!(lBody.midOpts.degree >= 0)) lBody.midOpts.degree = 0;// 现网用 repeat 字段表达重复方式;旧版 notEmpty 已废弃,导出时删除(无损升级)const repeatMap = { 'repeat': 'all', 'repeat-x': 'x', 'repeat-y': 'y' };lBody.midOpts.repeat = repeatMap[cfg.bgRepeat] || 'no-repeat';delete lBody.midOpts.notEmpty;lBody.midOpts.position = [cfg.bgPosX || 50, cfg.bgPosY || 0];lBody.midOpts.brightness = cfg.bgBrightness || 0;base.name = cfg.themeName || '';return base;}// 判断是否为洛谷主题格式(含 lBody / lNavi 等字段)function isLuoguTheme(obj) {return !!(obj && (obj.lBody || obj.lNavi || obj.dBody || obj.dNavi));}/* ============================================================* 主题导入 / 导出* ============================================================ */function normalizeTheme(obj) {const t = obj || {};2 行未改动primary: t.primary || t.mainColor || t.accent || DEFAULT_CONFIG.primary,primaryHover: t.primaryHover || DEFAULT_CONFIG.primaryHover,bgColor: t.bgColor || t.background || t.backgroundColor || DEFAULT_CONFIG.bgColor,bgImage: t.bgImage || t.backgroundImage || '',bgPosX: clampNum(t.bgPosX, 0, 100, DEFAULT_CONFIG.bgPosX),bgPosY: clampNum(t.bgPosY, 0, 100, DEFAULT_CONFIG.bgPosY),bgSize: t.bgSize || DEFAULT_CONFIG.bgSize,bgSizeCustom: t.bgSizeCustom || DEFAULT_CONFIG.bgSizeCustom,bgRepeat: t.bgRepeat || DEFAULT_CONFIG.bgRepeat,bgBrightness: clampNum(t.bgBrightness, -100, 100, DEFAULT_CONFIG.bgBrightness),bgDegree: clampNum(t.bgDegree, 0, 360, DEFAULT_CONFIG.bgDegree),bgFade: clampNum(t.bgFade, -1, 1, DEFAULT_CONFIG.bgFade),blur: clampNum(t.blur, 0, 40, DEFAULT_CONFIG.blur),opacity: clampNum(t.opacity, 0, 1, DEFAULT_CONFIG.opacity),radius: clampNum(t.radius, 0, 30, DEFAULT_CONFIG.radius),textColor: t.textColor || DEFAULT_CONFIG.textColor,secondaryColor: t.secondaryColor || DEFAULT_CONFIG.secondaryColor,cardColor: t.cardColor || DEFAULT_CONFIG.cardColor,navbarColor: t.navbarColor || DEFAULT_CONFIG.navbarColor,naviBack: t.naviBack || t.navbarColor || DEFAULT_CONFIG.naviBack,naviFore: t.naviFore || DEFAULT_CONFIG.naviFore,dark: !!t.dark,shadow: t.shadow !== false,customCSS: t.customCSS || ''};}function parseTheme(text) {let obj = null;try { obj = JSON.parse(text); } catch (e) { /* not json */ }if (!obj) {const m = text.match(/\{[\s\S]*\}/);if (m) { try { obj = JSON.parse(m[0]); } catch (e2) { /* ignore */ } }}if (!obj) throw new Error('无法解析主题:请输入 JSON 格式的主题配置');return obj;}// 导入入口:支持 洛谷格式 / 旧格式 / 彩蛋function importTheme(text) {const trimmed = String(text || '').trim();// 彩蛋:输入触发词并导入if (EASTER_EGG_TRIGGERS.includes(trimmed)) {// 彩蛋主题自带完整 __config 快照,直接无损恢复(与导出 JSON 完全一致)const egg = Object.assign({}, DEFAULT_CONFIG,EASTER_EGG_THEME.__config && typeof EASTER_EGG_THEME.__config === 'object'? EASTER_EGG_THEME.__config: convertLuoguToConfig(EASTER_EGG_THEME));return { cfg: egg, isEgg: true };}const obj = parseTheme(trimmed);// 完整快照格式(本脚本导出):__config 保存完整内部状态,直接无损恢复if (obj && obj.__meta && obj.__meta.schema === 'jxycoi-display-better' &&obj.__config && typeof obj.__config === 'object') {return {cfg: Object.assign({}, DEFAULT_CONFIG, obj.__config),isEgg: false};}if (isLuoguTheme(obj)) {// 洛谷主题格式:保留原始完整对象,映射到配置const mapped = convertLuoguToConfig(obj);// 只有暗色部分(无 lNavi/lBody)时视为暗色主题const isDarkLuogu = !obj.lNavi && !obj.lBody && (obj.dNavi || obj.dBody);const merged = Object.assign({}, config, mapped, {dark: isDarkLuogu || !!config.dark,themeName: obj.name || obj.author || '导入的洛谷主题',luoguTheme: obj,luoguExtra: { name: obj.name, author: obj.author, css: obj.css }});return { cfg: merged, isEgg: false };}// 旧格式:脚本自身的配置 JSONconst theme = normalizeTheme(obj);return {cfg: Object.assign({}, config, theme, { themeName: theme.name || config.themeName }),isEgg: false};}function exportTheme() {const luogu = configToLuogu(config);// 附加完整快照,保证导出→导入完全无损往返(洛谷官方浅合并+按已知键读取,__meta/__config 不影响洛谷渲染)luogu.__meta = {schema: 'jxycoi-display-better',schemaVersion: 1,appVersion: '1.2.0',exportedAt: new Date().toISOString(),name: config.themeName || '',author: 'zhanjinghan',source: config.luoguTheme ? 'luogu-import' : 'native'};luogu.__config = JSON.parse(JSON.stringify(config));return JSON.stringify(luogu, null, 2);}function copyText(text) {try {if (navigator.clipboard && navigator.clipboard.writeText) {15 行未改动return Promise.resolve(ok);}/* ============================================================* 去除首页图片(/api/public/img/xxx.png 等大图)* ============================================================ */let hideImgObserver = null;function applyHideHomeImages() {if (!config.hideHomeImages) return;const imgs = document.querySelectorAll('img');imgs.forEach(img => {const src = img.getAttribute('src') || img.currentSrc || '';// 只看 /api/public/img/ 下的图;小尺寸头像(宽高<80px)不隐藏if (src.indexOf('/api/public/img/') !== -1) {const w = img.naturalWidth || img.width;const h = img.naturalHeight || img.height;if (w >= 80 && h >= 80) img.style.display = 'none';}});if (!hideImgObserver) {hideImgObserver = new MutationObserver(() => applyHideHomeImages());hideImgObserver.observe(document.body, { childList: true, subtree: true });}}function clearHideHomeImages() {if (hideImgObserver) { hideImgObserver.disconnect(); hideImgObserver = null; }document.querySelectorAll('img').forEach(img => {const src = img.getAttribute('src') || img.currentSrc || '';if (src.indexOf('/api/public/img/') !== -1) img.style.display = '';});}/* ============================================================* 设置面板 UI* ============================================================ */let panelEl = null, btnEl = null;36 行未改动]);P.appendChild(title);// 开关P.appendChild(switchRow('enabled', '启用美化', e => {config.enabled = e.target.checked;refreshAll();}));// 主题选择P.appendChild(sectionTitle('主题'));const themeRow = el('div', { style: 'display:flex; gap:6px; flex-wrap:wrap; margin-bottom:10px;' });8 行未改动}, [name]));});P.appendChild(themeRow);P.appendChild(sectionTitle('颜色'));P.appendChild(colorRow('primary', '主题色', () => {config.primary = valueOf('cfg-primary');config.primaryHover = darken(config.primary, 0.12);refreshAll();}));P.appendChild(colorRow('bgColor', '背景色', () => {config.bgColor = valueOf('cfg-bgColor');refreshAll();}));P.appendChild(colorRow('naviBack', '导航背景', () => {config.naviBack = valueOf('cfg-naviBack');refreshAll();}));P.appendChild(sectionTitle('背景图片'));const bgImgWrap = el('div', { style: rowStyle() }, [el('label', { style: 'flex:1;' }, ['图片 URL']),el('input', { type: 'text', id: 'cfg-bgImage', value: config.bgImage, placeholder: '留空为纯色', style: inputStyle(), onchange: e => {config.bgImage = e.target.value.trim();refreshAll();} })]);P.appendChild(bgImgWrap);P.appendChild(sliderRow('bgPosX', '图片位置 X', 0, 100, '%', () => {config.bgPosX = Number(valueOf('cfg-bgPosX'));refreshAll();}));P.appendChild(sliderRow('bgPosY', '图片位置 Y', 0, 100, '%', () => {config.bgPosY = Number(valueOf('cfg-bgPosY'));refreshAll();}));// 图片尺寸下拉const sizeWrap = el('div', { style: rowStyle() }, [el('label', { style: 'flex:1;' }, ['图片尺寸']),el('select', { id: 'cfg-bgSize', style: inputStyle(), onchange: e => {config.bgSize = e.target.value;refreshAll();} }, [el('option', { value: 'auto' }, ['自动']),el('option', { value: 'cover' }, ['填充']),el('option', { value: 'contain' }, ['适应']),el('option', { value: 'custom' }, ['自定义'])])]);P.appendChild(sizeWrap);const sizeCustomWrap = el('div', { style: rowStyle() }, [el('label', { style: 'flex:1;' }, ['自定义尺寸']),el('input', { type: 'text', id: 'cfg-bgSizeCustom', value: config.bgSizeCustom, placeholder: '如 100% 100% / 800px 600px', style: inputStyle(), onchange: e => {config.bgSizeCustom = e.target.value.trim();refreshAll();} })]);P.appendChild(sizeCustomWrap);// 图片重复下拉const repeatWrap = el('div', { style: rowStyle() }, [el('label', { style: 'flex:1;' }, ['图片重复']),el('select', { id: 'cfg-bgRepeat', style: inputStyle(), onchange: e => {config.bgRepeat = e.target.value;refreshAll();} }, [el('option', { value: 'no-repeat' }, ['不重复']),el('option', { value: 'repeat' }, ['全部重复']),el('option', { value: 'repeat-x' }, ['横向重复']),el('option', { value: 'repeat-y' }, ['纵向重复'])])]);P.appendChild(repeatWrap);P.appendChild(sliderRow('bgBrightness', '图片亮度', -100, 100, '', () => {config.bgBrightness = Number(valueOf('cfg-bgBrightness'));refreshAll();}));P.appendChild(sliderRow('bgDegree', '图片旋转', 0, 360, '°', () => {config.bgDegree = Number(valueOf('cfg-bgDegree'));refreshAll();}));P.appendChild(sectionTitle('效果'));P.appendChild(sliderRow('blur', '背景模糊', 0, 40, 'px', () => {config.blur = Number(valueOf('cfg-blur'));7 行未改动config.radius = Number(valueOf('cfg-radius'));refreshAll();}));P.appendChild(sectionTitle('功能'));P.appendChild(switchRow('hideHomeImages', '去除首页图片', e => {config.hideHomeImages = e.target.checked;if (config.hideHomeImages) applyHideHomeImages();else clearHideHomeImages();refreshAll();}));P.appendChild(switchRow('cardMode', '卡片化(做题页自动豁免)', e => {config.cardMode = e.target.checked;refreshAll();}));P.appendChild(sectionTitle('导入 / 导出'));const importWrap = el('div', { style: 'margin-bottom:8px;' }, [el('textarea', { id: 'cfg-import', placeholder: '粘贴洛谷主题 JSON / 本脚本导出 JSON', style: 'width:100%; height:56px; box-sizing:border-box; font-size:12px; border:1px solid #d0d7de; border-radius:6px; padding:6px;' }),el('div', { style: 'display:flex; gap:6px; margin-top:6px;' }, [el('button', { style: btnStyle(false), onclick: () => {try {const r = importTheme(valueOf('cfg-import'));config = r.cfg;refreshAll();toast(r.isEgg ? '彩蛋主题已应用 ✨' : '主题导入成功');} catch (e) {toast('导入失败:' + e.message, true);}} }, ['导入主题']),65 行未改动el('label', { style: 'flex:1;' }, [label]),input, out]);}function switchRow(id, label, onChange) {return el('div', { style: rowStyle() }, [el('label', { style: 'flex:1;' }, [label]),el('input', { type: 'checkbox', id: 'cfg-' + id, checked: config[id], style: 'width:16px;height:16px;', onchange: onChange })]);}function valueOf(id) {const n = document.getElementById(id);return n ? n.value : '';}2 行未改动saveConfig(config);syncPanelValues();applyStyle();syncThemeButtons();if (config.hideHomeImages) applyHideHomeImages();else clearHideHomeImages();}function syncPanelValues() {if (!panelEl) return;const set = (id, v) => { const n = document.getElementById(id); if (n) n.value = v; };set('cfg-enabled', config.enabled);set('cfg-primary', config.primary);set('cfg-bgColor', config.bgColor);set('cfg-naviBack', config.naviBack);set('cfg-bgImage', config.bgImage);set('cfg-bgPosX', String(config.bgPosX));set('cfg-bgPosY', String(config.bgPosY));set('cfg-bgSize', config.bgSize);set('cfg-bgSizeCustom', config.bgSizeCustom);set('cfg-bgRepeat', config.bgRepeat);set('cfg-bgBrightness', String(config.bgBrightness));set('cfg-bgDegree', String(config.bgDegree));set('cfg-blur', String(config.blur));set('cfg-opacity', String(Math.round(config.opacity * 100)));set('cfg-radius', String(config.radius));set('cfg-hideHomeImages', config.hideHomeImages);set('cfg-cardMode', config.cardMode);set('cfg-customCSS', config.customCSS);}function syncThemeButtons() {if (!panelEl) return;17 行未改动toastEl.textContent = msg;toastEl.style.background = isError ? 'rgba(180,60,60,.92)' : 'rgba(0,0,0,.78)';toastEl.style.opacity = '1';clearTimeout(toastEl._t);toastEl._t = setTimeout(() => { toastEl.style.opacity = '0'; }, 2200);}function buildButton() {if (btnEl) return btnEl;16 行未改动return btnEl;}/* ============================================================* SPA 适配:MutationObserver 补样式/入口/图片隐藏* ============================================================ */let moTimer = null;function onDomChange() {clearTimeout(moTimer);moTimer = setTimeout(() => {applyStyle();if (config.hideHomeImages) applyHideHomeImages();if (btnEl && !btnEl.isConnected) document.body.appendChild(btnEl);if (panelEl && !panelEl.isConnected) document.body.appendChild(panelEl);}, 300);}/* ============================================================* 初始化* ============================================================ */function init() {if (!document.body) {document.addEventListener('DOMContentLoaded', init);return;}applyStyle();if (config.hideHomeImages) applyHideHomeImages();buildButton();new MutationObserver(onDomChange).observe(document.body, { childList: true, subtree: true });}if (document.readyState === 'loading') {document.addEventListener('DOMContentLoaded', init);} else {init();}})();```