标题
增加 1 行删除 1 行
1想要装饰洛谷吗?用铍洛谷吧1想要装饰你的洛谷吗?试试铍洛谷吧!
正文
增加 6022 行删除 62 行
12345678910111213141516176 行未改动2425262728293031323334353637383936 行未改动767778798081828318 行未改动10210310410510610710810911011111211311476 行未改动19119219319419519619719821 行未改动22022122222322422522622724 行未改动252253254255256257258259353 行未改动全部展开613614615616617618619620621622623624625626627628244 行未改动全部展开87387487587687787887988088119 行未改动901902903904905906907908146 行未改动全部展开1055105610571058105910601061106293 行未改动1156115711581159116011611162116371 行未改动1235123612371238123912401241124262 行未改动1305130613071308130913101311131213131314131513161317131828 行未改动1347134813491350135113521353135471 行未改动1426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314645 行未改动147014711472147314741475147614773 行未改动1481148214831484148514861487148823 行未改动151215131514151515161517151815191520152115221523152415251526152715281529153015312 行未改动15341535153615371538153915401541154215431544154512 行未改动155815591560156115621563156415651566156715687 行未改动15761577157815791580158115821583182 行未改动全部展开17661767176817691770177117721773134 行未改动全部展开1908190919101911191219131914191519161917191819191920192119221923192421 行未改动194619471948194919501951195219531954195519561957195871 行未改动2030203120322033203420352036203751 行未改动20892090209120922093209420952096209720982099210021012102106 行未改动全部展开2209221022112212221322142215221624 行未改动2241224222432244224522462247224822492250225122522253225428 行未改动2283228422852286228722882289229022912292199 行未改动全部展开24922493249424952496249724982499250025012502::::info[成品展示]::::::::warning[叠甲]由于这是作者第一次探索类似的插件,以及这个项目目前还处于测试阶段,所以可能有各种各样的BUG。还有一个问题,就是~~洛谷网校目前适配成一坨了~~::::## 一、这是什么「铍洛谷」是一个 Tampermonkey 用户脚本,给洛谷全站加上:6 行未改动1. 浏览器装 **Tampermonkey** 扩展2. 打开 Tampermonkey 面板 → 新建脚本3. 把整份脚本粘进去 → 保存(Ctrl+S)4. 打开任意洛谷页面,F5 刷新,看到控制台打印 `[铍洛谷] v5.3 已启动。` 就说明成功了::::info[脚本]{open}```javascript// ==UserScript==// @name 铍洛谷// @namespace http://tampermonkey.net/// @version 5.3// @description 洛谷主站(含用户主页)+ 网校 + 有题 + image/paste/ticket 统一背景板// @author Breakon and DeepSeek// @match https://www.luogu.com.cn/*// @match https://class.luogu.com.cn/*36 行未改动const GLASS_VAR_BG_HD = '--luogu-glass-bg-hd';const GLASS_VAR_BORDER = '--luogu-glass-border';const GLASS_VAR_SHADOW = '--luogu-glass-shadow';const GLASS_VAR_TICKET_DIVIDER = '--luogu-glass-ticket-divider';const PAINT_MARK = 'data-bg-painted';const ORIG_BG_ATTR = 'data-bg-orig-bg';const TICKET_TOPBAR_ATTR = 'data-ticket-topbar';18 行未改动const IS_MAIN_SITE = HOST === 'www.luogu.com.cn' || HOST === 'www.luogu.org';const IS_CLASS_SITE = HOST === 'class.luogu.com.cn';const IS_TI_SITE = HOST === 'ti.luogu.com.cn';const BLUE_MARK = 'data-darkened-blue';const GREEN_MARK = 'data-darkened-green';const GRAY_MARK = 'data-darkened-gray';const DARK_BLUE = 'rgb(20, 85, 143)';const DARK_GREEN = 'rgb(34, 112, 10)';const DARK_GRAY = 'rgb(60, 60, 70)';const SKIP_TAGS = new Set(['INPUT', 'TEXTAREA', 'BUTTON', 'SELECT',76 行未改动'blockquote', 'figcaption', 'cite', 'q', 'mark','section', 'article', 'header', 'footer', 'aside',].join(', ');/* ============================================================* 状态* ============================================================ */function readAlpha() {21 行未改动let luoguThemePollTimer = null;let lastLuoguThemeImage = '';let userCardGlassTimer = null;/* ============================================================* 工具* ============================================================ */24 行未改动const lum = 0.299 * r + 0.587 * g + 0.114 * b;if (lum > 128) return 'rgba(0, 0, 0, 0.55)';return 'rgba(255, 255, 255, 0.55)';}function parseRgb(str) {if (!str) return null;const m = str.match(/rgba?\(\s*(\d+)\s*[,\s]\s*(\d+)\s*[,\s]\s*(\d+)/);if (!m) return null;353 行未改动全部展开root.style.setProperty(GLASS_VAR_BG_HD, buildFeedHeaderBg(currentColor, currentAlpha));root.style.setProperty(GLASS_VAR_BORDER, GLASS_BORDER);root.style.setProperty(GLASS_VAR_SHADOW, GLASS_SHADOW);root.style.setProperty(GLASS_VAR_TICKET_DIVIDER, buildTicketDividerColor(currentColor));}function clearGlassVars() {const root = document.documentElement;root.style.removeProperty(GLASS_VAR_BG);root.style.removeProperty(GLASS_VAR_BG_HD);root.style.removeProperty(GLASS_VAR_BORDER);root.style.removeProperty(GLASS_VAR_SHADOW);root.style.removeProperty(GLASS_VAR_TICKET_DIVIDER);}/* ============================================================* 内联画背景244 行未改动全部展开`;}/* ============================================================* ★ v5.3:用户名悬停卡片 —— CSS 层面兜底(JS 内联是主方案)* ============================================================ */function buildUserCardGlassRules() {return `body .l-card.float-card:not(#${FORCE_ID}),19 行未改动`;}/* ============================================================* 玻璃 CSS* ============================================================ */function injectGlassCSS() {let styleEl = document.getElementById(GLASS_STYLE_ID);146 行未改动全部展开const inputGlassRules = buildInputGlassRules();const problemListGlassRules = buildProblemListGlassRules();const userCardGlassRules = buildUserCardGlassRules();const content = `${navSolidRules}${pseudoMaskRules}93 行未改动${inputGlassRules}${problemListGlassRules}${userCardGlassRules}.user-header-top:not(#${FORCE_ID}) {background-color: transparent !important;box-shadow: none !important;71 行未改动try { if (el.closest(CONTENT_EXCLUDE)) return; } catch (e) {}try { if (el.closest(CSS_OWNED_SUBTREE)) return; } catch (e) {}try { if (el.closest(NAV_SELECTOR)) return; } catch (e) {}try { if (el.closest('.l-card.float-card, .dropdown.shown .l-card')) return; } catch (e) {}try { if (el.closest(FLOATING_EXCLUDE)) return; } catch (e) {}if (paintedElements.get(el) === ver) return;62 行未改动el.style.removeProperty('border');el.style.removeProperty('box-shadow');el.style.removeProperty('border-radius');});}/* ============================================================* ★ v5.3:JS 内联 !important 强制悬停卡片毛玻璃* 用 setInterval 持续覆盖,防止洛谷 Vue 组件把白底写回来* 只改卡片本体背景,不动里面的头像/图标/横幅图* ============================================================ */function forceUserCardGlass() {if (!currentEnabled) return;const bg = buildBgValue(currentColor, currentAlpha);28 行未改动}}/* ============================================================* 强制 .refined-input.text 的内层元素透明* ============================================================ */function forceTextInnerTransparent() {if (!currentEnabled) return;71 行未改动});}/* ============================================================* 文字加深* ============================================================ */function isBlueish(r, g, b) {if (b < 130) return false;if (b - r < 40) return false;if (b < g - 10) return false;if (r > 130) return false;if (b < 160 && r < 40) return false;return true;}function isGreenish(r, g, b) {if (g < 130) return false;if (g - r < 40) return false;if (g - b < 40) return false;if (r > 130) return false;return true;}function isGrayish(r, g, b) {const max = Math.max(r, g, b);const min = Math.min(r, g, b);if (max - min > 30) return false;if (max < 40) return false;if (min > 220) return false;return true;}function isAlreadyDarkBlue(r, g, b) {return Math.abs(r - 20) < 15 && Math.abs(g - 85) < 15 && Math.abs(b - 143) < 15;}function isAlreadyDarkGreen(r, g, b) {return Math.abs(r - 34) < 15 && Math.abs(g - 112) < 15 && Math.abs(b - 10) < 15;}function isAlreadyDarkGray(r, g, b) {return Math.abs(r - 60) < 12 && Math.abs(g - 60) < 12 && Math.abs(b - 70) < 12;}5 行未改动if (!containers.length) return;containers.forEach(card => {if (card.closest && card.closest(`#${PANEL_ID}`)) return;card.querySelectorAll(TEXT_DARKEN_SELECTOR).forEach(el => {if (el.children.length > 0) return;if (SKIP_TAGS.has(el.tagName)) return;3 行未改动if (el.closest('.user-header-top')) return;if (el.closest(NAV_SELECTOR)) return;if (el.closest(`.${INPUT_SKIP_CLASS}`)) return;if (el.closest(`#${PANEL_ID}`)) return;try { if (el.closest(CONTENT_EXCLUDE)) return; } catch (e) {}try { if (el.closest('.refined-input.search-text')) return; } catch (e) {}try { if (el.closest('.refined-input.text')) return; } catch (e) {}try { if (el.closest('.search-option')) return; } catch (e) {}23 行未改动try { cs = getComputedStyle(el); } catch { return; }const rgb = parseRgb(cs.color);if (!rgb) return;if (!isAlreadyDarkBlue(rgb.r, rgb.g, rgb.b) && isBlueish(rgb.r, rgb.g, rgb.b)) {el.style.setProperty('color', DARK_BLUE, 'important');el.setAttribute(BLUE_MARK, '1');darkenedElements.add(el);return;}if (!isAlreadyDarkGreen(rgb.r, rgb.g, rgb.b) && isGreenish(rgb.r, rgb.g, rgb.b)) {el.style.setProperty('color', DARK_GREEN, 'important');el.setAttribute(GREEN_MARK, '1');darkenedElements.add(el);return;}if (!isAlreadyDarkGray(rgb.r, rgb.g, rgb.b) && isGrayish(rgb.r, rgb.g, rgb.b)) {el.style.setProperty('color', DARK_GRAY, 'important');el.setAttribute(GRAY_MARK, '1');darkenedElements.add(el);2 行未改动});}function clearColorText() {document.querySelectorAll(`[${BLUE_MARK}], [${GREEN_MARK}], [${GRAY_MARK}]`).forEach(el => {el.style.removeProperty('color');el.removeAttribute(BLUE_MARK);el.removeAttribute(GREEN_MARK);el.removeAttribute(GRAY_MARK);});darkenedElements = new WeakSet();}12 行未改动clearWhiteCardsPaint();clearTextInnerTransparent();clearSolidNavigationBars();clearPaintedBackground();stopThemeBgWatcher();stopLuoguThemePoll();stopUserCardGlassLoop();lastThemeInfo = { imageUrl: null, backColor: null, colorGradient: null, source: 'none' };return;}7 行未改动applyTicketTopBarBlack();applyWhiteCardsGlass();forceUserCardGlass();startUserCardGlassLoop();forceTextInnerTransparent();darkenColorText();startThemeBgWatcher();startLuoguThemePoll();182 行未改动全部展开transform: translateX(20px);}#${PANEL_ID} .bg-input-area { margin-top: 14px; transition: opacity 0.3s; }#${PANEL_ID} .bg-input-area.disabled { opacity: 0.45; pointer-events: none; }#${PANEL_ID} .bg-row {display: flex; align-items: center; gap: 12px;padding: 10px 12px; border-radius: 10px;background: rgba(255, 255, 255, 0.25);134 行未改动全部展开<div class="bg-preview-color" id="bg-preview-color"></div><span>预览效果</span></div><div class="debug-info" id="bg-debug"></div><div class="btn-row"><button class="btn btn-primary" id="bg-save">保存</button><button class="btn btn-secondary" id="bg-reset">重置</button><button class="btn btn-secondary" id="bg-refresh-theme">重新拉取主题</button><button class="btn btn-secondary" id="bg-url-clear">清空手动 URL</button><button class="btn btn-secondary" id="bg-auto-clear">清空自动缓存</button><span class="save-status" id="bg-status">已保存</span></div></div>`;panel.querySelectorAll('input, textarea').forEach(el => {el.classList.add(INPUT_SKIP_CLASS);21 行未改动const manual = GM_getValue(KEY_THEME_BG_URL, '') || '(空)';const auto = GM_getValue(KEY_AUTO_BG_URL, '') || '(空)';const source = lastThemeInfo.source || 'none';const divider = buildTicketDividerColor(currentColor);debugInfo.innerHTML =`手动 URL: ${manual}<br>` +`自动缓存: ${auto}<br>` +`当前生效来源: <b>${source}</b><br>` +`工单分割线色: <b>${divider}</b>`;}function liveUpdate() {currentColor = colorInput.value;71 行未改动});toggle.addEventListener('change', () => {currentEnabled = toggle.checked;inputArea.classList.toggle('disabled', !toggle.checked);bumpPaintVersion();applyCustomBg();refreshDebug();51 行未改动/* ============================================================* 调试 & 手动设置接口* ============================================================ */PAGE_WIN.__luoguBgDebug = function () {console.group('==== 铍洛谷调试 v5.3 ====');console.log('enabled:', currentEnabled);console.log('手动 URL:', GM_getValue(KEY_THEME_BG_URL, '') || '(空)');console.log('自动缓存 URL:', GM_getValue(KEY_AUTO_BG_URL, '') || '(空)');console.log('自动缓存 backColor:', GM_getValue(KEY_AUTO_BG_BACK, '') || '(空)');console.log('自动缓存 gradient:', GM_getValue(KEY_AUTO_BG_GRAD, '') || '(空)');console.log('lastThemeInfo:', lastThemeInfo);console.log('isHomePage:', isHomePage());console.log('lastLuoguThemeImage:', lastLuoguThemeImage);106 行未改动全部展开applyCustomBg();console.log('[铍洛谷] 自动缓存 URL =', url || '(已清空)');};PAGE_WIN.__luoguBgVerbose = function (on) {PAGE_WIN.__LUOGU_BG_VERBOSE = !!on;console.log('[铍洛谷] verbose =', PAGE_WIN.__LUOGU_BG_VERBOSE);};24 行未改动});}console.log('[铍洛谷] v5.3 已启动。\n' +' 调试: __luoguBgDebug()\n' +' 悬停卡片调试: __luoguBgInspectUserCard()\n' +' 强制刷新: __luoguBgForceRefresh()\n' +' 重新拉取主题: __luoguBgFetchTheme()\n' +' fetch 拉取: __luoguBgFetchFromServer()');} catch (err) {console.error('[铍洛谷] boot 出错:', err);}28 行未改动}, 300);}}, 800);})();```::::---199 行未改动全部展开**注**:本文包括插件由DeepSeek协助完成***::::warning[免责声明]铍洛谷是一个美化洛谷的插件,不含任何爬取/滥用数据或API或修改了洛谷的核心功能或数据或影响其他用户或服务器稳定性等损害洛谷或其他用户利益的功能。如果用户因为铍洛谷(包括从第三方下载、私自修改等)被封禁,铍洛谷概不负责。如果洛谷官方明令禁止,请立即停止使用此脚本。::::123456789106 行未改动17181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347936 行未改动35163517351835193520352135223523352418 行未改动35433544354535463547354835493550355176 行未改动3628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365021 行未改动36723673367436753676367736783679368024 行未改动3705370637073708370937103711371237133714371537163717353 行未改动全部展开4071407240734074407540764077407840794080408140824083408440854086408740884089244 行未改动全部展开43344335433643374338433943404341434219 行未改动436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415146 行未改动全部展开45624563456445654566456745684569457093 行未改动46644665466646674668466946704671467271 行未改动47444745474647474748474947504751475262 行未改动4815481648174818481948204821482248234824482548264827482848294830483148324833483428 行未改动4863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492771 行未改动4999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773985 行未改动74047405740674077408740974107411741274133 行未改动74177418741974207421742274237424742523 行未改动744974507451745274537454745574562 行未改动745974607461746274637464746574667467746812 行未改动74817482748374847485748674877488748974907491749274937 行未改动7501750275037504750575067507750875097510182 行未改动全部展开769376947695769676977698769977007701134 行未改动全部展开7836783778387839784078417842784378447845784678477848784978507851785221 行未改动78747875787678777878787978807881788278837884788578867887788871 行未改动79607961796279637964796579667967796851 行未改动802080218022802380248025802680278028802980308031803280338034106 行未改动全部展开814181428143814481458146814781488149815081518152815381548155815624 行未改动81818182818381848185818681878188818981908191819281938194819528 行未改动822482258226822782288229823082318232823382348235199 行未改动全部展开8435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462::::info[成品展示]::::## 一、这是什么「铍洛谷」是一个 Tampermonkey 用户脚本,给洛谷全站加上:6 行未改动1. 浏览器装 **Tampermonkey** 扩展2. 打开 Tampermonkey 面板 → 新建脚本3. 把整份脚本粘进去 → 保存(Ctrl+S)4. 打开任意洛谷页面,F5 刷新,看到控制台打印 `[铍洛谷] v5.5 已启动。` 就说明成功了::::info[Safari Userscripts解决方案]```javascript// ==UserScript==// @name 铍洛谷(Userscripts 适配版)// @namespace https://www.luogu.com.cn/// @version 5.5.2// @description 洛谷背景板// @match https://www.luogu.com.cn/*// @match https://www.luogu.org/*// @match https://class.luogu.com.cn/*// @match https://ti.luogu.com.cn/*// @grant GM_getValue// @grant GM_setValue// @grant GM_addValueChangeListener// @grant unsafeWindow// @run-at document-idle// ==/UserScript==(function () {'use strict';try {if (window.top !== window.self) return;} catch (e) {return;}const __GM_PREFIX = 'luogu_bg_';const __nativeGMGetValue = (typeof globalThis.GM_getValue === 'function')? globalThis.GM_getValue.bind(globalThis): null;const __nativeGMSetValue = (typeof globalThis.GM_setValue === 'function')? globalThis.GM_setValue.bind(globalThis): null;const __nativeGMAddListener = (typeof globalThis.GM_addValueChangeListener === 'function')? globalThis.GM_addValueChangeListener.bind(globalThis): null;function __lsGet(key, def) {try {const raw = localStorage.getItem(__GM_PREFIX + key);return raw === null ? def : JSON.parse(raw);} catch (e) {return def;}}function __lsSet(key, val) {try {localStorage.setItem(__GM_PREFIX + key, JSON.stringify(val));} catch (e) {}}const GM_getValue = function (key, def) {if (__nativeGMGetValue) {try {const v = __nativeGMGetValue(key, def);if (v && typeof v.then === 'function') {return __lsGet(key, def);}if (v !== undefined) return v;} catch (e) {}}return __lsGet(key, def);};const GM_setValue = function (key, val) {if (__nativeGMSetValue) {try {__nativeGMSetValue(key, val);return;} catch (e) {}}__lsSet(key, val);};const GM_addValueChangeListener = function (key, cb) {if (__nativeGMAddListener) {try {return __nativeGMAddListener(key, cb);} catch (e) {}}return 'noop-' + key;};const PAGE_WIN = (typeof unsafeWindow !== 'undefined' && unsafeWindow)? unsafeWindow: window;/* ============================================================* 常量* ============================================================ */const KEY_ENABLED = 'bg_custom_enabled';const KEY_COLOR = 'bg_custom_color';const KEY_ALPHA = 'bg_custom_alpha';const KEY_THEME_BG_URL = 'bg_theme_bg_url';const KEY_AUTO_BG_URL = 'bg_auto_bg_url';const KEY_AUTO_BG_BACK = 'bg_auto_back_color';const KEY_AUTO_BG_GRAD = 'bg_auto_gradient';const PANEL_ID = 'luogu-bg-panel';const STYLE_ID = 'luogu-bg-panel-style';const HITOKOTO_PANEL_ID = 'luogu-hitokoto-panel';const GLASS_STYLE_ID = 'luogu-glass-style';const GLASS_VAR_BG = '--luogu-glass-bg';const GLASS_VAR_BG_HD = '--luogu-glass-bg-hd';const GLASS_VAR_BORDER = '--luogu-glass-border';const GLASS_VAR_SHADOW = '--luogu-glass-shadow';const GLASS_VAR_TICKET_DIVIDER = '--luogu-glass-ticket-divider';const GLASS_VAR_FROSTED_BG = '--luogu-glass-frosted-bg';const PAINT_MARK = 'data-bg-painted';const ORIG_BG_ATTR = 'data-bg-orig-bg';const TICKET_TOPBAR_ATTR = 'data-ticket-topbar';const NAV_SOLID_ATTR = 'data-nav-solid';const SHELL_CLEARED_ATTR = 'data-shell-cleared';const INNER_TRANSPARENT_ATTR = 'data-luogu-inner-transparent';const FORCE_ID = 'luogu-glass-force';const FIXED_BG_ID = 'luogu-fixed-bg';const FALLBACK_BG_IMAGE = 'https://cdn.luogu.com.cn/upload/image_hosting/e5xgx75m.webp';const INPUT_SKIP_CLASS = 'luogu-bg-skip';const GLASS_BORDER = '1px solid rgba(255, 255, 255, 0.55)';const GLASS_SHADOW = `0 8px 32px rgba(31, 38, 135, 0.12),0 2px 8px rgba(0, 0, 0, 0.05),inset 0 1px 0 rgba(255, 255, 255, 0.6)`;const USER_CARD_BLUR = 'blur(24px) saturate(180%)';const FEED_HEADER_DARKEN = 25;const FEED_HEADER_ALPHA_BOOST = 0.15;const HOST = location.hostname;const IS_MAIN_SITE = HOST === 'www.luogu.com.cn' || HOST === 'www.luogu.org';const IS_CLASS_SITE = HOST === 'class.luogu.com.cn';const IS_TI_SITE = HOST === 'ti.luogu.com.cn';const GRAY_MARK = 'data-darkened-gray';const DARK_GRAY = 'rgb(60, 60, 70)';const SKIP_TAGS = new Set(['INPUT', 'TEXTAREA', 'BUTTON', 'SELECT','IMG', 'SVG', 'PATH', 'IFRAME', 'VIDEO', 'CANVAS','SCRIPT', 'STYLE', 'LINK', 'META', 'HR', 'BR',]);const INLINE_TAGS = new Set(['SPAN', 'A', 'B', 'I', 'EM', 'STRONG', 'SMALL','CODE', 'KBD', 'TIME', 'LABEL', 'CITE', 'Q', 'S', 'U','SUB', 'SUP', 'MARK',]);const FLOATING_EXCLUDE = ['.v-popper__popper', '.v-popper__inner','[class*="popper"]', '[class*="popup"]', '[class*="popover"]','[class*="tooltip"]', '[class*="dropdown"]','.dropdown','[role="tooltip"]', '[role="menu"]','[aria-hidden="true"]',].join(', ');const CONTENT_EXCLUDE = ['.markdown-body','.lfe-markdown','.lg-article-content','.article-content','.feed-comment','.am-comment-bd','[class*="markdown-body"]','[class*="markdown-content"]',].join(', ');const NAV_SELECTOR = ['.top-bar','nav.sidebar','nav.sidebar.lside','.sidebar.lside.bar','.user-nav.rside','#app-sidenav','#app-header',].join(', ');const SHELL_SELECTOR = ['.theme-page','.theme-mid-full','.theme-mid','.main-container','.columba-content-wrap','.main-content','#app','#app-old','.lg-index-content','.lfe-body','main',].join(', ');const CSS_OWNED_SELECTOR = ['.tag-button','.refined-input.search-text','.list-scroll',].join(', ');const CSS_OWNED_SUBTREE = ['.refined-input.search-text','.list-scroll',].join(', ');const CARD_SELECTOR_RAW = ['.l-card', '.lg-article', '.lg-index-stat', '.lg-index-contest','.am-panel', '.n-card', '.training-card', '.category-card','.srqc', '.course-card', '.lesson-card', '.chapter-card','.class-card', '.problemsets', '.problemset-item','.lg-punch',].join(', ');const TEXT_DARKEN_SELECTOR = ['a', 'span', 'strong', 'em', 'small', 'p', 'i', 'b','div', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6','li', 'td', 'th', 'dt', 'dd', 'label', 'time','blockquote', 'figcaption', 'cite', 'q', 'mark','section', 'article', 'header', 'footer', 'aside',].join(', ');const MODAL_CARD_SELECTOR = ['.l-card.container.type-burger','.l-card.container.type-dialog','.l-card.container.type-popup','.l-card.container[class*="type-"]','.l-card[class*="container"][class*="type-"]','.l-modal .l-card','.l-modal__body .l-card','.v-modal .l-card','[class*="modal"] > .l-card','[class*="dialog"] > .l-card','[class*="popup"] > .l-card',].join(', ');/* ============================================================* 状态* ============================================================ */function readAlpha() {let v = parseFloat(GM_getValue(KEY_ALPHA, 0.78));if (isNaN(v) || v <= 0.01) v = 0.78;return Math.min(1, Math.max(0.05, v));}let currentEnabled = !!GM_getValue(KEY_ENABLED, false);let currentColor = GM_getValue(KEY_COLOR, '#232329') || '#232329';let currentAlpha = readAlpha();let lastThemeInfo = { imageUrl: null, backColor: null, colorGradient: null, source: 'none' };let themeHostEl = null;let paintVersion = 0;let paintedElements = new WeakMap();let darkenedElements = new WeakSet();let preferenceFetched = false;let preferenceFetching = false;let serverThemeFetched = false;let serverThemeFetching = false;let serverThemeAttempted = false;let luoguThemePollTimer = null;let lastLuoguThemeImage = '';let userCardGlassTimer = null;let modalGlassTimer = null;/* ============================================================* 工具* ============================================================ */function hexToRgb(hex) {let h = String(hex || '#232329').replace('#', '').trim();if (h.length === 3) h = h.split('').map(c => c + c).join('');if (h.length !== 6 || /[^0-9a-fA-F]/.test(h)) h = '232329';return {r: parseInt(h.slice(0, 2), 16) || 0,g: parseInt(h.slice(2, 4), 16) || 0,b: parseInt(h.slice(4, 6), 16) || 0,};}function buildBgValue(hex, alpha) {const { r, g, b } = hexToRgb(hex);return `rgba(${r}, ${g}, ${b}, ${alpha})`;}function buildFeedHeaderBg(hex, alpha) {const { r, g, b } = hexToRgb(hex);const dr = Math.max(0, r - FEED_HEADER_DARKEN);const dg = Math.max(0, g - FEED_HEADER_DARKEN);const db = Math.max(0, b - FEED_HEADER_DARKEN);const a = Math.min(1, alpha + FEED_HEADER_ALPHA_BOOST);return `rgba(${dr}, ${dg}, ${db}, ${a})`;}function buildTicketDividerColor(hex) {const { r, g, b } = hexToRgb(hex);const lum = 0.299 * r + 0.587 * g + 0.114 * b;if (lum > 128) return 'rgba(0, 0, 0, 0.55)';return 'rgba(255, 255, 255, 0.55)';}function buildFrostedBgValue(hex, alpha) {const frostedAlpha = Math.max(0.18, Math.min(0.55, alpha * 0.55));return buildBgValue(hex, frostedAlpha);}function parseRgb(str) {if (!str) return null;const m = str.match(/rgba?\(\s*(\d+)\s*[,\s]\s*(\d+)\s*[,\s]\s*(\d+)/);if (!m) return null;return { r: +m[1], g: +m[2], b: +m[3] };}function parseUrlFromCssValue(raw) {if (!raw) return null;const s = String(raw).trim();if (!s || s === 'none' || s === 'initial' || s === 'unset' || s === 'inherit') return null;const m = s.match(/url\(\s*["']?([^"')]+)["']?\s*\)/);return m && m[1] ? m[1].trim() : null;}function readVarFrom(el, name) {if (!el) return '';try { return getComputedStyle(el).getPropertyValue(name).trim(); } catch (e) { return ''; }}function readAllThemeVarsFrom(el) {if (!el) return { image: '', back: '', gradient: '' };return {image: readVarFrom(el, '--theme-body-image'),back: readVarFrom(el, '--theme-body-back'),gradient: readVarFrom(el, '--theme-body-color'),};}function findUrlInObject(obj, depth) {depth = depth || 0;if (depth > 6 || !obj) return null;if (typeof obj === 'string') {if (/^https?:\/\/.*\.(webp|jpg|jpeg|png|gif|svg)(\?|$)/i.test(obj.trim())) {return obj.trim();}const m = obj.match(/url\(\s*["']?(https?:\/\/[^"')]+)["']?\s*\)/);if (m && m[1]) return m[1].trim();return null;}if (Array.isArray(obj)) {for (const item of obj) {const u = findUrlInObject(item, depth + 1);if (u) return u;}return null;}if (typeof obj === 'object') {for (const k of Object.keys(obj)) {if (/image|background|bg/i.test(k)) {const u = findUrlInObject(obj[k], depth + 1);if (u) return u;}}for (const k of Object.keys(obj)) {if (/image|background|bg/i.test(k)) continue;if (/avatar|icon|logo/i.test(k)) continue;const u = findUrlInObject(obj[k], depth + 1);if (u) return u;}}return null;}function extractLuoguThemeFromDoc(doc) {try {const el = doc.getElementById('luogu-theme');if (!el) return null;return JSON.parse(el.textContent);} catch (e) {return null;}}function extractLuoguThemeFromHtml(html) {if (!html || typeof html !== 'string') return null;const m = html.match(/<script[^>]*id=["']luogu-theme["'][^>]*>([\s\S]*?)<\/script>/);if (!m || !m[1]) return null;try {return JSON.parse(m[1]);} catch (e) {return null;}}function parseLBody(lBody) {if (!lBody) return null;const imageUrl = lBody.image;if (!imageUrl || !/^https?:\/\//i.test(imageUrl)) return null;const backColor = (typeof lBody.back === 'string' && lBody.back) ? lBody.back : null;const colorArr = Array.isArray(lBody.color) ? lBody.color : null;const grad = (colorArr && colorArr.length >= 2)? `linear-gradient(167deg, ${colorArr.join(', ')})`: null;return { imageUrl, backColor, colorGradient: grad };}/* ============================================================* 主题变量提取* ============================================================ */function getManualBgUrl() {const u = (GM_getValue(KEY_THEME_BG_URL, '') || '').trim();return u || null;}function getAutoBgUrl() {const u = (GM_getValue(KEY_AUTO_BG_URL, '') || '').trim();return u || null;}function readThemeVarsFromPage() {const candidates = [];if (themeHostEl && document.contains(themeHostEl)) candidates.push(themeHostEl);const selectors = ['.theme-page', '.theme-mid-full', '.theme-mid','.columba-content-wrap', '.main-container','#app', '#app-old', 'main', 'body', 'html',];for (const sel of selectors) {const el = sel === 'html' ? document.documentElement : document.querySelector(sel);if (el && !candidates.includes(el)) candidates.push(el);}for (const el of candidates) {if (!el) continue;const vars = readAllThemeVarsFrom(el);const u = parseUrlFromCssValue(vars.image);if (u) {themeHostEl = el;return {imageUrl: u,backColor: (vars.back && vars.back !== 'none') ? vars.back : null,colorGradient: (vars.gradient && vars.gradient !== 'none') ? vars.gradient : null,};}}const lsUrl = tryReadThemeFromLocalStorage();if (lsUrl) {return { imageUrl: lsUrl, backColor: null, colorGradient: null };}return { imageUrl: null, backColor: null, colorGradient: null };}function tryReadThemeFromLocalStorage() {const fixedKeys = ['luogu-theme', 'LFE_THEME', 'lfe-theme','columba-theme', 'lentille-theme','theme', 'theme-data', 'themeData','luogu-theme-store', 'theme-store',];for (const key of fixedKeys) {const url = tryExtractUrlFromStorage(key);if (url) return url;}try {const n = localStorage.length;for (let i = 0; i < n; i++) {const key = localStorage.key(i);if (!key) continue;if (!/theme|columba|lentille|background|wallpaper/i.test(key)) continue;if (fixedKeys.includes(key)) continue;const url = tryExtractUrlFromStorage(key);if (url) return url;}} catch (e) {}return null;}function tryExtractUrlFromStorage(key) {let raw;try { raw = localStorage.getItem(key); } catch (e) { return null; }if (!raw) return null;const trimmed = raw.trim();if (!trimmed) return null;if (/^https?:\/\//i.test(trimmed) &&/\.(webp|jpg|jpeg|png|gif)(\?|$)/i.test(trimmed)) {return trimmed;}const m = trimmed.match(/--theme-body-image\s*:\s*url\(\s*["']?([^"')]+)["']?\s*\)/);if (m && m[1]) return m[1].trim();const m2 = trimmed.match(/url\(\s*["']?(https?:\/\/[^"')]+)["']?\s*\)/);if (m2 && m2[1]) return m2[1].trim();try {const obj = JSON.parse(trimmed);const u = findUrlInObject(obj);if (u) return u;} catch (e) {}return null;}async function fetchThemeFromPreference() {if (preferenceFetched || preferenceFetching) return;if (!IS_MAIN_SITE) return;preferenceFetching = true;try {const resp = await fetch('/user/setting/preference', {credentials: 'same-origin',headers: { 'Accept': 'text/html' },});preferenceFetched = true;if (!resp.ok) return;const html = await resp.text();const themeData = extractLuoguThemeFromHtml(html);const parsed = themeData ? parseLBody(themeData.lBody) : null;if (parsed && parsed.imageUrl !== GM_getValue(KEY_AUTO_BG_URL, '')) {GM_setValue(KEY_AUTO_BG_URL, parsed.imageUrl);if (parsed.backColor) GM_setValue(KEY_AUTO_BG_BACK, parsed.backColor);if (parsed.colorGradient) GM_setValue(KEY_AUTO_BG_GRAD, parsed.colorGradient);applyCustomBg();}} catch (e) {} finally {preferenceFetching = false;}}async function fetchThemeFromApi(force) {if (serverThemeFetching) return null;if (serverThemeFetched && !force) return null;if (serverThemeAttempted && !force) return null;if (!IS_MAIN_SITE) return null;serverThemeFetching = true;serverThemeAttempted = true;try {let themeData = extractLuoguThemeFromDoc(document);let source = 'current-doc';if (!themeData) {const resp = await fetch('/theme', {credentials: 'same-origin',headers: { 'Accept': 'text/html' },});if (!resp.ok) return null;const html = await resp.text();themeData = extractLuoguThemeFromHtml(html);source = 'fetched-html';}if (!themeData) return null;const parsed = parseLBody(themeData.lBody);if (!parsed) return null;if (parsed.backColor) GM_setValue(KEY_AUTO_BG_BACK, parsed.backColor);if (parsed.colorGradient) GM_setValue(KEY_AUTO_BG_GRAD, parsed.colorGradient);serverThemeFetched = true;if (PAGE_WIN.__LUOGU_BG_VERBOSE) {console.log('[铍洛谷] 从', source, '提取到主题背景:', parsed.imageUrl);}return parsed.imageUrl;} catch (e) {return null;} finally {serverThemeFetching = false;}}function getThemeBackgroundInfo() {const manual = getManualBgUrl();if (manual) {return { imageUrl: manual, backColor: null, colorGradient: null, source: 'manual' };}const themeData = extractLuoguThemeFromDoc(document);const parsed = themeData ? parseLBody(themeData.lBody) : null;if (parsed) {const old = GM_getValue(KEY_AUTO_BG_URL, '');if (old !== parsed.imageUrl) {GM_setValue(KEY_AUTO_BG_URL, parsed.imageUrl);}if (parsed.backColor) GM_setValue(KEY_AUTO_BG_BACK, parsed.backColor);if (parsed.colorGradient) GM_setValue(KEY_AUTO_BG_GRAD, parsed.colorGradient);return {imageUrl: parsed.imageUrl,backColor: parsed.backColor,colorGradient: parsed.colorGradient,source: 'luogu-theme',};}const live = readThemeVarsFromPage();if (live.imageUrl) {const old = GM_getValue(KEY_AUTO_BG_URL, '');if (old !== live.imageUrl) {GM_setValue(KEY_AUTO_BG_URL, live.imageUrl);}return { ...live, source: 'live' };}const auto = getAutoBgUrl();if (auto) {const autoBack = GM_getValue(KEY_AUTO_BG_BACK, '');const autoGrad = GM_getValue(KEY_AUTO_BG_GRAD, '');return {imageUrl: auto,backColor: autoBack || null,colorGradient: autoGrad || null,source: 'auto-cache',};}return { imageUrl: null, backColor: null, colorGradient: null, source: 'none' };}/* ============================================================* 路径判断* ============================================================ */function isSettingPage() {return IS_MAIN_SITE && location.href.includes('/user/setting/preference');}function isImagePage() {return IS_MAIN_SITE && /^\/image(\/|$)/.test(location.pathname);}function isPastePage() {return IS_MAIN_SITE && /^\/paste(\/|$)/.test(location.pathname);}function isTicketPage() {return IS_MAIN_SITE && /^\/ticket(\/|$)/.test(location.pathname);}function isArticleDetailPage() {if (!IS_MAIN_SITE) return false;const p = location.pathname;return /^\/article\/[^\/]+\/?$/.test(p) && !/^\/article\/(mine|_new)\/?$/.test(p);}function isHomePage() {if (!IS_MAIN_SITE) return false;const p = location.pathname;return p === '/' || p === '' || p === '/index';}function isGlassApplyPage() {return IS_MAIN_SITE && (/^\/user\/setting(\/|$)/.test(location.pathname) ||/^\/theme(\/|$)/.test(location.pathname) ||/^\/paste(\/|$)/.test(location.pathname) ||/^\/article(\/|$)/.test(location.pathname) ||/^\/training(\/|$)/.test(location.pathname) ||/^\/problem(\/|$)/.test(location.pathname) ||/^\/benben(\/|$)/.test(location.pathname) ||/^\/chat(\/|$)/.test(location.pathname) ||/^\/contest(\/|$)/.test(location.pathname));}/* ============================================================* CSS 变量同步* ============================================================ */function syncGlassVars() {const root = document.documentElement;root.style.setProperty(GLASS_VAR_BG, buildBgValue(currentColor, currentAlpha));root.style.setProperty(GLASS_VAR_BG_HD, buildFeedHeaderBg(currentColor, currentAlpha));root.style.setProperty(GLASS_VAR_BORDER, GLASS_BORDER);root.style.setProperty(GLASS_VAR_SHADOW, GLASS_SHADOW);root.style.setProperty(GLASS_VAR_TICKET_DIVIDER, buildTicketDividerColor(currentColor));root.style.setProperty(GLASS_VAR_FROSTED_BG, buildFrostedBgValue(currentColor, currentAlpha));}function clearGlassVars() {const root = document.documentElement;root.style.removeProperty(GLASS_VAR_BG);root.style.removeProperty(GLASS_VAR_BG_HD);root.style.removeProperty(GLASS_VAR_BORDER);root.style.removeProperty(GLASS_VAR_SHADOW);root.style.removeProperty(GLASS_VAR_TICKET_DIVIDER);root.style.removeProperty(GLASS_VAR_FROSTED_BG);}/* ============================================================* 内联画背景 —— 固定视口,不随任何页面滚动* ============================================================ */function paintBackgroundInline() {if (!currentEnabled) return;const body = document.body;if (!body) return;const root = document.documentElement;const info = lastThemeInfo;const imageUrl = info.imageUrl || FALLBACK_BG_IMAGE;const layers = [];if (imageUrl) layers.push(`url("${imageUrl}")`);if (info.colorGradient && info.colorGradient !== 'none') {layers.push(info.colorGradient);}const n = layers.length;const rep = Array(n).fill('cover').join(', ');const pos = Array(n).fill('center').join(', ');const rpt = Array(n).fill('no-repeat').join(', ');// 给 html 垫一个深色底,防止 iOS Safari 回弹或滚动到底部时露出白底const fallbackRootColor = (info.backColor && info.backColor !== 'transparent') ? info.backColor : currentColor;root.style.setProperty('background-color', fallbackRootColor, 'important');root.style.setProperty('background-image', 'none', 'important');root.style.removeProperty('background-attachment');body.style.setProperty('background', 'transparent', 'important');let bgLayer = document.getElementById(FIXED_BG_ID);if (!bgLayer) {bgLayer = document.createElement('div');bgLayer.id = FIXED_BG_ID;bgLayer.style.cssText = ['position: fixed','top: 0','left: 0','right: 0','bottom: 0','width: 100vw','height: 100vh','height: 100dvh','z-index: -1','pointer-events: none','-webkit-transform: translate3d(0, 0, 0)','transform: translate3d(0, 0, 0)','will-change: transform','-webkit-backface-visibility: hidden','backface-visibility: hidden','-webkit-perspective: 1000px','perspective: 1000px',].join('; ') + ';';document.documentElement.insertBefore(bgLayer, document.documentElement.firstChild);}bgLayer.style.backgroundColor = (info.backColor && info.backColor !== 'transparent')? info.backColor: 'transparent';bgLayer.style.backgroundImage = n > 0 ? layers.join(', ') : 'none';bgLayer.style.backgroundSize = rep;bgLayer.style.backgroundPosition = pos;bgLayer.style.backgroundRepeat = rpt;const shells = document.querySelectorAll(SHELL_SELECTOR);shells.forEach(el => {if (el === bgLayer) return;if (el.matches && el.matches(NAV_SELECTOR)) return;el.style.setProperty('background', 'transparent', 'important');el.style.setProperty('background-color', 'transparent', 'important');el.style.setProperty('background-image', 'none', 'important');el.setAttribute(SHELL_CLEARED_ATTR, '1');});}/* ============================================================* 题目列表专属元素* ============================================================ *//* ============================================================* 输入框玻璃化* ============================================================ */function buildInputGlassRules() {const inputSel = ['input[type="text"]', 'input[type="search"]', 'input[type="email"]','input[type="password"]', 'input[type="url"]', 'input[type="number"]','input[type="tel"]', 'input:not([type])', 'textarea','.am-form-field', '.l-input', '.lfe-input',].join(', ');return `main :is(${inputSel}):not(.${INPUT_SKIP_CLASS}):not(#${FORCE_ID}):not([type="hidden"]):not([type="color"]):not([type="range"]):not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="submit"]):not([type="button"]):not([type="reset"]) {background-color: rgba(255, 255, 255, 0.45) !important;background-image: none !important;border: 1px solid rgba(255, 255, 255, 0.65) !important;border-radius: 8px !important;box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.06) !important;backdrop-filter: none !important;-webkit-backdrop-filter: none !important;transition: background-color 0.2s ease,border-color 0.2s ease,box-shadow 0.2s ease;}main :is(${inputSel}):not(.${INPUT_SKIP_CLASS}):not(#${FORCE_ID}):not([type="hidden"]):not([type="color"]):not([type="range"]):not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="submit"]):not([type="button"]):not([type="reset"]):hover {background-color: rgba(255, 255, 255, 0.55) !important;border-color: rgba(255, 255, 255, 0.8) !important;}main :is(${inputSel}):not(.${INPUT_SKIP_CLASS}):not(#${FORCE_ID}):not([type="hidden"]):not([type="color"]):not([type="range"]):not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="submit"]):not([type="button"]):not([type="reset"]):focus {background-color: rgba(255, 255, 255, 0.75) !important;border-color: rgba(52, 152, 219, 0.8) !important;box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.18),inset 0 1px 2px rgba(0, 0, 0, 0.06) !important;outline: none !important;}main .am-input-group:not(#${FORCE_ID}),main .am-input-group:not(#${FORCE_ID}) .am-input-group-label,main .am-input-group:not(#${FORCE_ID}) .am-input-group-btn,main .image-input:not(#${FORCE_ID}) {background-color: transparent !important;background-image: none !important;}`;}function buildProblemListGlassRules() {return `.tag-button:not(#${FORCE_ID}) {background-color: var(${GLASS_VAR_BG}) !important;background-image: none !important;border: var(${GLASS_VAR_BORDER}) !important;box-shadow: var(${GLASS_VAR_SHADOW}) !important;backdrop-filter: none !important;-webkit-backdrop-filter: none !important;transition: background-color 0.2s ease,border-color 0.2s ease,box-shadow 0.2s ease;}.tag-button:not(#${FORCE_ID}):hover {background-color: rgba(255, 255, 255, 0.6) !important;border-color: rgba(255, 255, 255, 0.85) !important;}.refined-input.search-text:not(#${FORCE_ID}) {background-color: var(${GLASS_VAR_BG}) !important;background-image: none !important;border: var(${GLASS_VAR_BORDER}) !important;box-shadow: var(${GLASS_VAR_SHADOW}) !important;backdrop-filter: none !important;-webkit-backdrop-filter: none !important;border-radius: 0 !important;}.refined-input.search-text:not(#${FORCE_ID}) input,.refined-input.search-text:not(#${FORCE_ID}) input:not(#${FORCE_ID}),.refined-input.search-text:not(#${FORCE_ID}) input[type="text"],.refined-input.search-text:not(#${FORCE_ID}) input.search-text,.refined-input.search-text:not(#${FORCE_ID}) input:hover,.refined-input.search-text:not(#${FORCE_ID}) input:focus {background: transparent !important;background-color: transparent !important;background-image: none !important;border: none !important;border-radius: 0 !important;box-shadow: none !important;outline: none !important;}.refined-input.search-text:not(#${FORCE_ID}) > *,.refined-input.search-text:not(#${FORCE_ID}) .east,.refined-input.search-text:not(#${FORCE_ID}) .east *,.refined-input.search-text:not(#${FORCE_ID}) .search-icon {background: transparent !important;background-color: transparent !important;background-image: none !important;box-shadow: none !important;}.refined-input.search-text:not(#${FORCE_ID}) .search-icon {color: #2c3e50 !important;}section .search-option .lfe-caption,section .search-option .lfe-caption label,section .search-option .lfe-caption span,section .search-option .lfe-caption label svg {color: #2c3e50 !important;}section .search-option .lfe-caption input[type="checkbox"] {color: inherit;}.refined-input.text:not(#${FORCE_ID}):not(.search-text) *,.refined-input.text:not(#${FORCE_ID}):not(.search-text)::before,.refined-input.text:not(#${FORCE_ID}):not(.search-text)::after,.refined-input.text:not(#${FORCE_ID}):not(.search-text) > *::before,.refined-input.text:not(#${FORCE_ID}):not(.search-text) > *::after {background-color: transparent !important;background-image: none !important;border-color: transparent !important;box-shadow: none !important;backdrop-filter: none !important;-webkit-backdrop-filter: none !important;}.refined-input.text:not(#${FORCE_ID}):not(.search-text) input,.refined-input.text:not(#${FORCE_ID}):not(.search-text) input:hover,.refined-input.text:not(#${FORCE_ID}):not(.search-text) input:focus {background-color: transparent !important;background-image: none !important;border: none !important;border-radius: 0 !important;box-shadow: none !important;outline: none !important;}.refined-input.text:not(#${FORCE_ID}):not(.search-text) .search-icon {color: #2c3e50 !important;}.solution-filter.lfe-caption,.solution-filter.lfe-caption label,.solution-filter.lfe-caption span,.solution-filter.lfe-caption label svg {color: #2c3e50 !important;}.solution-filter.lfe-caption input[type="checkbox"] {color: inherit;}.list-scroll:not(#${FORCE_ID}),.list-scroll.overflow:not(#${FORCE_ID}) {scrollbar-width: thin;scrollbar-color: rgba(255, 255, 255, 0.65) rgba(255, 255, 255, 0.2);}.list-scroll:not(#${FORCE_ID})::-webkit-scrollbar {width: 10px; height: 10px; background: transparent;}.list-scroll:not(#${FORCE_ID})::-webkit-scrollbar:horizontal { height: 10px; }.list-scroll:not(#${FORCE_ID})::-webkit-scrollbar:vertical { width: 10px; }.list-scroll:not(#${FORCE_ID})::-webkit-scrollbar-track {background: rgba(255, 255, 255, 0.18) !important;border-radius: 5px;border: 1px solid rgba(255, 255, 255, 0.3);}.list-scroll:not(#${FORCE_ID})::-webkit-scrollbar-thumb {background: rgba(255, 255, 255, 0.55) !important;background-image: linear-gradient(180deg, rgba(255,255,255,0.75), rgba(255,255,255,0.4)) !important;border: 1px solid rgba(255, 255, 255, 0.7) !important;border-radius: 5px;box-shadow: inset 0 1px 0 rgba(255,255,255,0.8), 0 1px 3px rgba(31,38,135,0.08);}.list-scroll:not(#${FORCE_ID})::-webkit-scrollbar-thumb:hover {background: rgba(255, 255, 255, 0.75) !important;}.list-scroll:not(#${FORCE_ID})::-webkit-scrollbar-corner { background: transparent; }.list-scroll:not(#${FORCE_ID}) .list-wrap:not(#${FORCE_ID}),.list-scroll:not(#${FORCE_ID}) .header-wrap:not(#${FORCE_ID}),.list-scroll:not(#${FORCE_ID}) .row-wrap:not(#${FORCE_ID}),.list-scroll:not(#${FORCE_ID}) .row:not(#${FORCE_ID}) {background-color: transparent !important;background-image: none !important;}`;}/* ============================================================* 用户名悬停卡片* ============================================================ */function buildUserCardGlassRules() {return `body .l-card.float-card:not(#${FORCE_ID}),body .dropdown.shown .l-card:not(#${FORCE_ID}),body .dropdown.shown > .l-card.float-card:not(#${FORCE_ID}),body .dropdown .l-card.float-card:not(#${FORCE_ID}) {background-color: var(${GLASS_VAR_BG}) !important;background-image: none !important;border: 1px solid rgba(255, 255, 255, 0.55) !important;box-shadow: 0 8px 32px rgba(31, 38, 135, 0.2),0 2px 8px rgba(0, 0, 0, 0.08),inset 0 1px 0 rgba(255, 255, 255, 0.6) !important;backdrop-filter: ${USER_CARD_BLUR} !important;-webkit-backdrop-filter: ${USER_CARD_BLUR} !important;border-radius: 12px !important;}body .l-card.float-card:not(#${FORCE_ID}) .user-info,body .l-card.float-card:not(#${FORCE_ID}) .user-action {background-color: transparent !important;background-image: none !important;}`;}/* ============================================================* 弹窗 / 模态框毛玻璃* ============================================================ */function buildModalGlassRules() {return `${MODAL_CARD_SELECTOR.split(',').map(s => s.trim() + ':not(#' + FORCE_ID + ')').join(',\n ')} {background-color: var(${GLASS_VAR_FROSTED_BG}) !important;background-image: none !important;backdrop-filter: ${USER_CARD_BLUR} !important;::::info[脚本]```javascript// ==UserScript==// @name 铍洛谷(Userscripts 适配版)// @namespace https://www.luogu.com.cn/// @version 5.5.2// @description 洛谷背景板// @match https://www.luogu.com.cn/*// @match https://www.luogu.org/*// @match https://class.luogu.com.cn/*// @match https://ti.luogu.com.cn/*// @grant GM_getValue// @grant GM_setValue// @grant GM_addValueChangeListener// @grant unsafeWindow// @run-at document-idle// ==/UserScript==(function () {'use strict';try {if (window.top !== window.self) return;} catch (e) {return;}const __GM_PREFIX = 'luogu_bg_';const __nativeGMGetValue = (typeof globalThis.GM_getValue === 'function')? globalThis.GM_getValue.bind(globalThis): null;const __nativeGMSetValue = (typeof globalThis.GM_setValue === 'function')? globalThis.GM_setValue.bind(globalThis): null;const __nativeGMAddListener = (typeof globalThis.GM_addValueChangeListener === 'function')? globalThis.GM_addValueChangeListener.bind(globalThis): null;function __lsGet(key, def) {try {const raw = localStorage.getItem(__GM_PREFIX + key);return raw === null ? def : JSON.parse(raw);} catch (e) {return def;}}function __lsSet(key, val) {try {localStorage.setItem(__GM_PREFIX + key, JSON.stringify(val));} catch (e) {}}const GM_getValue = function (key, def) {if (__nativeGMGetValue) {try {const v = __nativeGMGetValue(key, def);if (v && typeof v.then === 'function') {return __lsGet(key, def);}if (v !== undefined) return v;} catch (e) {}}return __lsGet(key, def);};const GM_setValue = function (key, val) {if (__nativeGMSetValue) {try {__nativeGMSetValue(key, val);return;} catch (e) {}}__lsSet(key, val);};const GM_addValueChangeListener = function (key, cb) {if (__nativeGMAddListener) {try {return __nativeGMAddListener(key, cb);} catch (e) {}}return 'noop-' + key;};const PAGE_WIN = (typeof unsafeWindow !== 'undefined' && unsafeWindow)? unsafeWindow: window;/* ============================================================* 常量* ============================================================ */const KEY_ENABLED = 'bg_custom_enabled';const KEY_COLOR = 'bg_custom_color';const KEY_ALPHA = 'bg_custom_alpha';const KEY_THEME_BG_URL = 'bg_theme_bg_url';const KEY_AUTO_BG_URL = 'bg_auto_bg_url';const KEY_AUTO_BG_BACK = 'bg_auto_back_color';const KEY_AUTO_BG_GRAD = 'bg_auto_gradient';const PANEL_ID = 'luogu-bg-panel';const STYLE_ID = 'luogu-bg-panel-style';const HITOKOTO_PANEL_ID = 'luogu-hitokoto-panel';const GLASS_STYLE_ID = 'luogu-glass-style';const GLASS_VAR_BG = '--luogu-glass-bg';const GLASS_VAR_BG_HD = '--luogu-glass-bg-hd';const GLASS_VAR_BORDER = '--luogu-glass-border';const GLASS_VAR_SHADOW = '--luogu-glass-shadow';const GLASS_VAR_TICKET_DIVIDER = '--luogu-glass-ticket-divider';const GLASS_VAR_FROSTED_BG = '--luogu-glass-frosted-bg';const PAINT_MARK = 'data-bg-painted';const ORIG_BG_ATTR = 'data-bg-orig-bg';const TICKET_TOPBAR_ATTR = 'data-ticket-topbar';const NAV_SOLID_ATTR = 'data-nav-solid';const SHELL_CLEARED_ATTR = 'data-shell-cleared';const INNER_TRANSPARENT_ATTR = 'data-luogu-inner-transparent';const FORCE_ID = 'luogu-glass-force';const FIXED_BG_ID = 'luogu-fixed-bg';const FALLBACK_BG_IMAGE = 'https://cdn.luogu.com.cn/upload/image_hosting/e5xgx75m.webp';const INPUT_SKIP_CLASS = 'luogu-bg-skip';const GLASS_BORDER = '1px solid rgba(255, 255, 255, 0.55)';const GLASS_SHADOW = `0 8px 32px rgba(31, 38, 135, 0.12),0 2px 8px rgba(0, 0, 0, 0.05),inset 0 1px 0 rgba(255, 255, 255, 0.6)`;const USER_CARD_BLUR = 'blur(24px) saturate(180%)';const FEED_HEADER_DARKEN = 25;const FEED_HEADER_ALPHA_BOOST = 0.15;const HOST = location.hostname;const IS_MAIN_SITE = HOST === 'www.luogu.com.cn' || HOST === 'www.luogu.org';const IS_CLASS_SITE = HOST === 'class.luogu.com.cn';const IS_TI_SITE = HOST === 'ti.luogu.com.cn';const GRAY_MARK = 'data-darkened-gray';const DARK_GRAY = 'rgb(60, 60, 70)';const SKIP_TAGS = new Set(['INPUT', 'TEXTAREA', 'BUTTON', 'SELECT','IMG', 'SVG', 'PATH', 'IFRAME', 'VIDEO', 'CANVAS','SCRIPT', 'STYLE', 'LINK', 'META', 'HR', 'BR',]);const INLINE_TAGS = new Set(['SPAN', 'A', 'B', 'I', 'EM', 'STRONG', 'SMALL','CODE', 'KBD', 'TIME', 'LABEL', 'CITE', 'Q', 'S', 'U','SUB', 'SUP', 'MARK',]);const FLOATING_EXCLUDE = ['.v-popper__popper', '.v-popper__inner','[class*="popper"]', '[class*="popup"]', '[class*="popover"]','[class*="tooltip"]', '[class*="dropdown"]','.dropdown','[role="tooltip"]', '[role="menu"]','[aria-hidden="true"]',].join(', ');const CONTENT_EXCLUDE = ['.markdown-body','.lfe-markdown','.lg-article-content','.article-content','.feed-comment','.am-comment-bd','[class*="markdown-body"]','[class*="markdown-content"]',].join(', ');const NAV_SELECTOR = ['.top-bar','nav.sidebar','nav.sidebar.lside','.sidebar.lside.bar','.user-nav.rside','#app-sidenav','#app-header',].join(', ');const SHELL_SELECTOR = ['.theme-page','.theme-mid-full','.theme-mid','.main-container','.columba-content-wrap','.main-content','#app','#app-old','.lg-index-content','.lfe-body','main',].join(', ');const CSS_OWNED_SELECTOR = ['.tag-button','.refined-input.search-text','.list-scroll',].join(', ');const CSS_OWNED_SUBTREE = ['.refined-input.search-text','.list-scroll',].join(', ');const CARD_SELECTOR_RAW = ['.l-card', '.lg-article', '.lg-index-stat', '.lg-index-contest','.am-panel', '.n-card', '.training-card', '.category-card','.srqc', '.course-card', '.lesson-card', '.chapter-card','.class-card', '.problemsets', '.problemset-item','.lg-punch',].join(', ');const TEXT_DARKEN_SELECTOR = ['a', 'span', 'strong', 'em', 'small', 'p', 'i', 'b','div', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6','li', 'td', 'th', 'dt', 'dd', 'label', 'time','blockquote', 'figcaption', 'cite', 'q', 'mark','section', 'article', 'header', 'footer', 'aside',].join(', ');const MODAL_CARD_SELECTOR = ['.l-card.container.type-burger','.l-card.container.type-dialog','.l-card.container.type-popup','.l-card.container[class*="type-"]','.l-card[class*="container"][class*="type-"]','.l-modal .l-card','.l-modal__body .l-card','.v-modal .l-card','[class*="modal"] > .l-card','[class*="dialog"] > .l-card','[class*="popup"] > .l-card',].join(', ');/* ============================================================* 状态* ============================================================ */function readAlpha() {let v = parseFloat(GM_getValue(KEY_ALPHA, 0.78));if (isNaN(v) || v <= 0.01) v = 0.78;return Math.min(1, Math.max(0.05, v));}let currentEnabled = !!GM_getValue(KEY_ENABLED, false);let currentColor = GM_getValue(KEY_COLOR, '#232329') || '#232329';let currentAlpha = readAlpha();let lastThemeInfo = { imageUrl: null, backColor: null, colorGradient: null, source: 'none' };let themeHostEl = null;let paintVersion = 0;let paintedElements = new WeakMap();let darkenedElements = new WeakSet();let preferenceFetched = false;let preferenceFetching = false;let serverThemeFetched = false;let serverThemeFetching = false;let serverThemeAttempted = false;let luoguThemePollTimer = null;let lastLuoguThemeImage = '';let userCardGlassTimer = null;let modalGlassTimer = null;/* ============================================================* 工具* ============================================================ */function hexToRgb(hex) {let h = String(hex || '#232329').replace('#', '').trim();if (h.length === 3) h = h.split('').map(c => c + c).join('');if (h.length !== 6 || /[^0-9a-fA-F]/.test(h)) h = '232329';return {r: parseInt(h.slice(0, 2), 16) || 0,g: parseInt(h.slice(2, 4), 16) || 0,b: parseInt(h.slice(4, 6), 16) || 0,};}function buildBgValue(hex, alpha) {const { r, g, b } = hexToRgb(hex);return `rgba(${r}, ${g}, ${b}, ${alpha})`;}function buildFeedHeaderBg(hex, alpha) {const { r, g, b } = hexToRgb(hex);const dr = Math.max(0, r - FEED_HEADER_DARKEN);const dg = Math.max(0, g - FEED_HEADER_DARKEN);const db = Math.max(0, b - FEED_HEADER_DARKEN);const a = Math.min(1, alpha + FEED_HEADER_ALPHA_BOOST);return `rgba(${dr}, ${dg}, ${db}, ${a})`;}function buildTicketDividerColor(hex) {const { r, g, b } = hexToRgb(hex);const lum = 0.299 * r + 0.587 * g + 0.114 * b;if (lum > 128) return 'rgba(0, 0, 0, 0.55)';return 'rgba(255, 255, 255, 0.55)';}function buildFrostedBgValue(hex, alpha) {const frostedAlpha = Math.max(0.18, Math.min(0.55, alpha * 0.55));return buildBgValue(hex, frostedAlpha);}function parseRgb(str) {if (!str) return null;const m = str.match(/rgba?\(\s*(\d+)\s*[,\s]\s*(\d+)\s*[,\s]\s*(\d+)/);if (!m) return null;return { r: +m[1], g: +m[2], b: +m[3] };}function parseUrlFromCssValue(raw) {if (!raw) return null;const s = String(raw).trim();if (!s || s === 'none' || s === 'initial' || s === 'unset' || s === 'inherit') return null;const m = s.match(/url\(\s*["']?([^"')]+)["']?\s*\)/);return m && m[1] ? m[1].trim() : null;}function readVarFrom(el, name) {if (!el) return '';try { return getComputedStyle(el).getPropertyValue(name).trim(); } catch (e) { return ''; }}function readAllThemeVarsFrom(el) {if (!el) return { image: '', back: '', gradient: '' };return {image: readVarFrom(el, '--theme-body-image'),back: readVarFrom(el, '--theme-body-back'),gradient: readVarFrom(el, '--theme-body-color'),};}function findUrlInObject(obj, depth) {depth = depth || 0;if (depth > 6 || !obj) return null;if (typeof obj === 'string') {if (/^https?:\/\/.*\.(webp|jpg|jpeg|png|gif|svg)(\?|$)/i.test(obj.trim())) {return obj.trim();}const m = obj.match(/url\(\s*["']?(https?:\/\/[^"')]+)["']?\s*\)/);if (m && m[1]) return m[1].trim();return null;}if (Array.isArray(obj)) {for (const item of obj) {const u = findUrlInObject(item, depth + 1);if (u) return u;}return null;}if (typeof obj === 'object') {for (const k of Object.keys(obj)) {if (/image|background|bg/i.test(k)) {const u = findUrlInObject(obj[k], depth + 1);if (u) return u;}}for (const k of Object.keys(obj)) {if (/image|background|bg/i.test(k)) continue;if (/avatar|icon|logo/i.test(k)) continue;const u = findUrlInObject(obj[k], depth + 1);if (u) return u;}}return null;}function extractLuoguThemeFromDoc(doc) {try {const el = doc.getElementById('luogu-theme');if (!el) return null;return JSON.parse(el.textContent);} catch (e) {return null;}}function extractLuoguThemeFromHtml(html) {if (!html || typeof html !== 'string') return null;const m = html.match(/<script[^>]*id=["']luogu-theme["'][^>]*>([\s\S]*?)<\/script>/);if (!m || !m[1]) return null;try {return JSON.parse(m[1]);} catch (e) {return null;}}function parseLBody(lBody) {if (!lBody) return null;const imageUrl = lBody.image;if (!imageUrl || !/^https?:\/\//i.test(imageUrl)) return null;const backColor = (typeof lBody.back === 'string' && lBody.back) ? lBody.back : null;const colorArr = Array.isArray(lBody.color) ? lBody.color : null;const grad = (colorArr && colorArr.length >= 2)? `linear-gradient(167deg, ${colorArr.join(', ')})`: null;return { imageUrl, backColor, colorGradient: grad };}/* ============================================================* 主题变量提取* ============================================================ */function getManualBgUrl() {const u = (GM_getValue(KEY_THEME_BG_URL, '') || '').trim();return u || null;}function getAutoBgUrl() {const u = (GM_getValue(KEY_AUTO_BG_URL, '') || '').trim();return u || null;}function readThemeVarsFromPage() {const candidates = [];if (themeHostEl && document.contains(themeHostEl)) candidates.push(themeHostEl);const selectors = ['.theme-page', '.theme-mid-full', '.theme-mid','.columba-content-wrap', '.main-container','#app', '#app-old', 'main', 'body', 'html',];for (const sel of selectors) {const el = sel === 'html' ? document.documentElement : document.querySelector(sel);if (el && !candidates.includes(el)) candidates.push(el);}for (const el of candidates) {if (!el) continue;const vars = readAllThemeVarsFrom(el);const u = parseUrlFromCssValue(vars.image);if (u) {themeHostEl = el;return {imageUrl: u,backColor: (vars.back && vars.back !== 'none') ? vars.back : null,colorGradient: (vars.gradient && vars.gradient !== 'none') ? vars.gradient : null,};}}const lsUrl = tryReadThemeFromLocalStorage();if (lsUrl) {return { imageUrl: lsUrl, backColor: null, colorGradient: null };}return { imageUrl: null, backColor: null, colorGradient: null };}function tryReadThemeFromLocalStorage() {const fixedKeys = ['luogu-theme', 'LFE_THEME', 'lfe-theme','columba-theme', 'lentille-theme','theme', 'theme-data', 'themeData','luogu-theme-store', 'theme-store',];for (const key of fixedKeys) {const url = tryExtractUrlFromStorage(key);if (url) return url;}try {const n = localStorage.length;for (let i = 0; i < n; i++) {const key = localStorage.key(i);if (!key) continue;if (!/theme|columba|lentille|background|wallpaper/i.test(key)) continue;if (fixedKeys.includes(key)) continue;const url = tryExtractUrlFromStorage(key);if (url) return url;}} catch (e) {}return null;}function tryExtractUrlFromStorage(key) {let raw;try { raw = localStorage.getItem(key); } catch (e) { return null; }if (!raw) return null;const trimmed = raw.trim();if (!trimmed) return null;if (/^https?:\/\//i.test(trimmed) &&/\.(webp|jpg|jpeg|png|gif)(\?|$)/i.test(trimmed)) {return trimmed;}const m = trimmed.match(/--theme-body-image\s*:\s*url\(\s*["']?([^"')]+)["']?\s*\)/);if (m && m[1]) return m[1].trim();const m2 = trimmed.match(/url\(\s*["']?(https?:\/\/[^"')]+)["']?\s*\)/);if (m2 && m2[1]) return m2[1].trim();try {const obj = JSON.parse(trimmed);const u = findUrlInObject(obj);if (u) return u;} catch (e) {}return null;}async function fetchThemeFromPreference() {if (preferenceFetched || preferenceFetching) return;if (!IS_MAIN_SITE) return;preferenceFetching = true;try {const resp = await fetch('/user/setting/preference', {credentials: 'same-origin',headers: { 'Accept': 'text/html' },});preferenceFetched = true;if (!resp.ok) return;const html = await resp.text();const themeData = extractLuoguThemeFromHtml(html);const parsed = themeData ? parseLBody(themeData.lBody) : null;if (parsed && parsed.imageUrl !== GM_getValue(KEY_AUTO_BG_URL, '')) {GM_setValue(KEY_AUTO_BG_URL, parsed.imageUrl);if (parsed.backColor) GM_setValue(KEY_AUTO_BG_BACK, parsed.backColor);if (parsed.colorGradient) GM_setValue(KEY_AUTO_BG_GRAD, parsed.colorGradient);applyCustomBg();}} catch (e) {} finally {preferenceFetching = false;}}async function fetchThemeFromApi(force) {if (serverThemeFetching) return null;if (serverThemeFetched && !force) return null;if (serverThemeAttempted && !force) return null;if (!IS_MAIN_SITE) return null;serverThemeFetching = true;serverThemeAttempted = true;try {let themeData = extractLuoguThemeFromDoc(document);let source = 'current-doc';if (!themeData) {const resp = await fetch('/theme', {credentials: 'same-origin',headers: { 'Accept': 'text/html' },});if (!resp.ok) return null;const html = await resp.text();themeData = extractLuoguThemeFromHtml(html);source = 'fetched-html';}if (!themeData) return null;const parsed = parseLBody(themeData.lBody);if (!parsed) return null;if (parsed.backColor) GM_setValue(KEY_AUTO_BG_BACK, parsed.backColor);if (parsed.colorGradient) GM_setValue(KEY_AUTO_BG_GRAD, parsed.colorGradient);serverThemeFetched = true;if (PAGE_WIN.__LUOGU_BG_VERBOSE) {console.log('[铍洛谷] 从', source, '提取到主题背景:', parsed.imageUrl);}return parsed.imageUrl;} catch (e) {return null;} finally {serverThemeFetching = false;}}function getThemeBackgroundInfo() {const manual = getManualBgUrl();if (manual) {return { imageUrl: manual, backColor: null, colorGradient: null, source: 'manual' };}const themeData = extractLuoguThemeFromDoc(document);const parsed = themeData ? parseLBody(themeData.lBody) : null;if (parsed) {const old = GM_getValue(KEY_AUTO_BG_URL, '');if (old !== parsed.imageUrl) {GM_setValue(KEY_AUTO_BG_URL, parsed.imageUrl);}if (parsed.backColor) GM_setValue(KEY_AUTO_BG_BACK, parsed.backColor);if (parsed.colorGradient) GM_setValue(KEY_AUTO_BG_GRAD, parsed.colorGradient);return {imageUrl: parsed.imageUrl,backColor: parsed.backColor,colorGradient: parsed.colorGradient,source: 'luogu-theme',};}const live = readThemeVarsFromPage();if (live.imageUrl) {const old = GM_getValue(KEY_AUTO_BG_URL, '');if (old !== live.imageUrl) {GM_setValue(KEY_AUTO_BG_URL, live.imageUrl);}return { ...live, source: 'live' };}const auto = getAutoBgUrl();if (auto) {const autoBack = GM_getValue(KEY_AUTO_BG_BACK, '');const autoGrad = GM_getValue(KEY_AUTO_BG_GRAD, '');return {imageUrl: auto,backColor: autoBack || null,colorGradient: autoGrad || null,source: 'auto-cache',};}return { imageUrl: null, backColor: null, colorGradient: null, source: 'none' };}/* ============================================================* 路径判断* ============================================================ */function isSettingPage() {return IS_MAIN_SITE && location.href.includes('/user/setting/preference');}function isImagePage() {return IS_MAIN_SITE && /^\/image(\/|$)/.test(location.pathname);}function isPastePage() {return IS_MAIN_SITE && /^\/paste(\/|$)/.test(location.pathname);}function isTicketPage() {return IS_MAIN_SITE && /^\/ticket(\/|$)/.test(location.pathname);}function isArticleDetailPage() {if (!IS_MAIN_SITE) return false;const p = location.pathname;return /^\/article\/[^\/]+\/?$/.test(p) && !/^\/article\/(mine|_new)\/?$/.test(p);}function isHomePage() {if (!IS_MAIN_SITE) return false;const p = location.pathname;return p === '/' || p === '' || p === '/index';}function isGlassApplyPage() {return IS_MAIN_SITE && (/^\/user\/setting(\/|$)/.test(location.pathname) ||/^\/theme(\/|$)/.test(location.pathname) ||/^\/paste(\/|$)/.test(location.pathname) ||/^\/article(\/|$)/.test(location.pathname) ||/^\/training(\/|$)/.test(location.pathname) ||/^\/problem(\/|$)/.test(location.pathname) ||/^\/benben(\/|$)/.test(location.pathname) ||/^\/chat(\/|$)/.test(location.pathname) ||/^\/contest(\/|$)/.test(location.pathname));}/* ============================================================* CSS 变量同步* ============================================================ */function syncGlassVars() {const root = document.documentElement;root.style.setProperty(GLASS_VAR_BG, buildBgValue(currentColor, currentAlpha));root.style.setProperty(GLASS_VAR_BG_HD, buildFeedHeaderBg(currentColor, currentAlpha));root.style.setProperty(GLASS_VAR_BORDER, GLASS_BORDER);root.style.setProperty(GLASS_VAR_SHADOW, GLASS_SHADOW);root.style.setProperty(GLASS_VAR_TICKET_DIVIDER, buildTicketDividerColor(currentColor));root.style.setProperty(GLASS_VAR_FROSTED_BG, buildFrostedBgValue(currentColor, currentAlpha));}function clearGlassVars() {const root = document.documentElement;root.style.removeProperty(GLASS_VAR_BG);root.style.removeProperty(GLASS_VAR_BG_HD);root.style.removeProperty(GLASS_VAR_BORDER);root.style.removeProperty(GLASS_VAR_SHADOW);root.style.removeProperty(GLASS_VAR_TICKET_DIVIDER);root.style.removeProperty(GLASS_VAR_FROSTED_BG);}/* ============================================================* 内联画背景 —— 固定视口,不随任何页面滚动* ============================================================ */function paintBackgroundInline() {if (!currentEnabled) return;const body = document.body;if (!body) return;const root = document.documentElement;const info = lastThemeInfo;const imageUrl = info.imageUrl || FALLBACK_BG_IMAGE;const layers = [];if (imageUrl) layers.push(`url("${imageUrl}")`);if (info.colorGradient && info.colorGradient !== 'none') {layers.push(info.colorGradient);}const n = layers.length;const rep = Array(n).fill('cover').join(', ');const pos = Array(n).fill('center').join(', ');const rpt = Array(n).fill('no-repeat').join(', ');// 给 html 垫一个深色底,防止 iOS Safari 回弹或滚动到底部时露出白底const fallbackRootColor = (info.backColor && info.backColor !== 'transparent') ? info.backColor : currentColor;root.style.setProperty('background-color', fallbackRootColor, 'important');root.style.setProperty('background-image', 'none', 'important');root.style.removeProperty('background-attachment');body.style.setProperty('background', 'transparent', 'important');let bgLayer = document.getElementById(FIXED_BG_ID);if (!bgLayer) {bgLayer = document.createElement('div');bgLayer.id = FIXED_BG_ID;bgLayer.style.cssText = ['position: fixed','top: 0','left: 0','right: 0','bottom: 0','width: 100vw','height: 100vh','height: 100dvh','z-index: -1','pointer-events: none','-webkit-transform: translate3d(0, 0, 0)','transform: translate3d(0, 0, 0)','will-change: transform','-webkit-backface-visibility: hidden','backface-visibility: hidden','-webkit-perspective: 1000px','perspective: 1000px',].join('; ') + ';';document.documentElement.insertBefore(bgLayer, document.documentElement.firstChild);}bgLayer.style.backgroundColor = (info.backColor && info.backColor !== 'transparent')? info.backColor: 'transparent';bgLayer.style.backgroundImage = n > 0 ? layers.join(', ') : 'none';bgLayer.style.backgroundSize = rep;bgLayer.style.backgroundPosition = pos;bgLayer.style.backgroundRepeat = rpt;const shells = document.querySelectorAll(SHELL_SELECTOR);shells.forEach(el => {if (el === bgLayer) return;if (el.matches && el.matches(NAV_SELECTOR)) return;el.style.setProperty('background', 'transparent', 'important');el.style.setProperty('background-color', 'transparent', 'important');el.style.setProperty('background-image', 'none', 'important');el.setAttribute(SHELL_CLEARED_ATTR, '1');});}/* ============================================================* 题目列表专属元素* ============================================================ *//* ============================================================* 输入框玻璃化* ============================================================ */function buildInputGlassRules() {const inputSel = ['input[type="text"]', 'input[type="search"]', 'input[type="email"]','input[type="password"]', 'input[type="url"]', 'input[type="number"]','input[type="tel"]', 'input:not([type])', 'textarea','.am-form-field', '.l-input', '.lfe-input',].join(', ');return `main :is(${inputSel}):not(.${INPUT_SKIP_CLASS}):not(#${FORCE_ID}):not([type="hidden"]):not([type="color"]):not([type="range"]):not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="submit"]):not([type="button"]):not([type="reset"]) {background-color: rgba(255, 255, 255, 0.45) !important;background-image: none !important;border: 1px solid rgba(255, 255, 255, 0.65) !important;border-radius: 8px !important;box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.06) !important;backdrop-filter: none !important;-webkit-backdrop-filter: none !important;transition: background-color 0.2s ease,border-color 0.2s ease,box-shadow 0.2s ease;}main :is(${inputSel}):not(.${INPUT_SKIP_CLASS}):not(#${FORCE_ID}):not([type="hidden"]):not([type="color"]):not([type="range"]):not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="submit"]):not([type="button"]):not([type="reset"]):hover {background-color: rgba(255, 255, 255, 0.55) !important;border-color: rgba(255, 255, 255, 0.8) !important;}main :is(${inputSel}):not(.${INPUT_SKIP_CLASS}):not(#${FORCE_ID}):not([type="hidden"]):not([type="color"]):not([type="range"]):not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="submit"]):not([type="button"]):not([type="reset"]):focus {background-color: rgba(255, 255, 255, 0.75) !important;border-color: rgba(52, 152, 219, 0.8) !important;box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.18),inset 0 1px 2px rgba(0, 0, 0, 0.06) !important;outline: none !important;}main .am-input-group:not(#${FORCE_ID}),main .am-input-group:not(#${FORCE_ID}) .am-input-group-label,main .am-input-group:not(#${FORCE_ID}) .am-input-group-btn,main .image-input:not(#${FORCE_ID}) {background-color: transparent !important;background-image: none !important;}`;}function buildProblemListGlassRules() {return `.tag-button:not(#${FORCE_ID}) {background-color: var(${GLASS_VAR_BG}) !important;background-image: none !important;border: var(${GLASS_VAR_BORDER}) !important;box-shadow: var(${GLASS_VAR_SHADOW}) !important;backdrop-filter: none !important;-webkit-backdrop-filter: none !important;transition: background-color 0.2s ease,border-color 0.2s ease,box-shadow 0.2s ease;}.tag-button:not(#${FORCE_ID}):hover {background-color: rgba(255, 255, 255, 0.6) !important;border-color: rgba(255, 255, 255, 0.85) !important;}.refined-input.search-text:not(#${FORCE_ID}) {background-color: var(${GLASS_VAR_BG}) !important;background-image: none !important;border: var(${GLASS_VAR_BORDER}) !important;box-shadow: var(${GLASS_VAR_SHADOW}) !important;backdrop-filter: none !important;-webkit-backdrop-filter: none !important;border-radius: 0 !important;}.refined-input.search-text:not(#${FORCE_ID}) input,.refined-input.search-text:not(#${FORCE_ID}) input:not(#${FORCE_ID}),.refined-input.search-text:not(#${FORCE_ID}) input[type="text"],.refined-input.search-text:not(#${FORCE_ID}) input.search-text,.refined-input.search-text:not(#${FORCE_ID}) input:hover,.refined-input.search-text:not(#${FORCE_ID}) input:focus {background: transparent !important;background-color: transparent !important;background-image: none !important;border: none !important;border-radius: 0 !important;box-shadow: none !important;outline: none !important;}.refined-input.search-text:not(#${FORCE_ID}) > *,.refined-input.search-text:not(#${FORCE_ID}) .east,.refined-input.search-text:not(#${FORCE_ID}) .east *,.refined-input.search-text:not(#${FORCE_ID}) .search-icon {background: transparent !important;background-color: transparent !important;background-image: none !important;box-shadow: none !important;}.refined-input.search-text:not(#${FORCE_ID}) .search-icon {color: #2c3e50 !important;}section .search-option .lfe-caption,section .search-option .lfe-caption label,section .search-option .lfe-caption span,section .search-option .lfe-caption label svg {color: #2c3e50 !important;}section .search-option .lfe-caption input[type="checkbox"] {color: inherit;}.refined-input.text:not(#${FORCE_ID}):not(.search-text) *,.refined-input.text:not(#${FORCE_ID}):not(.search-text)::before,.refined-input.text:not(#${FORCE_ID}):not(.search-text)::after,.refined-input.text:not(#${FORCE_ID}):not(.search-text) > *::before,.refined-input.text:not(#${FORCE_ID}):not(.search-text) > *::after {background-color: transparent !important;background-image: none !important;border-color: transparent !important;box-shadow: none !important;backdrop-filter: none !important;-webkit-backdrop-filter: none !important;}.refined-input.text:not(#${FORCE_ID}):not(.search-text) input,.refined-input.text:not(#${FORCE_ID}):not(.search-text) input:hover,.refined-input.text:not(#${FORCE_ID}):not(.search-text) input:focus {background-color: transparent !important;background-image: none !important;border: none !important;border-radius: 0 !important;box-shadow: none !important;outline: none !important;}.refined-input.text:not(#${FORCE_ID}):not(.search-text) .search-icon {color: #2c3e50 !important;}.solution-filter.lfe-caption,.solution-filter.lfe-caption label,.solution-filter.lfe-caption span,.solution-filter.lfe-caption label svg {color: #2c3e50 !important;}.solution-filter.lfe-caption input[type="checkbox"] {color: inherit;}.list-scroll:not(#${FORCE_ID}),.list-scroll.overflow:not(#${FORCE_ID}) {scrollbar-width: thin;scrollbar-color: rgba(255, 255, 255, 0.65) rgba(255, 255, 255, 0.2);}.list-scroll:not(#${FORCE_ID})::-webkit-scrollbar {width: 10px; height: 10px; background: transparent;}.list-scroll:not(#${FORCE_ID})::-webkit-scrollbar:horizontal { height: 10px; }.list-scroll:not(#${FORCE_ID})::-webkit-scrollbar:vertical { width: 10px; }.list-scroll:not(#${FORCE_ID})::-webkit-scrollbar-track {background: rgba(255, 255, 255, 0.18) !important;border-radius: 5px;border: 1px solid rgba(255, 255, 255, 0.3);}.list-scroll:not(#${FORCE_ID})::-webkit-scrollbar-thumb {background: rgba(255, 255, 255, 0.55) !important;background-image: linear-gradient(180deg, rgba(255,255,255,0.75), rgba(255,255,255,0.4)) !important;border: 1px solid rgba(255, 255, 255, 0.7) !important;border-radius: 5px;box-shadow: inset 0 1px 0 rgba(255,255,255,0.8), 0 1px 3px rgba(31,38,135,0.08);}.list-scroll:not(#${FORCE_ID})::-webkit-scrollbar-thumb:hover {background: rgba(255, 255, 255, 0.75) !important;}.list-scroll:not(#${FORCE_ID})::-webkit-scrollbar-corner { background: transparent; }.list-scroll:not(#${FORCE_ID}) .list-wrap:not(#${FORCE_ID}),.list-scroll:not(#${FORCE_ID}) .header-wrap:not(#${FORCE_ID}),.list-scroll:not(#${FORCE_ID}) .row-wrap:not(#${FORCE_ID}),.list-scroll:not(#${FORCE_ID}) .row:not(#${FORCE_ID}) {background-color: transparent !important;background-image: none !important;}`;}/* ============================================================* 用户名悬停卡片* ============================================================ */function buildUserCardGlassRules() {return `body .l-card.float-card:not(#${FORCE_ID}),body .dropdown.shown .l-card:not(#${FORCE_ID}),body .dropdown.shown > .l-card.float-card:not(#${FORCE_ID}),body .dropdown .l-card.float-card:not(#${FORCE_ID}) {background-color: var(${GLASS_VAR_BG}) !important;background-image: none !important;border: 1px solid rgba(255, 255, 255, 0.55) !important;box-shadow: 0 8px 32px rgba(31, 38, 135, 0.2),0 2px 8px rgba(0, 0, 0, 0.08),inset 0 1px 0 rgba(255, 255, 255, 0.6) !important;backdrop-filter: ${USER_CARD_BLUR} !important;-webkit-backdrop-filter: ${USER_CARD_BLUR} !important;border-radius: 12px !important;}body .l-card.float-card:not(#${FORCE_ID}) .user-info,body .l-card.float-card:not(#${FORCE_ID}) .user-action {background-color: transparent !important;background-image: none !important;}`;}/* ============================================================* 弹窗 / 模态框毛玻璃* ============================================================ */function buildModalGlassRules() {return `${MODAL_CARD_SELECTOR.split(',').map(s => s.trim() + ':not(#' + FORCE_ID + ')').join(',\n ')} {background-color: var(${GLASS_VAR_FROSTED_BG}) !important;background-image: none !important;backdrop-filter: ${USER_CARD_BLUR} !important;-webkit-backdrop-filter: ${USER_CARD_BLUR} !important;border: var(${GLASS_VAR_BORDER}) !important;box-shadow: 0 16px 48px rgba(31, 38, 135, 0.22),0 4px 12px rgba(0, 0, 0, 0.08),inset 0 1px 0 rgba(255, 255, 255, 0.6) !important;border-radius: 12px !important;}${MODAL_CARD_SELECTOR.split(',').map(s => s.trim() + ':not(#' + FORCE_ID + ') > *').join(',\n ')},${MODAL_CARD_SELECTOR.split(',').map(s => s.trim() + ':not(#' + FORCE_ID + ') > * > *').join(',\n ')},${MODAL_CARD_SELECTOR.split(',').map(s => s.trim() + ':not(#' + FORCE_ID + ') form').join(',\n ')},${MODAL_CARD_SELECTOR.split(',').map(s => s.trim() + ':not(#' + FORCE_ID + ') .l-form-layout').join(',\n ')},${MODAL_CARD_SELECTOR.split(',').map(s => s.trim() + ':not(#' + FORCE_ID + ') .radio-group').join(',\n ')},${MODAL_CARD_SELECTOR.split(',').map(s => s.trim() + ':not(#' + FORCE_ID + ') .radio-group > *').join(',\n ')} {background-color: transparent !important;background-image: none !important;}${MODAL_CARD_SELECTOR.split(',').map(s => s.trim() + ':not(#' + FORCE_ID + ') .lfe-h3').join(',\n ')},${MODAL_CARD_SELECTOR.split(',').map(s => s.trim() + ':not(#' + FORCE_ID + ') h3').join(',\n ')} {color: #f0f0f5 !important;text-shadow: 0 1px 2px rgba(0,0,0,0.35) !important;}${MODAL_CARD_SELECTOR.split(',').map(s => s.trim() + ':not(#' + FORCE_ID + ') .l-form-layout > span').join(',\n ')},${MODAL_CARD_SELECTOR.split(',').map(s => s.trim() + ':not(#' + FORCE_ID + ') label').join(',\n ')} {color: #e8e8f0 !important;}${MODAL_CARD_SELECTOR.split(',').map(s => s.trim() + ':not(#' + FORCE_ID + ') .close svg').join(',\n ')} {color: #e8e8f0 !important;cursor: pointer;}`;}/* ============================================================* 玻璃 CSS 注入* ============================================================ */function injectGlassCSS() {let styleEl = document.getElementById(GLASS_STYLE_ID);if (!styleEl) {styleEl = document.createElement('style');styleEl.id = GLASS_STYLE_ID;document.head.appendChild(styleEl);}if (!currentEnabled) {if (styleEl.textContent !== '') styleEl.textContent = '';return;}const imageRules = isImagePage() ? `.image-card, .image-item,[class*="image-card"], [class*="image-item"] {background-color: var(${GLASS_VAR_BG}) !important;background-image: none !important;border: var(${GLASS_VAR_BORDER}) !important;box-shadow: var(${GLASS_VAR_SHADOW}) !important;backdrop-filter: none !important;-webkit-backdrop-filter: none !important;}` : '';const pasteRules = isPastePage() ? `.code-block, .paste-code,.am-pre-scrollable, .markdown-body pre,[class*="paste-code"], [class*="code-block"] {background-color: var(${GLASS_VAR_BG}) !important;background-image: none !important;border: var(${GLASS_VAR_BORDER}) !important;box-shadow: var(${GLASS_VAR_SHADOW}) !important;border-radius: 8px !important;backdrop-filter: none !important;-webkit-backdrop-filter: none !important;}` : '';const ticketRules = isTicketPage() ? `.ticket-card {background-color: transparent !important;background-image: none !important;border-color: transparent !important;box-shadow: none !important;backdrop-filter: none !important;-webkit-backdrop-filter: none !important;}.ticket-card > *,.list-wrap, .list-wrap > *,.row-wrap, .row-wrap > *,.wrapper, .wrapper > *,.left-status, .left-status > * {background-color: transparent !important;background-image: none !important;box-shadow: none !important;}.list-wrap:not(#${FORCE_ID}) > .row-wrap:not(#${FORCE_ID}):not(:first-child),.list-wrap:not(#${FORCE_ID}) > .row:not(#${FORCE_ID}):not(:first-child) {border-top: 1px solid var(${GLASS_VAR_TICKET_DIVIDER}, rgba(128, 128, 128, 0.6)) !important;margin-top: 16px !important;padding-top: 16px !important;}.list-wrap:not(#${FORCE_ID}) > .row:not(#${FORCE_ID}) {border-bottom: none !important;}` : '';const classSiteRules = IS_CLASS_SITE ? `.fix nav.hidden, .fix .hidden { display: none !important; }` : '';const tiRules = IS_TI_SITE ? `#app-header, #app-body, #app-footer,.width-wrap, .full-container {background-color: transparent !important;background-image: none !important;box-shadow: none !important;border-color: transparent !important;}.bg-wrap:not(#${FORCE_ID}),.bg-wrap:not(#${FORCE_ID}) .bg {background: transparent !important;background-color: transparent !important;background-image: none !important;border: none !important;box-shadow: none !important;backdrop-filter: none !important;-webkit-backdrop-filter: none !important;}.problemsets.card, .problemsets {background-color: var(${GLASS_VAR_BG}) !important;background-image: none !important;border: var(${GLASS_VAR_BORDER}) !important;box-shadow: var(${GLASS_VAR_SHADOW}) !important;border-radius: 12px !important;}.problemsets .problemset-item,.problemsets .row,.problemsets .problemset-item *,.problemsets .row * {background-color: transparent !important;background-image: none !important;box-shadow: none !important;}` : '';const forceTransparentRules = `html, body,#app, #app > div, #app-old, #app-old > div,.theme-page, .theme-page > div,.theme-mid-full, .theme-mid,.main-container, .columba-content-wrap,.lfe-body, .lfe-body > div, main, main > div {background-color: transparent !important;background-image: none !important;}`;const navSolidRules = `.top-bar:not(#${FORCE_ID}),nav.sidebar:not(#${FORCE_ID}),nav.sidebar.lside:not(#${FORCE_ID}),.sidebar.lside.bar:not(#${FORCE_ID}),.user-nav.rside:not(#${FORCE_ID}),#app-sidenav:not(#${FORCE_ID}),#app-header:not(#${FORCE_ID}) {background-color: var(--theme-navi-back, #1f1f28) !important;background-image: none !important;backdrop-filter: none !important;-webkit-backdrop-filter: none !important;}`;const pseudoMaskRules = `.theme-page:not(#${FORCE_ID})::before,.theme-page:not(#${FORCE_ID})::after,.theme-mid-full:not(#${FORCE_ID})::before,.theme-mid-full:not(#${FORCE_ID})::after,.theme-mid:not(#${FORCE_ID})::before,.theme-mid:not(#${FORCE_ID})::after,#app:not(#${FORCE_ID})::before,#app:not(#${FORCE_ID})::after,#app-old:not(#${FORCE_ID})::before,#app-old:not(#${FORCE_ID})::after,body:not(#${FORCE_ID})::before,body:not(#${FORCE_ID})::after {background: transparent !important;background-color: transparent !important;background-image: none !important;box-shadow: none !important;backdrop-filter: none !important;-webkit-backdrop-filter: none !important;}`;const helperTextRules = `.lg-small:not(#${FORCE_ID}):not([class*="lg-fg-"]):not([class*="lcolor--"]) {color: rgb(60, 60, 70) !important;}`;const inputGlassRules = buildInputGlassRules();const problemListGlassRules = buildProblemListGlassRules();const userCardGlassRules = buildUserCardGlassRules();const modalGlassRules = buildModalGlassRules();const content = `${forceTransparentRules}${navSolidRules}${pseudoMaskRules}${helperTextRules}// ... 后面的不动${navSolidRules}${pseudoMaskRules}${helperTextRules}.l-card, .lg-article, .lg-index-stat, .lg-index-contest,.am-panel, .n-card, .training-card, .category-card,.srqc, .course-card, .lesson-card, .chapter-card,.class-card, .problemsets, .problemset-item {background-color: var(${GLASS_VAR_BG}) !important;background-image: none !important;}.lg-punch {background-color: transparent !important;background-image: none !important;}.l-card > div:not(.user-header-top),.l-card > section, .l-card > header, .l-card > footer,.l-card > ul, .l-card > li,.l-card .list-scroll, .l-card .list-wrap, .l-card .header-wrap,.l-card .header, .l-card .row-wrap, .l-card .row, .l-card .block,.l-card .filter-section, .l-card .search-row, .l-card .combo-wrapper,.l-card .toolbar, .l-card .result,.lg-article > div, .lg-article > section,.n-card > .n-card-header, .n-card > .n-card__content, .n-card > .n-card__footer,.am-panel > .am-panel-hd, .am-panel > .am-panel-bd, .am-panel > .am-panel-ft {background-color: transparent !important;background-image: none !important;}footer, .footer, [class*="footer"] {background-color: transparent !important;background-image: none !important;border: none !important;box-shadow: none !important;}.am-comment-main {background-color: var(${GLASS_VAR_BG}) !important;background-image: none !important;}.am-comment-hd {background-color: var(${GLASS_VAR_BG_HD}) !important;background-image: none !important;backdrop-filter: none !important;-webkit-backdrop-filter: none !important;border-bottom: var(${GLASS_VAR_BORDER}) !important;box-shadow: var(${GLASS_VAR_SHADOW}) !important;border-radius: 8px 8px 0 0 !important;}.am-comment-bd, .am-comment-meta {background-color: transparent !important;background-image: none !important;}li.feed-li {background-color: transparent !important;background-image: none !important;}.bottom-wrap.float {background: var(${GLASS_VAR_BG}) !important;backdrop-filter: none !important;-webkit-backdrop-filter: none !important;border: var(${GLASS_VAR_BORDER}) !important;box-shadow: var(${GLASS_VAR_SHADOW}) !important;border-radius: 12px !important;padding: 6px 10px !important;}.bottom-wrap.float .btn-checkbox {background: transparent !important;background-color: transparent !important;background-image: none !important;border-color: transparent !important;box-shadow: none !important;backdrop-filter: none !important;-webkit-backdrop-filter: none !important;}.bottom-wrap.float .page-bar button {background: var(${GLASS_VAR_BG}) !important;backdrop-filter: none !important;-webkit-backdrop-filter: none !important;border: var(${GLASS_VAR_BORDER}) !important;box-shadow: var(${GLASS_VAR_SHADOW}) !important;border-radius: 8px !important;}.bottom-wrap.float .toolbar {background: transparent !important;}${imageRules}${pasteRules}${ticketRules}${classSiteRules}${tiRules}${inputGlassRules}${problemListGlassRules}${userCardGlassRules}${modalGlassRules}.user-header-top:not(#${FORCE_ID}) {background-color: transparent !important;box-shadow: none !important;border: none !important;}`;if (styleEl.textContent !== content) styleEl.textContent = content;}function clearPaintedBackground() {const root = document.documentElement;const body = document.body;['background-color', 'background-image', 'background-size','background-position', 'background-repeat', 'background-attachment'].forEach(p => root.style.removeProperty(p));if (body) body.style.removeProperty('background');const bgLayer = document.getElementById(FIXED_BG_ID);if (bgLayer && bgLayer.parentNode) bgLayer.parentNode.removeChild(bgLayer);document.querySelectorAll(`[${SHELL_CLEARED_ATTR}]`).forEach(el => {el.style.removeProperty('background');el.style.removeProperty('background-color');el.style.removeProperty('background-image');el.removeAttribute(SHELL_CLEARED_ATTR);});}/* ============================================================* 导航栏不透明兜底* ============================================================ */function solidifyNavigationBars() {if (!currentEnabled) return;const els = document.querySelectorAll(NAV_SELECTOR);els.forEach(el => {if (el.matches && el.matches(SHELL_SELECTOR)) {if (el.hasAttribute(NAV_SOLID_ATTR)) {el.removeAttribute(NAV_SOLID_ATTR);el.style.removeProperty('background-color');el.style.removeProperty('background-image');el.style.removeProperty('backdrop-filter');el.style.removeProperty('-webkit-backdrop-filter');}return;}const cs = getComputedStyle(el);const bg = cs.backgroundColor;const rgb = parseRgb(bg);if (!rgb) return;const isOpaque = !/rgba\(/.test(bg) || /rgba\([^)]*,\s*1(\.0*)?\s*\)/.test(bg);if (isOpaque && el.hasAttribute(NAV_SOLID_ATTR)) return;el.style.setProperty('background-color', `rgb(${rgb.r}, ${rgb.g}, ${rgb.b})`, 'important');el.style.setProperty('background-image', 'none', 'important');el.style.setProperty('backdrop-filter', 'none', 'important');el.style.setProperty('-webkit-backdrop-filter', 'none', 'important');el.setAttribute(NAV_SOLID_ATTR, '1');});}function clearSolidNavigationBars() {document.querySelectorAll(`[${NAV_SOLID_ATTR}]`).forEach(el => {el.style.removeProperty('background-color');el.style.removeProperty('background-image');el.style.removeProperty('backdrop-filter');el.style.removeProperty('-webkit-backdrop-filter');el.removeAttribute(NAV_SOLID_ATTR);});}/* ============================================================* 白卡玻璃化* ============================================================ */function bumpPaintVersion() {paintVersion++;}function applyWhiteCardsGlass() {if (!isGlassApplyPage() || !currentEnabled) return;const userBg = buildBgValue(currentColor, currentAlpha);const ver = paintVersion;const all = document.querySelectorAll('body *');all.forEach(el => {if (SKIP_TAGS.has(el.tagName)) return;if (INLINE_TAGS.has(el.tagName)) return;if (el.matches && el.matches('.l-card')) return;if (el.matches && el.matches('.user-header-top')) return;if (el.matches && el.matches(NAV_SELECTOR)) return;if (el.matches && el.matches(CSS_OWNED_SELECTOR)) return;if (el.closest && el.closest(`#${PANEL_ID}`)) return;try { if (el.closest('svg')) return; } catch (e) {}try { if (el.closest(CONTENT_EXCLUDE)) return; } catch (e) {}try { if (el.closest(CSS_OWNED_SUBTREE)) return; } catch (e) {}try { if (el.closest(NAV_SELECTOR)) return; } catch (e) {}try { if (el.closest('.l-card.float-card, .dropdown.shown .l-card')) return; } catch (e) {}try { if (el.closest(MODAL_CARD_SELECTOR)) return; } catch (e) {}try { if (el.closest(FLOATING_EXCLUDE)) return; } catch (e) {}if (paintedElements.get(el) === ver) return;const inlineBg = el.style && el.style.backgroundColor;if (inlineBg && inlineBg !== 'transparent' && inlineBg !== 'rgba(0, 0, 0, 0)') {const rgb = parseRgb(inlineBg);if (rgb) {const max = Math.max(rgb.r, rgb.g, rgb.b);const min = Math.min(rgb.r, rgb.g, rgb.b);if (!(max - min <= 20 && min >= 240)) return;} else return;}let cs;try { cs = getComputedStyle(el); } catch (e) { return; }const bg = cs.backgroundColor;if (!bg || bg === 'transparent' || bg === 'rgba(0, 0, 0, 0)') return;const rgb = parseRgb(bg);if (!rgb) return;const max = Math.max(rgb.r, rgb.g, rgb.b);const min = Math.min(rgb.r, rgb.g, rgb.b);if (max - min > 25) return;if (min < 210) return;if (!el.hasAttribute(ORIG_BG_ATTR)) {const orig = el.style.getPropertyValue('background-color');if (orig && orig !== 'transparent' && orig !== 'rgba(0, 0, 0, 0)') {el.setAttribute(ORIG_BG_ATTR, orig);}}el.style.setProperty('background-color', userBg, 'important');el.style.setProperty('background-image', 'none', 'important');el.style.setProperty('backdrop-filter', 'none', 'important');el.style.setProperty('-webkit-backdrop-filter', 'none', 'important');el.style.setProperty('border', GLASS_BORDER, 'important');el.style.setProperty('box-shadow', GLASS_SHADOW, 'important');el.setAttribute(PAINT_MARK, '1');paintedElements.set(el, ver);});}function clearWhiteCardsPaint() {document.querySelectorAll(`[${PAINT_MARK}]`).forEach(el => {el.style.removeProperty('background-color');if (el.hasAttribute(ORIG_BG_ATTR)) {const orig = el.getAttribute(ORIG_BG_ATTR);if (orig) el.style.setProperty('background-color', orig);el.removeAttribute(ORIG_BG_ATTR);}el.style.removeProperty('background-image');el.style.removeProperty('backdrop-filter');el.style.removeProperty('-webkit-backdrop-filter');el.style.removeProperty('border');el.style.removeProperty('box-shadow');el.removeAttribute(PAINT_MARK);});paintedElements = new WeakMap();document.querySelectorAll('.l-card.float-card, .dropdown.shown .l-card').forEach(el => {el.style.removeProperty('background-color');el.style.removeProperty('background-image');el.style.removeProperty('backdrop-filter');el.style.removeProperty('-webkit-backdrop-filter');el.style.removeProperty('border');el.style.removeProperty('box-shadow');el.style.removeProperty('border-radius');});document.querySelectorAll('.l-card.float-card .user-info, .l-card.float-card .user-action, ' +'.dropdown.shown .l-card .user-info, .dropdown.shown .l-card .user-action').forEach(el => {el.style.removeProperty('background-color');el.style.removeProperty('background-image');});}/* ============================================================* 悬停卡片强制毛玻璃* ============================================================ */function forceUserCardGlass() {if (!currentEnabled) return;const bg = buildBgValue(currentColor, currentAlpha);const cards = document.querySelectorAll('.l-card.float-card, .dropdown.shown .l-card');if (!cards.length) return;cards.forEach(el => {el.style.setProperty('background-color', bg, 'important');el.style.setProperty('background-image', 'none', 'important');el.style.setProperty('backdrop-filter', USER_CARD_BLUR, 'important');el.style.setProperty('-webkit-backdrop-filter', USER_CARD_BLUR, 'important');el.style.setProperty('border', GLASS_BORDER, 'important');el.style.setProperty('box-shadow', GLASS_SHADOW, 'important');el.style.setProperty('border-radius', '12px', 'important');});document.querySelectorAll('.l-card.float-card .user-info, .l-card.float-card .user-action').forEach(el => {el.style.setProperty('background-color', 'transparent', 'important');el.style.setProperty('background-image', 'none', 'important');});}function startUserCardGlassLoop() {if (userCardGlassTimer) return;userCardGlassTimer = setInterval(forceUserCardGlass, 300);}function stopUserCardGlassLoop() {if (userCardGlassTimer) {clearInterval(userCardGlassTimer);userCardGlassTimer = null;}}/* ============================================================* 弹窗强制毛玻璃* ============================================================ */function forceModalGlass() {if (!currentEnabled) return;const bg = buildFrostedBgValue(currentColor, currentAlpha);const modals = document.querySelectorAll(MODAL_CARD_SELECTOR);if (!modals.length) return;modals.forEach(el => {el.style.setProperty('background-color', bg, 'important');el.style.setProperty('background-image', 'none', 'important');el.style.setProperty('backdrop-filter', USER_CARD_BLUR, 'important');el.style.setProperty('-webkit-backdrop-filter', USER_CARD_BLUR, 'important');el.style.setProperty('border', GLASS_BORDER, 'important');el.style.setProperty('box-shadow','0 16px 48px rgba(31, 38, 135, 0.22), 0 4px 12px rgba(0, 0, 0, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.6)','important');el.style.setProperty('border-radius', '12px', 'important');el.querySelectorAll(':scope > *, :scope > * > *').forEach(child => {if (child.closest(`#${PANEL_ID}`)) return;child.style.setProperty('background-color', 'transparent', 'important');child.style.setProperty('background-image', 'none', 'important');});});}function startModalGlassLoop() {if (modalGlassTimer) return;modalGlassTimer = setInterval(forceModalGlass, 400);}function stopModalGlassLoop() {if (modalGlassTimer) {clearInterval(modalGlassTimer);modalGlassTimer = null;}}function clearModalGlass() {document.querySelectorAll(MODAL_CARD_SELECTOR).forEach(el => {el.style.removeProperty('background-color');el.style.removeProperty('background-image');el.style.removeProperty('backdrop-filter');el.style.removeProperty('-webkit-backdrop-filter');el.style.removeProperty('border');el.style.removeProperty('box-shadow');el.style.removeProperty('border-radius');el.querySelectorAll(':scope > *, :scope > * > *').forEach(child => {child.style.removeProperty('background-color');child.style.removeProperty('background-image');});});}/* ============================================================* 强制 refined-input.text 内层透明* ============================================================ */function forceTextInnerTransparent() {if (!currentEnabled) return;const containers = document.querySelectorAll('.refined-input.text:not(.search-text)');if (!containers.length) return;containers.forEach(container => {const inner = container.querySelectorAll('*');inner.forEach(el => {if (el.closest('svg') && el.tagName.toLowerCase() !== 'svg') return;el.style.setProperty('background-color', 'transparent', 'important');el.style.setProperty('background-image', 'none', 'important');el.style.setProperty('background', 'transparent', 'important');el.style.setProperty('border', 'none', 'important');el.style.setProperty('box-shadow', 'none', 'important');el.style.setProperty('outline', 'none', 'important');el.style.setProperty('backdrop-filter', 'none', 'important');el.style.setProperty('-webkit-backdrop-filter', 'none', 'important');el.setAttribute(INNER_TRANSPARENT_ATTR, '1');});});}function clearTextInnerTransparent() {document.querySelectorAll(`[${INNER_TRANSPARENT_ATTR}]`).forEach(el => {el.style.removeProperty('background-color');el.style.removeProperty('background-image');el.style.removeProperty('background');el.style.removeProperty('border');el.style.removeProperty('box-shadow');el.style.removeProperty('outline');el.style.removeProperty('backdrop-filter');el.style.removeProperty('-webkit-backdrop-filter');el.removeAttribute(INNER_TRANSPARENT_ATTR);});}/* ============================================================* 工单顶栏黑* ============================================================ */function applyTicketTopBarBlack() {if (!isTicketPage() || !currentEnabled) return;const topBar = document.querySelector('.top-bar');if (!topBar) return;const rect = topBar.getBoundingClientRect();if (rect.top > 100) return;if (topBar.hasAttribute(TICKET_TOPBAR_ATTR)) return;topBar.style.setProperty('background-color', '#1a1a1a', 'important');topBar.style.setProperty('background-image', 'none', 'important');topBar.style.setProperty('backdrop-filter', 'none', 'important');topBar.style.setProperty('-webkit-backdrop-filter', 'none', 'important');topBar.style.setProperty('border-bottom', '1px solid rgba(255,255,255,0.1)', 'important');topBar.setAttribute(TICKET_TOPBAR_ATTR, '1');topBar.querySelectorAll('a, span, div, h1, h2, h3, h4, p, li').forEach(child => {if (child.closest('svg')) return;child.style.setProperty('color', '#e0e0e0', 'important');});topBar.querySelectorAll('svg').forEach(svg => {svg.style.setProperty('color', '#e0e0e0', 'important');});}function clearTicketTopBarBlack() {document.querySelectorAll(`[${TICKET_TOPBAR_ATTR}]`).forEach(el => {el.style.removeProperty('background-color');el.style.removeProperty('background-image');el.style.removeProperty('backdrop-filter');el.style.removeProperty('-webkit-backdrop-filter');el.style.removeProperty('border-bottom');el.querySelectorAll('a, span, div, h1, h2, h3, h4, p, li, svg').forEach(child => {child.style.removeProperty('color');});el.removeAttribute(TICKET_TOPBAR_ATTR);});}/* ============================================================* 文字加深* ============================================================ */function isGrayish(r, g, b) {const max = Math.max(r, g, b);const min = Math.min(r, g, b);if (max - min > 30) return false;if (max < 40) return false;if (min > 220) return false;return true;}function isAlreadyDarkGray(r, g, b) {return Math.abs(r - 60) < 12 && Math.abs(g - 60) < 12 && Math.abs(b - 70) < 12;}function darkenColorText() {if (IS_CLASS_SITE || IS_TI_SITE) return;if (isArticleDetailPage()) return;const containers = document.querySelectorAll(CARD_SELECTOR_RAW);if (!containers.length) return;containers.forEach(card => {if (card.closest && card.closest(`#${PANEL_ID}`)) return;if (card.matches && card.matches(MODAL_CARD_SELECTOR)) return;if (card.closest && card.closest(MODAL_CARD_SELECTOR)) return;card.querySelectorAll(TEXT_DARKEN_SELECTOR).forEach(el => {if (el.children.length > 0) return;if (SKIP_TAGS.has(el.tagName)) return;if (el.closest('svg')) return;if (el.closest('input, textarea, button, select')) return;if (el.closest('.bottom-wrap.float')) return;if (el.closest('.user-header-top')) return;if (el.closest(NAV_SELECTOR)) return;if (el.closest(`.${INPUT_SKIP_CLASS}`)) return;if (el.closest(`#${PANEL_ID}`)) return;if (el.closest(MODAL_CARD_SELECTOR)) return;try { if (el.closest(CONTENT_EXCLUDE)) return; } catch (e) {}try { if (el.closest('.refined-input.search-text')) return; } catch (e) {}try { if (el.closest('.refined-input.text')) return; } catch (e) {}try { if (el.closest('.search-option')) return; } catch (e) {}if (darkenedElements.has(el)) return;const inlineBg = el.style && el.style.backgroundColor;if (inlineBg && inlineBg !== 'transparent' && inlineBg !== 'rgba(0, 0, 0, 0)') {const rgb = parseRgb(inlineBg);if (rgb) {const max = Math.max(rgb.r, rgb.g, rgb.b);const min = Math.min(rgb.r, rgb.g, rgb.b);if (!(max - min <= 20 && min >= 240)) return;} else return;}const parentInlineBg = el.parentElement && el.parentElement.style && el.parentElement.style.backgroundColor;if (parentInlineBg && parentInlineBg !== 'transparent' && parentInlineBg !== 'rgba(0, 0, 0, 0)') {const rgb = parseRgb(parentInlineBg);if (rgb) {const max = Math.max(rgb.r, rgb.g, rgb.b);const min = Math.min(rgb.r, rgb.g, rgb.b);if (!(max - min <= 20 && min >= 240)) return;} else return;}let cs;try { cs = getComputedStyle(el); } catch (e) { return; }const rgb = parseRgb(cs.color);if (!rgb) return;if (!isAlreadyDarkGray(rgb.r, rgb.g, rgb.b) && isGrayish(rgb.r, rgb.g, rgb.b)) {el.style.setProperty('color', DARK_GRAY, 'important');el.setAttribute(GRAY_MARK, '1');darkenedElements.add(el);}});});}function clearColorText() {document.querySelectorAll(`[${GRAY_MARK}]`).forEach(el => {el.style.removeProperty('color');el.removeAttribute(GRAY_MARK);});darkenedElements = new WeakSet();}/* ============================================================* 主入口* ============================================================ */function applyCustomBg() {try {if (!currentEnabled) {const styleEl = document.getElementById(GLASS_STYLE_ID);if (styleEl && styleEl.textContent !== '') styleEl.textContent = '';clearGlassVars();clearColorText();clearTicketTopBarBlack();clearWhiteCardsPaint();clearTextInnerTransparent();clearSolidNavigationBars();clearPaintedBackground();clearModalGlass();stopThemeBgWatcher();stopLuoguThemePoll();stopUserCardGlassLoop();stopModalGlassLoop();lastThemeInfo = { imageUrl: null, backColor: null, colorGradient: null, source: 'none' };return;}const info = getThemeBackgroundInfo();lastThemeInfo = info;syncGlassVars();injectGlassCSS();solidifyNavigationBars();paintBackgroundInline();applyTicketTopBarBlack();applyWhiteCardsGlass();forceUserCardGlass();startUserCardGlassLoop();forceModalGlass();startModalGlassLoop();forceTextInnerTransparent();darkenColorText();startThemeBgWatcher();startLuoguThemePoll();} catch (err) {console.error('[铍洛谷] applyCustomBg 出错:', err);}}/* ============================================================* 观察器 + 节流* ============================================================ */let observer = null;let repaintTimer = null;function scheduleRepaint() {if (repaintTimer) return;repaintTimer = setTimeout(() => {repaintTimer = null;applyCustomBg();}, 200);}function startWatching() {if (observer || !document.body) return;observer = new MutationObserver(scheduleRepaint);observer.observe(document.body, { childList: true, subtree: true });}/* ============================================================* 主题变化轮询* ============================================================ */let themeBgPollTimer = null;function startThemeBgWatcher() {if (themeBgPollTimer) return;themeBgPollTimer = setInterval(() => {if (!currentEnabled) return;const latest = getThemeBackgroundInfo();const changed =latest.imageUrl !== lastThemeInfo.imageUrl ||latest.backColor !== lastThemeInfo.backColor ||latest.colorGradient !== lastThemeInfo.colorGradient;if (changed) {lastThemeInfo = latest;paintBackgroundInline();}}, 800);}function stopThemeBgWatcher() {if (themeBgPollTimer) {clearInterval(themeBgPollTimer);themeBgPollTimer = null;}}function startLuoguThemePoll() {if (luoguThemePollTimer) return;luoguThemePollTimer = setInterval(() => {if (!currentEnabled) return;const themeData = extractLuoguThemeFromDoc(document);const parsed = themeData ? parseLBody(themeData.lBody) : null;if (!parsed) return;if (parsed.imageUrl === lastLuoguThemeImage) return;lastLuoguThemeImage = parsed.imageUrl;GM_setValue(KEY_AUTO_BG_URL, parsed.imageUrl);if (parsed.backColor) GM_setValue(KEY_AUTO_BG_BACK, parsed.backColor);if (parsed.colorGradient) GM_setValue(KEY_AUTO_BG_GRAD, parsed.colorGradient);if (PAGE_WIN.__LUOGU_BG_VERBOSE) {console.log('[铍洛谷] 检测到 #luogu-theme 变化:', parsed.imageUrl);}applyCustomBg();}, 1500);}function stopLuoguThemePoll() {if (luoguThemePollTimer) {clearInterval(luoguThemePollTimer);luoguThemePollTimer = null;}}/* ============================================================* 跨标签同步* ============================================================ */let listenersAdded = false;const listenedKeys = new Set();function addValueListeners() {if (listenersAdded) return;listenersAdded = true;if (typeof GM_addValueChangeListener === 'undefined') return;const sync = (name, oldVal, newVal) => {if (name === KEY_ENABLED) currentEnabled = !!newVal;if (name === KEY_COLOR) currentColor = newVal || '#232329';if (name === KEY_ALPHA) currentAlpha = Math.min(1, Math.max(0.05, parseFloat(newVal) || 0.78));if (name === KEY_THEME_BG_URL || name === KEY_AUTO_BG_URL) {themeHostEl = null;}if (name === KEY_COLOR || name === KEY_ALPHA) {bumpPaintVersion();}setTimeout(applyCustomBg, 50);};const register = (key) => {if (listenedKeys.has(key)) return;listenedKeys.add(key);GM_addValueChangeListener(key, sync);};register(KEY_ENABLED);register(KEY_COLOR);register(KEY_ALPHA);register(KEY_THEME_BG_URL);register(KEY_AUTO_BG_URL);register(KEY_AUTO_BG_BACK);register(KEY_AUTO_BG_GRAD);}/* ============================================================* 设置面板样式* ============================================================ */function injectPanelStyle() {if (document.getElementById(STYLE_ID)) return;const s = document.createElement('style');s.id = STYLE_ID;s.textContent = `#${PANEL_ID} {margin: 20px auto; max-width: 900px; padding: 20px 24px;position: relative;background: rgba(255, 255, 255, 0.35);backdrop-filter: blur(30px) saturate(160%) brightness(1.08);-webkit-backdrop-filter: blur(30px) saturate(160%) brightness(1.08);border: 1px solid rgba(255, 255, 255, 0.55);border-radius: 14px;box-shadow: 0 8px 32px rgba(31,38,135,0.12),0 2px 8px rgba(0,0,0,0.05),inset 0 1px 0 rgba(255,255,255,0.6);font-family: -apple-system, BlinkMacSystemFont, "PingFang SC","Microsoft YaHei", "Segoe UI", sans-serif;box-sizing: border-box; overflow: hidden; color: #2c3e50;}#${PANEL_ID}::before {content: ""; position: absolute; top: 0; left: 0; right: 0; height: 50%;background: linear-gradient(to bottom, rgba(255,255,255,0.35), transparent);pointer-events: none; border-radius: 14px 14px 0 0;}#${PANEL_ID} > * { position: relative; z-index: 1; }#${PANEL_ID} .panel-title {display: flex; align-items: center; gap: 6px;font-size: 15px; font-weight: 600; color: #2c3e50;margin-bottom: 16px; letter-spacing: 0.3px;text-shadow: 0 1px 2px rgba(255, 255, 255, 0.6);}#${PANEL_ID} .panel-title::before {content: ""; width: 3px; height: 14px;background: linear-gradient(to bottom, #3498db, #5dade2);border-radius: 2px; box-shadow: 0 0 6px rgba(52,152,219,0.5);}#${PANEL_ID} .setting-row {display: flex; align-items: center; justify-content: space-between;padding: 10px 12px; border-radius: 10px;background: rgba(255, 255, 255, 0.25);border: 1px solid rgba(255, 255, 255, 0.45);}#${PANEL_ID} .setting-label { font-size: 14px; color: #2c3e50; font-weight: 500; }#${PANEL_ID} .setting-desc { font-size: 12px; color: #5a6a7a; margin-top: 2px; }#${PANEL_ID} .toggle-switch {position: relative; width: 46px; height: 26px; flex-shrink: 0; cursor: pointer;}#${PANEL_ID} .toggle-switch input { opacity: 0; width: 0; height: 0; }#${PANEL_ID} .toggle-slider {position: absolute; inset: 0;background: rgba(180, 190, 205, 0.45);border: 1px solid rgba(255, 255, 255, 0.55);border-radius: 26px; transition: background 0.3s;}#${PANEL_ID} .toggle-slider::before {content: ""; position: absolute; width: 20px; height: 20px;left: 2px; top: 2px; background: #fff; border-radius: 50%;transition: transform 0.3s cubic-bezier(.4, 1.4, .6, 1);box-shadow: 0 2px 4px rgba(0,0,0,0.15);}#${PANEL_ID} .toggle-switch input:checked + .toggle-slider {background: linear-gradient(135deg, #3498db, #5dade2);box-shadow: 0 0 12px rgba(52,152,219,0.45);}#${PANEL_ID} .toggle-switch input:checked + .toggle-slider::before {transform: translateX(20px);}#${PANEL_ID} .bg-input-area { margin-top: 14px; transition: opacity 0.3s; }#${PANEL_ID} .bg-input-area.disabled { opacity: 0.45; pointer-events: none; }#${PANEL_ID} .bg-input-area.disabled .btn-row { pointer-events: auto; }#${PANEL_ID} .bg-row {display: flex; align-items: center; gap: 12px;padding: 10px 12px; border-radius: 10px;background: rgba(255, 255, 255, 0.25);border: 1px solid rgba(255, 255, 255, 0.45);margin-top: 10px;}#${PANEL_ID} .bg-row label {font-size: 13px; color: #4a5a6a; width: 80px; flex-shrink: 0;}#${PANEL_ID} .bg-row .bg-value {font-size: 12px; color: #5a6a7a; min-width: 60px; text-align: right;font-family: ui-monospace, Menlo, Consolas, monospace;}#${PANEL_ID} input[type="color"] {width: 44px; height: 30px; padding: 0;border: 1px solid rgba(255, 255, 255, 0.6);border-radius: 8px; background: transparent;cursor: pointer; outline: none; flex-shrink: 0;}#${PANEL_ID} input[type="range"] {flex: 1; height: 6px; border-radius: 3px;background: rgba(255, 255, 255, 0.5);outline: none; -webkit-appearance: none;appearance: none; cursor: pointer;}#${PANEL_ID} input[type="range"]::-webkit-slider-thumb {-webkit-appearance: none;width: 18px; height: 18px; border-radius: 50%;background: linear-gradient(135deg, #3498db, #5dade2);box-shadow: 0 2px 6px rgba(52,152,219,0.5);cursor: pointer; border: 2px solid #fff;}#${PANEL_ID} input[type="text"] {flex: 1; padding: 6px 10px; font-size: 12px;border: 1px solid rgba(255, 255, 255, 0.6);border-radius: 8px; background: rgba(255, 255, 255, 0.5);outline: none; font-family: ui-monospace, Menlo, Consolas, monospace;color: #2c3e50; min-width: 0;}#${PANEL_ID} input[type="text"]:focus {background: rgba(255, 255, 255, 0.8);border-color: #3498db;}#${PANEL_ID} .bg-preview {margin-top: 12px; height: 64px; border-radius: 10px;border: 1px solid rgba(255, 255, 255, 0.6);position: relative; overflow: hidden;background-image:linear-gradient(45deg, rgba(0,0,0,0.08) 25%, transparent 25%),linear-gradient(-45deg, rgba(0,0,0,0.08) 25%, transparent 25%),linear-gradient(45deg, transparent 75%, rgba(0,0,0,0.08) 75%),linear-gradient(-45deg, transparent 75%, rgba(0,0,0,0.08) 75%);background-size: 16px 16px;background-position: 0 0, 0 8px, 8px -8px, -8px 0;}#${PANEL_ID} .bg-preview-color {position: absolute; inset: 0; transition: background-color 0.2s;}#${PANEL_ID} .bg-preview span {position: absolute; inset: 0;display: flex; align-items: center; justify-content: center;font-size: 13px; color: #fff;text-shadow: 0 1px 3px rgba(0,0,0,0.5);pointer-events: none; z-index: 1;}#${PANEL_ID} .debug-info {margin-top: 10px; padding: 8px 12px; border-radius: 8px;background: rgba(0, 0, 0, 0.06);font-family: ui-monospace, Menlo, Consolas, monospace;font-size: 11px; color: #4a5a6a;word-break: break-all; line-height: 1.6;}#${PANEL_ID} .btn-row {display: flex; gap: 10px; margin-top: 12px; align-items: center;flex-wrap: wrap;}#${PANEL_ID} .btn {padding: 8px 20px; border-radius: 8px;font-size: 13px; font-weight: 500;cursor: pointer; border: 1px solid transparent;font-family: inherit;}#${PANEL_ID} .btn-primary {background: linear-gradient(135deg, #3498db, #5dade2);color: #fff; box-shadow: 0 4px 12px rgba(52,152,219,0.35);}#${PANEL_ID} .btn-secondary {background: rgba(255, 255, 255, 0.35);color: #5a6a7a;border-color: rgba(255, 255, 255, 0.55);}#${PANEL_ID} .btn-mini {padding: 4px 10px; font-size: 11px;}#${PANEL_ID} .save-status {font-size: 12px; color: #27ae60; margin-left: 4px;opacity: 0; transition: opacity 0.3s;}#${PANEL_ID} .save-status.show { opacity: 1; }`;document.head.appendChild(s);}function createPanel() {const manualUrl = GM_getValue(KEY_THEME_BG_URL, '') || '';const panel = document.createElement('div');panel.id = PANEL_ID;panel.innerHTML = `<div class="panel-title">铍洛谷 设置</div><div class="setting-row"><div><div class="setting-label">启用自定义背景板</div><div class="setting-desc">全站统一应用颜色与透明度</div></div><label class="toggle-switch"><input type="checkbox" id="bg-toggle" ${currentEnabled ? 'checked' : ''}><span class="toggle-slider"></span></label></div><div class="bg-input-area ${currentEnabled ? '' : 'disabled'}" id="bg-input-area"><div class="bg-row"><label>背景图 URL</label><input type="text" id="bg-url" placeholder="留空则跟随主题" value="${manualUrl.replace(/"/g, '"')}"><button class="btn btn-primary btn-mini" id="bg-url-apply">应用</button></div><div class="bg-row"><label>颜色</label><input type="color" id="bg-color" value="${currentColor}"><span class="bg-value" id="bg-color-text">${currentColor}</span></div><div class="bg-row"><label>透明度</label><input type="range" id="bg-alpha" min="5" max="100" value="${Math.round(currentAlpha * 100)}"><span class="bg-value" id="bg-alpha-text">${Math.round(currentAlpha * 100)}%</span></div><div class="bg-preview"><div class="bg-preview-color" id="bg-preview-color"></div><span>预览效果</span></div><div class="debug-info" id="bg-debug"></div></div><div class="btn-row"><button class="btn btn-primary" id="bg-save">保存</button><button class="btn btn-secondary" id="bg-reset">重置</button><button class="btn btn-secondary" id="bg-refresh-theme">重新拉取主题</button><button class="btn btn-secondary" id="bg-url-clear">清空手动 URL</button><button class="btn btn-secondary" id="bg-auto-clear">清空自动缓存</button><span class="save-status" id="bg-status">已保存</span></div>`;panel.querySelectorAll('input, textarea').forEach(el => {el.classList.add(INPUT_SKIP_CLASS);});const toggle = panel.querySelector('#bg-toggle');const inputArea = panel.querySelector('#bg-input-area');const colorInput = panel.querySelector('#bg-color');const colorText = panel.querySelector('#bg-color-text');const alphaInput = panel.querySelector('#bg-alpha');const alphaText = panel.querySelector('#bg-alpha-text');const urlInput = panel.querySelector('#bg-url');const previewColor = panel.querySelector('#bg-preview-color');const debugInfo = panel.querySelector('#bg-debug');const status = panel.querySelector('#bg-status');const showStatus = msg => {status.textContent = msg;status.classList.add('show');clearTimeout(status._t);status._t = setTimeout(() => status.classList.remove('show'), 1800);};function refreshDebug() {const manual = GM_getValue(KEY_THEME_BG_URL, '') || '(空)';const auto = GM_getValue(KEY_AUTO_BG_URL, '') || '(空)';const source = lastThemeInfo.source || 'none';const divider = buildTicketDividerColor(currentColor);const frosted = buildFrostedBgValue(currentColor, currentAlpha);debugInfo.innerHTML =`手动 URL: ${manual}<br>` +`自动缓存: ${auto}<br>` +`当前生效来源: <b>${source}</b><br>` +`工单分割线色: <b>${divider}</b><br>` +`弹窗毛玻璃色: <b>${frosted}</b>`;}function liveUpdate() {currentColor = colorInput.value;currentAlpha = parseInt(alphaInput.value, 10) / 100;colorText.textContent = currentColor;alphaText.textContent = `${Math.round(currentAlpha * 100)}%`;previewColor.style.backgroundColor = buildBgValue(currentColor, currentAlpha);bumpPaintVersion();if (currentEnabled) applyCustomBg();refreshDebug();}colorInput.addEventListener('input', liveUpdate);alphaInput.addEventListener('input', liveUpdate);colorInput.addEventListener('change', liveUpdate);alphaInput.addEventListener('change', liveUpdate);previewColor.style.backgroundColor = buildBgValue(currentColor, currentAlpha);refreshDebug();panel.querySelector('#bg-url-apply').addEventListener('click', () => {const url = urlInput.value.trim();GM_setValue(KEY_THEME_BG_URL, url);themeHostEl = null;lastThemeInfo = { imageUrl: null, backColor: null, colorGradient: null, source: 'none' };applyCustomBg();refreshDebug();showStatus(url ? '已应用' : '已切回跟随主题');});panel.querySelector('#bg-refresh-theme').addEventListener('click', () => {preferenceFetched = false;serverThemeFetched = false;serverThemeAttempted = false;themeHostEl = null;lastLuoguThemeImage = '';lastThemeInfo = { imageUrl: null, backColor: null, colorGradient: null, source: 'none' };applyCustomBg();fetchThemeFromApi(true).then(url => {if (url) {GM_setValue(KEY_AUTO_BG_URL, url);applyCustomBg();showStatus('已重新拉取:' + url.slice(0, 40) + '...');} else {showStatus('拉取失败');}refreshDebug();});});panel.querySelector('#bg-url-clear').addEventListener('click', () => {urlInput.value = '';GM_setValue(KEY_THEME_BG_URL, '');themeHostEl = null;lastThemeInfo = { imageUrl: null, backColor: null, colorGradient: null, source: 'none' };applyCustomBg();refreshDebug();showStatus('已清空手动 URL');});panel.querySelector('#bg-auto-clear').addEventListener('click', () => {GM_setValue(KEY_AUTO_BG_URL, '');GM_setValue(KEY_AUTO_BG_BACK, '');GM_setValue(KEY_AUTO_BG_GRAD, '');lastLuoguThemeImage = '';refreshDebug();showStatus('已清空自动缓存');});urlInput.addEventListener('keydown', (e) => {if (e.key === 'Enter') {e.preventDefault();panel.querySelector('#bg-url-apply').click();}});toggle.addEventListener('change', () => {currentEnabled = toggle.checked;GM_setValue(KEY_ENABLED, currentEnabled);inputArea.classList.toggle('disabled', !toggle.checked);bumpPaintVersion();applyCustomBg();refreshDebug();});panel.querySelector('#bg-save').addEventListener('click', () => {GM_setValue(KEY_ENABLED, currentEnabled);GM_setValue(KEY_COLOR, currentColor);GM_setValue(KEY_ALPHA, currentAlpha);GM_setValue(KEY_THEME_BG_URL, urlInput.value.trim());bumpPaintVersion();applyCustomBg();refreshDebug();showStatus('已保存');});panel.querySelector('#bg-reset').addEventListener('click', () => {colorInput.value = '#232329';alphaInput.value = 78;liveUpdate();GM_setValue(KEY_COLOR, '#232329');GM_setValue(KEY_ALPHA, 0.78);showStatus('已重置');});return panel;}function tryInsertPanel() {if (document.getElementById(PANEL_ID)) return true;if (!isSettingPage()) return false;const main = document.querySelector('main');if (!main) return false;injectPanelStyle();const panel = createPanel();const hitoPanel = document.getElementById(HITOKOTO_PANEL_ID);if (hitoPanel && hitoPanel.parentElement === main) {hitoPanel.insertAdjacentElement('afterend', panel);} else {main.appendChild(panel);}return true;}function tryInsertPanelWithWait() {if (tryInsertPanel()) return;let waited = 0;const t = setInterval(() => {waited += 200;if (tryInsertPanel()) { clearInterval(t); return; }if (waited >= 3000) clearInterval(t);}, 200);}/* ============================================================* 调试接口* ============================================================ */PAGE_WIN.__luoguBgDebug = function () {console.group('==== 铍洛谷调试 v5.5.2 ====');console.log('enabled:', currentEnabled);console.log('手动 URL:', GM_getValue(KEY_THEME_BG_URL, '') || '(空)');console.log('自动缓存 URL:', GM_getValue(KEY_AUTO_BG_URL, '') || '(空)');console.log('自动缓存 backColor:', GM_getValue(KEY_AUTO_BG_BACK, '') || '(空)');console.log('自动缓存 gradient:', GM_getValue(KEY_AUTO_BG_GRAD, '') || '(空)');console.log('毛玻璃背景色:', buildFrostedBgValue(currentColor, currentAlpha));console.log('lastThemeInfo:', lastThemeInfo);console.log('isHomePage:', isHomePage());console.log('lastLuoguThemeImage:', lastLuoguThemeImage);const themeEl = document.getElementById('luogu-theme');if (themeEl) {try {const t = JSON.parse(themeEl.textContent);console.log('#luogu-theme lBody:', t.lBody);} catch (e) {console.log('#luogu-theme 解析失败:', e);}} else {console.log('#luogu-theme 不存在');}console.groupEnd();return {lastThemeInfo,manual: GM_getValue(KEY_THEME_BG_URL, ''),auto: GM_getValue(KEY_AUTO_BG_URL, ''),};};PAGE_WIN.__luoguBgInspectUserCard = function () {console.log('[铍洛谷] 请在 3 秒内把鼠标悬停到一个用户名上,并保持不动...');setTimeout(() => {const el = document.querySelector('.l-card.float-card');if (!el) {console.warn('[铍洛谷] 未找到 .l-card.float-card,请确认鼠标正悬停在用户名上');return null;}const cs = getComputedStyle(el);const info = {bg: cs.backgroundColor,backdropFilter: cs.backdropFilter || cs.webkitBackdropFilter,border: cs.borderTopWidth + ' ' + cs.borderTopStyle + ' ' + cs.borderTopColor,boxShadow: cs.boxShadow.slice(0, 80),borderRadius: cs.borderTopLeftRadius,inlineStyle: el.getAttribute('style'),};console.log('l-card.float-card:', info);console.log(el);return info;}, 3000);return '等待中... 3 秒后看控制台';};PAGE_WIN.__luoguBgForceRefresh = function () {themeHostEl = null;preferenceFetched = false;serverThemeFetched = false;serverThemeAttempted = false;lastLuoguThemeImage = '';lastThemeInfo = { imageUrl: null, backColor: null, colorGradient: null, source: 'none' };bumpPaintVersion();applyCustomBg();console.log('[铍洛谷] 已强制刷新');return lastThemeInfo;};PAGE_WIN.__luoguBgFetchTheme = function () {preferenceFetched = false;serverThemeFetched = false;serverThemeAttempted = false;lastLuoguThemeImage = '';fetchThemeFromPreference().then(() => {if (!lastThemeInfo.imageUrl) {return fetchThemeFromApi(true).then(url => {if (url) {GM_setValue(KEY_AUTO_BG_URL, url);applyCustomBg();}return url;});}});console.log('[铍洛谷] 已触发主题拉取');};PAGE_WIN.__luoguBgFetchFromServer = function () {serverThemeFetched = false;serverThemeAttempted = false;lastLuoguThemeImage = '';return fetchThemeFromApi(true).then(url => {console.log('[铍洛谷] fetch 结果:', url);if (url) {GM_setValue(KEY_AUTO_BG_URL, url);applyCustomBg();}return url;});};PAGE_WIN.__luoguBgFetchViaIframe = PAGE_WIN.__luoguBgFetchFromServer;PAGE_WIN.__luoguBgSetThemeBg = function (url) {url = (url || '').trim();GM_setValue(KEY_THEME_BG_URL, url);themeHostEl = null;lastThemeInfo = { imageUrl: null, backColor: null, colorGradient: null, source: 'none' };applyCustomBg();console.log('[铍洛谷] 手动 URL =', url || '(已清空)');};PAGE_WIN.__luoguBgSetAutoBg = function (url) {url = (url || '').trim();GM_setValue(KEY_AUTO_BG_URL, url);themeHostEl = null;lastLuoguThemeImage = '';lastThemeInfo = { imageUrl: null, backColor: null, colorGradient: null, source: 'none' };applyCustomBg();console.log('[铍洛谷] 自动缓存 URL =', url || '(已清空)');};PAGE_WIN.__luoguBgForceDisable = function () {GM_setValue(KEY_ENABLED, false);currentEnabled = false;bumpPaintVersion();applyCustomBg();console.log('[铍洛谷] 已强制关闭');};PAGE_WIN.__luoguBgVerbose = function (on) {PAGE_WIN.__LUOGU_BG_VERBOSE = !!on;console.log('[铍洛谷] verbose =', PAGE_WIN.__LUOGU_BG_VERBOSE);};/* ============================================================* 启动* ============================================================ */function boot() {try {const themeData = extractLuoguThemeFromDoc(document);const parsed = themeData ? parseLBody(themeData.lBody) : null;if (parsed) lastLuoguThemeImage = parsed.imageUrl;applyCustomBg();startWatching();addValueListeners();if (isSettingPage()) tryInsertPanelWithWait();if (IS_MAIN_SITE && !getManualBgUrl()) {fetchThemeFromApi().then(url => {if (url && currentEnabled) {const old = GM_getValue(KEY_AUTO_BG_URL, '');if (old !== url) {GM_setValue(KEY_AUTO_BG_URL, url);applyCustomBg();}}});}console.log('[铍洛谷] v5.5.2 已启动。\n' +' 调试: __luoguBgDebug()\n' +' 悬停卡片调试: __luoguBgInspectUserCard()\n' +' 强制刷新: __luoguBgForceRefresh()\n' +' 重新拉取主题: __luoguBgFetchTheme()\n' +' fetch 拉取: __luoguBgFetchFromServer()\n' +' 强制关闭: __luoguBgForceDisable()');} catch (err) {console.error('[铍洛谷] boot 出错:', err);}}boot();let lastUrl = location.href;setInterval(() => {if (location.href !== lastUrl) {lastUrl = location.href;serverThemeAttempted = false;setTimeout(() => {try {applyCustomBg();startWatching();if (isSettingPage()) tryInsertPanelWithWait();if (IS_MAIN_SITE && !getManualBgUrl()) {fetchThemeFromApi().then(url => {if (url && currentEnabled) {const old = GM_getValue(KEY_AUTO_BG_URL, '');if (old !== url) {GM_setValue(KEY_AUTO_BG_URL, url);applyCustomBg();}}});}} catch (err) {console.error('[铍洛谷] URL 变化后重绘出错:', err);}}, 300);}}, 800);})();::::::::info[脚本]{open}```javascript// ==UserScript==// @name 铍洛谷// @namespace http://tampermonkey.net/// @version 5.5// @description 洛谷主站(含用户主页)+ 网校 + 有题 + image/paste/ticket 统一背景板// @author Breakon and DeepSeek// @match https://www.luogu.com.cn/*// @match https://class.luogu.com.cn/*36 行未改动const GLASS_VAR_BG_HD = '--luogu-glass-bg-hd';const GLASS_VAR_BORDER = '--luogu-glass-border';const GLASS_VAR_SHADOW = '--luogu-glass-shadow';const GLASS_VAR_TICKET_DIVIDER = '--luogu-glass-ticket-divider';const GLASS_VAR_FROSTED_BG = '--luogu-glass-frosted-bg'; /* ★ v5.5 */const PAINT_MARK = 'data-bg-painted';const ORIG_BG_ATTR = 'data-bg-orig-bg';const TICKET_TOPBAR_ATTR = 'data-ticket-topbar';18 行未改动const IS_MAIN_SITE = HOST === 'www.luogu.com.cn' || HOST === 'www.luogu.org';const IS_CLASS_SITE = HOST === 'class.luogu.com.cn';const IS_TI_SITE = HOST === 'ti.luogu.com.cn';const GRAY_MARK = 'data-darkened-gray';const DARK_GRAY = 'rgb(60, 60, 70)';const SKIP_TAGS = new Set(['INPUT', 'TEXTAREA', 'BUTTON', 'SELECT',76 行未改动'blockquote', 'figcaption', 'cite', 'q', 'mark','section', 'article', 'header', 'footer', 'aside',].join(', ');/* ★ v5.5:弹窗容器选择器,用于识别模态类 .l-card */const MODAL_CARD_SELECTOR = ['.l-card.container.type-burger','.l-card.container.type-dialog','.l-card.container.type-popup','.l-card.container[class*="type-"]','.l-card[class*="container"][class*="type-"]','.l-modal .l-card','.l-modal__body .l-card','.v-modal .l-card','[class*="modal"] > .l-card','[class*="dialog"] > .l-card','[class*="popup"] > .l-card',].join(', ');/* ============================================================* 状态* ============================================================ */function readAlpha() {21 行未改动let luoguThemePollTimer = null;let lastLuoguThemeImage = '';let userCardGlassTimer = null;let modalGlassTimer = null; /* ★ v5.5 *//* ============================================================* 工具* ============================================================ */24 行未改动const lum = 0.299 * r + 0.587 * g + 0.114 * b;if (lum > 128) return 'rgba(0, 0, 0, 0.55)';return 'rgba(255, 255, 255, 0.55)';}/* ★ v5.5:根据当前 alpha 计算毛玻璃用的低透明度值 */function buildFrostedBgValue(hex, alpha) {const frostedAlpha = Math.max(0.18, Math.min(0.55, alpha * 0.55));return buildBgValue(hex, frostedAlpha);}function parseRgb(str) {if (!str) return null;const m = str.match(/rgba?\(\s*(\d+)\s*[,\s]\s*(\d+)\s*[,\s]\s*(\d+)/);if (!m) return null;353 行未改动全部展开root.style.setProperty(GLASS_VAR_BG_HD, buildFeedHeaderBg(currentColor, currentAlpha));root.style.setProperty(GLASS_VAR_BORDER, GLASS_BORDER);root.style.setProperty(GLASS_VAR_SHADOW, GLASS_SHADOW);root.style.setProperty(GLASS_VAR_TICKET_DIVIDER, buildTicketDividerColor(currentColor));/* ★ v5.5:毛玻璃弹窗专用背景(低 alpha,配合 backdrop-filter 用) */root.style.setProperty(GLASS_VAR_FROSTED_BG, buildFrostedBgValue(currentColor, currentAlpha));}function clearGlassVars() {const root = document.documentElement;root.style.removeProperty(GLASS_VAR_BG);root.style.removeProperty(GLASS_VAR_BG_HD);root.style.removeProperty(GLASS_VAR_BORDER);root.style.removeProperty(GLASS_VAR_SHADOW);root.style.removeProperty(GLASS_VAR_TICKET_DIVIDER);root.style.removeProperty(GLASS_VAR_FROSTED_BG); /* ★ v5.5 */}/* ============================================================* 内联画背景244 行未改动全部展开`;}/* ============================================================* 用户名悬停卡片 —— CSS 层面兜底(JS 内联是主方案)* ============================================================ */function buildUserCardGlassRules() {return `body .l-card.float-card:not(#${FORCE_ID}),19 行未改动`;}/* ============================================================* ★ v5.5:弹窗 / 模态框毛玻璃* ============================================================ */function buildModalGlassRules() {return `/* 弹窗容器:真正的毛玻璃 */${MODAL_CARD_SELECTOR.split(',').map(s => s.trim() + ':not(#' + FORCE_ID + ')').join(',\n ')} {background-color: var(${GLASS_VAR_FROSTED_BG}) !important;background-image: none !important;backdrop-filter: ${USER_CARD_BLUR} !important;-webkit-backdrop-filter: ${USER_CARD_BLUR} !important;border: var(${GLASS_VAR_BORDER}) !important;box-shadow: 0 16px 48px rgba(31, 38, 135, 0.22),0 4px 12px rgba(0, 0, 0, 0.08),inset 0 1px 0 rgba(255, 255, 255, 0.6) !important;border-radius: 12px !important;}/* 弹窗内部结构透明,露出毛玻璃 */${MODAL_CARD_SELECTOR.split(',').map(s => s.trim() + ':not(#' + FORCE_ID + ') > *').join(',\n ')},${MODAL_CARD_SELECTOR.split(',').map(s => s.trim() + ':not(#' + FORCE_ID + ') > * > *').join(',\n ')},${MODAL_CARD_SELECTOR.split(',').map(s => s.trim() + ':not(#' + FORCE_ID + ') form').join(',\n ')},${MODAL_CARD_SELECTOR.split(',').map(s => s.trim() + ':not(#' + FORCE_ID + ') .l-form-layout').join(',\n ')},${MODAL_CARD_SELECTOR.split(',').map(s => s.trim() + ':not(#' + FORCE_ID + ') .radio-group').join(',\n ')},${MODAL_CARD_SELECTOR.split(',').map(s => s.trim() + ':not(#' + FORCE_ID + ') .radio-group > *').join(',\n ')} {background-color: transparent !important;background-image: none !important;}/* 弹窗标题栏字符保持白色高对比 */${MODAL_CARD_SELECTOR.split(',').map(s => s.trim() + ':not(#' + FORCE_ID + ') .lfe-h3').join(',\n ')},${MODAL_CARD_SELECTOR.split(',').map(s => s.trim() + ':not(#' + FORCE_ID + ') h3').join(',\n ')} {color: #f0f0f5 !important;text-shadow: 0 1px 2px rgba(0,0,0,0.35) !important;}${MODAL_CARD_SELECTOR.split(',').map(s => s.trim() + ':not(#' + FORCE_ID + ') .l-form-layout > span').join(',\n ')},${MODAL_CARD_SELECTOR.split(',').map(s => s.trim() + ':not(#' + FORCE_ID + ') label').join(',\n ')} {color: #e8e8f0 !important;}${MODAL_CARD_SELECTOR.split(',').map(s => s.trim() + ':not(#' + FORCE_ID + ') .close svg').join(',\n ')} {color: #e8e8f0 !important;cursor: pointer;}`;}/* ============================================================* 玻璃 CSS* ============================================================ */function injectGlassCSS() {let styleEl = document.getElementById(GLASS_STYLE_ID);146 行未改动全部展开const inputGlassRules = buildInputGlassRules();const problemListGlassRules = buildProblemListGlassRules();const userCardGlassRules = buildUserCardGlassRules();const modalGlassRules = buildModalGlassRules(); /* ★ v5.5 */const content = `${navSolidRules}${pseudoMaskRules}93 行未改动${inputGlassRules}${problemListGlassRules}${userCardGlassRules}${modalGlassRules}.user-header-top:not(#${FORCE_ID}) {background-color: transparent !important;box-shadow: none !important;71 行未改动try { if (el.closest(CONTENT_EXCLUDE)) return; } catch (e) {}try { if (el.closest(CSS_OWNED_SUBTREE)) return; } catch (e) {}try { if (el.closest(NAV_SELECTOR)) return; } catch (e) {}try { if (el.closest('.l-card.float-card, .dropdown.shown .l-card')) return; } catch (e) {}try { if (el.closest(MODAL_CARD_SELECTOR)) return; } catch (e) {} /* ★ v5.5 */try { if (el.closest(FLOATING_EXCLUDE)) return; } catch (e) {}if (paintedElements.get(el) === ver) return;62 行未改动el.style.removeProperty('border');el.style.removeProperty('box-shadow');el.style.removeProperty('border-radius');});document.querySelectorAll('.l-card.float-card .user-info, .l-card.float-card .user-action, ' +'.dropdown.shown .l-card .user-info, .dropdown.shown .l-card .user-action').forEach(el => {el.style.removeProperty('background-color');el.style.removeProperty('background-image');});}/* ============================================================* JS 内联 !important 强制悬停卡片毛玻璃* ============================================================ */function forceUserCardGlass() {if (!currentEnabled) return;const bg = buildBgValue(currentColor, currentAlpha);28 行未改动}}/* ============================================================* ★ v5.5:JS 内联强制弹窗毛玻璃(CSS 兜底 + JS 强化)* ============================================================ */function forceModalGlass() {if (!currentEnabled) return;const bg = buildFrostedBgValue(currentColor, currentAlpha);const modals = document.querySelectorAll(MODAL_CARD_SELECTOR);if (!modals.length) return;modals.forEach(el => {el.style.setProperty('background-color', bg, 'important');el.style.setProperty('background-image', 'none', 'important');el.style.setProperty('backdrop-filter', USER_CARD_BLUR, 'important');el.style.setProperty('-webkit-backdrop-filter', USER_CARD_BLUR, 'important');el.style.setProperty('border', GLASS_BORDER, 'important');el.style.setProperty('box-shadow','0 16px 48px rgba(31, 38, 135, 0.22), 0 4px 12px rgba(0, 0, 0, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.6)','important');el.style.setProperty('border-radius', '12px', 'important');/* 内层结构清透明 */el.querySelectorAll(':scope > *, :scope > * > *').forEach(child => {if (child.closest(`#${PANEL_ID}`)) return;child.style.setProperty('background-color', 'transparent', 'important');child.style.setProperty('background-image', 'none', 'important');});});}function startModalGlassLoop() {if (modalGlassTimer) return;modalGlassTimer = setInterval(forceModalGlass, 400);}function stopModalGlassLoop() {if (modalGlassTimer) {clearInterval(modalGlassTimer);modalGlassTimer = null;}}function clearModalGlass() {document.querySelectorAll(MODAL_CARD_SELECTOR).forEach(el => {el.style.removeProperty('background-color');el.style.removeProperty('background-image');el.style.removeProperty('backdrop-filter');el.style.removeProperty('-webkit-backdrop-filter');el.style.removeProperty('border');el.style.removeProperty('box-shadow');el.style.removeProperty('border-radius');el.querySelectorAll(':scope > *, :scope > * > *').forEach(child => {child.style.removeProperty('background-color');child.style.removeProperty('background-image');});});}/* ============================================================* 强制 .refined-input.text 的内层元素透明* ============================================================ */function forceTextInnerTransparent() {if (!currentEnabled) return;71 行未改动});}/* ============================================================* 文字加深 —— 只保留灰色* ============================================================ */function isGrayish(r, g, b) {const max = Math.max(r, g, b);const min = Math.min(r, g, b);if (max - min > 30) return false;if (max < 40) return false;if (min > 220) return false;return true;}function isAlreadyDarkGray(r, g, b) {return Math.abs(r - 60) < 12 && Math.abs(g - 60) < 12 && Math.abs(b - 70) < 12;}function darkenColorText() {if (IS_CLASS_SITE || IS_TI_SITE) return;if (isArticleDetailPage()) return;const containers = document.querySelectorAll(CARD_SELECTOR_RAW);if (!containers.length) return;containers.forEach(card => {if (card.closest && card.closest(`#${PANEL_ID}`)) return;if (card.matches && card.matches(MODAL_CARD_SELECTOR)) return; /* ★ v5.5:弹窗交给 modal 规则 */if (card.closest && card.closest(MODAL_CARD_SELECTOR)) return; /* ★ v5.5 */card.querySelectorAll(TEXT_DARKEN_SELECTOR).forEach(el => {if (el.children.length > 0) return;if (SKIP_TAGS.has(el.tagName)) return;if (el.closest('svg')) return;if (el.closest('input, textarea, button, select')) return;if (el.closest('.bottom-wrap.float')) return;if (el.closest('.user-header-top')) return;if (el.closest(NAV_SELECTOR)) return;if (el.closest(`.${INPUT_SKIP_CLASS}`)) return;if (el.closest(`#${PANEL_ID}`)) return;if (el.closest(MODAL_CARD_SELECTOR)) return; /* ★ v5.5 */try { if (el.closest(CONTENT_EXCLUDE)) return; } catch (e) {}try { if (el.closest('.refined-input.search-text')) return; } catch (e) {}try { if (el.closest('.refined-input.text')) return; } catch (e) {}try { if (el.closest('.search-option')) return; } catch (e) {}if (darkenedElements.has(el)) return;const inlineBg = el.style && el.style.backgroundColor;if (inlineBg && inlineBg !== 'transparent' && inlineBg !== 'rgba(0, 0, 0, 0)') {const rgb = parseRgb(inlineBg);if (rgb) {const max = Math.max(rgb.r, rgb.g, rgb.b);const min = Math.min(rgb.r, rgb.g, rgb.b);if (!(max - min <= 20 && min >= 240)) return;} else return;}const parentInlineBg = el.parentElement && el.parentElement.style && el.parentElement.style.backgroundColor;if (parentInlineBg && parentInlineBg !== 'transparent' && parentInlineBg !== 'rgba(0, 0, 0, 0)') {const rgb = parseRgb(parentInlineBg);if (rgb) {const max = Math.max(rgb.r, rgb.g, rgb.b);const min = Math.min(rgb.r, rgb.g, rgb.b);if (!(max - min <= 20 && min >= 240)) return;} else return;}let cs;try { cs = getComputedStyle(el); } catch { return; }const rgb = parseRgb(cs.color);if (!rgb) return;if (!isAlreadyDarkGray(rgb.r, rgb.g, rgb.b) && isGrayish(rgb.r, rgb.g, rgb.b)) {el.style.setProperty('color', DARK_GRAY, 'important');el.setAttribute(GRAY_MARK, '1');darkenedElements.add(el);}});});}function clearColorText() {document.querySelectorAll(`[${GRAY_MARK}]`).forEach(el => {el.style.removeProperty('color');el.removeAttribute(GRAY_MARK);});darkenedElements = new WeakSet();}/* ============================================================* 主入口* ============================================================ */function applyCustomBg() {try {if (!currentEnabled) {const styleEl = document.getElementById(GLASS_STYLE_ID);if (styleEl && styleEl.textContent !== '') styleEl.textContent = '';clearGlassVars();clearColorText();clearTicketTopBarBlack();clearWhiteCardsPaint();clearTextInnerTransparent();clearSolidNavigationBars();clearPaintedBackground();clearModalGlass(); /* ★ v5.5 */stopThemeBgWatcher();stopLuoguThemePoll();stopUserCardGlassLoop();stopModalGlassLoop(); /* ★ v5.5 */lastThemeInfo = { imageUrl: null, backColor: null, colorGradient: null, source: 'none' };return;}const info = getThemeBackgroundInfo();lastThemeInfo = info;syncGlassVars();injectGlassCSS();solidifyNavigationBars();paintBackgroundInline();applyTicketTopBarBlack();applyWhiteCardsGlass();forceUserCardGlass();startUserCardGlassLoop();forceModalGlass(); /* ★ v5.5 */startModalGlassLoop(); /* ★ v5.5 */forceTextInnerTransparent();darkenColorText();startThemeBgWatcher();startLuoguThemePoll();} catch (err) {console.error('[铍洛谷] applyCustomBg 出错:', err);}}/* ============================================================* 观察器 + 节流* ============================================================ */let observer = null;let repaintTimer = null;function scheduleRepaint() {if (repaintTimer) return;repaintTimer = setTimeout(() => {repaintTimer = null;applyCustomBg();}, 200);}function startWatching() {if (observer || !document.body) return;observer = new MutationObserver(scheduleRepaint);observer.observe(document.body, { childList: true, subtree: true });}/* ============================================================* 主题变化轮询* ============================================================ */let themeBgPollTimer = null;function startThemeBgWatcher() {if (themeBgPollTimer) return;themeBgPollTimer = setInterval(() => {if (!currentEnabled) return;const latest = getThemeBackgroundInfo();const changed =latest.imageUrl !== lastThemeInfo.imageUrl ||latest.backColor !== lastThemeInfo.backColor ||latest.colorGradient !== lastThemeInfo.colorGradient;if (changed) {lastThemeInfo = latest;paintBackgroundInline();}}, 800);}function stopThemeBgWatcher() {if (themeBgPollTimer) {clearInterval(themeBgPollTimer);themeBgPollTimer = null;}}function startLuoguThemePoll() {if (luoguThemePollTimer) return;luoguThemePollTimer = setInterval(() => {if (!currentEnabled) return;const themeData = extractLuoguThemeFromDoc(document);const parsed = themeData ? parseLBody(themeData.lBody) : null;if (!parsed) return;if (parsed.imageUrl === lastLuoguThemeImage) return;lastLuoguThemeImage = parsed.imageUrl;GM_setValue(KEY_AUTO_BG_URL, parsed.imageUrl);if (parsed.backColor) GM_setValue(KEY_AUTO_BG_BACK, parsed.backColor);if (parsed.colorGradient) GM_setValue(KEY_AUTO_BG_GRAD, parsed.colorGradient);if (PAGE_WIN.__LUOGU_BG_VERBOSE) {console.log('[铍洛谷] 检测到 #luogu-theme 变化:', parsed.imageUrl);}applyCustomBg();}, 1500);}function stopLuoguThemePoll() {if (luoguThemePollTimer) {clearInterval(luoguThemePollTimer);luoguThemePollTimer = null;}}/* ============================================================* 跨标签同步* ============================================================ */let listenersAdded = false;const listenedKeys = new Set();function addValueListeners() {if (listenersAdded) return;listenersAdded = true;if (typeof GM_addValueChangeListener === 'undefined') return;const sync = (name, oldVal, newVal) => {if (name === KEY_ENABLED) currentEnabled = !!newVal;if (name === KEY_COLOR) currentColor = newVal || '#232329';if (name === KEY_ALPHA) currentAlpha = Math.min(1, Math.max(0.05, parseFloat(newVal) || 0.78));if (name === KEY_THEME_BG_URL || name === KEY_AUTO_BG_URL) {themeHostEl = null;}if (name === KEY_COLOR || name === KEY_ALPHA) {bumpPaintVersion();}setTimeout(applyCustomBg, 50);};const register = (key) => {if (listenedKeys.has(key)) return;listenedKeys.add(key);GM_addValueChangeListener(key, sync);};register(KEY_ENABLED);register(KEY_COLOR);register(KEY_ALPHA);register(KEY_THEME_BG_URL);register(KEY_AUTO_BG_URL);register(KEY_AUTO_BG_BACK);register(KEY_AUTO_BG_GRAD);}/* ============================================================* 设置面板* ============================================================ */function injectPanelStyle() {if (document.getElementById(STYLE_ID)) return;const s = document.createElement('style');s.id = STYLE_ID;s.textContent = `#${PANEL_ID} {margin: 20px auto; max-width: 900px; padding: 20px 24px;position: relative;background: rgba(255, 255, 255, 0.35);backdrop-filter: blur(30px) saturate(160%) brightness(1.08);-webkit-backdrop-filter: blur(30px) saturate(160%) brightness(1.08);border: 1px solid rgba(255, 255, 255, 0.55);border-radius: 14px;box-shadow: 0 8px 32px rgba(31,38,135,0.12),0 2px 8px rgba(0,0,0,0.05),inset 0 1px 0 rgba(255,255,255,0.6);font-family: -apple-system, BlinkMacSystemFont, "PingFang SC","Microsoft YaHei", "Segoe UI", sans-serif;box-sizing: border-box; overflow: hidden; color: #2c3e50;}#${PANEL_ID}::before {content: ""; position: absolute; top: 0; left: 0; right: 0; height: 50%;background: linear-gradient(to bottom, rgba(255,255,255,0.35), transparent);pointer-events: none; border-radius: 14px 14px 0 0;}#${PANEL_ID} > * { position: relative; z-index: 1; }#${PANEL_ID} .panel-title {display: flex; align-items: center; gap: 6px;font-size: 15px; font-weight: 600; color: #2c3e50;margin-bottom: 16px; letter-spacing: 0.3px;text-shadow: 0 1px 2px rgba(255, 255, 255, 0.6);}#${PANEL_ID} .panel-title::before {content: ""; width: 3px; height: 14px;background: linear-gradient(to bottom, #3498db, #5dade2);border-radius: 2px; box-shadow: 0 0 6px rgba(52,152,219,0.5);}#${PANEL_ID} .setting-row {display: flex; align-items: center; justify-content: space-between;padding: 10px 12px; border-radius: 10px;background: rgba(255, 255, 255, 0.25);border: 1px solid rgba(255, 255, 255, 0.45);}#${PANEL_ID} .setting-label { font-size: 14px; color: #2c3e50; font-weight: 500; }#${PANEL_ID} .setting-desc { font-size: 12px; color: #5a6a7a; margin-top: 2px; }#${PANEL_ID} .toggle-switch {position: relative; width: 46px; height: 26px; flex-shrink: 0; cursor: pointer;}#${PANEL_ID} .toggle-switch input { opacity: 0; width: 0; height: 0; }#${PANEL_ID} .toggle-slider {position: absolute; inset: 0;background: rgba(180, 190, 205, 0.45);border: 1px solid rgba(255, 255, 255, 0.55);border-radius: 26px; transition: background 0.3s;}#${PANEL_ID} .toggle-slider::before {content: ""; position: absolute; width: 20px; height: 20px;left: 2px; top: 2px; background: #fff; border-radius: 50%;transition: transform 0.3s cubic-bezier(.4, 1.4, .6, 1);box-shadow: 0 2px 4px rgba(0,0,0,0.15);}#${PANEL_ID} .toggle-switch input:checked + .toggle-slider {background: linear-gradient(135deg, #3498db, #5dade2);box-shadow: 0 0 12px rgba(52,152,219,0.45);}#${PANEL_ID} .toggle-switch input:checked + .toggle-slider::before {transform: translateX(20px);}#${PANEL_ID} .bg-input-area { margin-top: 14px; transition: opacity 0.3s; }#${PANEL_ID} .bg-input-area.disabled { opacity: 0.45; pointer-events: none; }#${PANEL_ID} .bg-input-area.disabled .btn-row { pointer-events: auto; }#${PANEL_ID} .bg-row {display: flex; align-items: center; gap: 12px;padding: 10px 12px; border-radius: 10px;background: rgba(255, 255, 255, 0.25);border: 1px solid rgba(255, 255, 255, 0.45);margin-top: 10px;}#${PANEL_ID} .bg-row label {font-size: 13px; color: #4a5a6a; width: 80px; flex-shrink: 0;}#${PANEL_ID} .bg-row .bg-value {font-size: 12px; color: #5a6a7a; min-width: 60px; text-align: right;font-family: ui-monospace, Menlo, Consolas, monospace;}#${PANEL_ID} input[type="color"] {width: 44px; height: 30px; padding: 0;border: 1px solid rgba(255, 255, 255, 0.6);border-radius: 8px; background: transparent;cursor: pointer; outline: none; flex-shrink: 0;}#${PANEL_ID} input[type="range"] {flex: 1; height: 6px; border-radius: 3px;background: rgba(255, 255, 255, 0.5);outline: none; -webkit-appearance: none;appearance: none; cursor: pointer;}#${PANEL_ID} input[type="range"]::-webkit-slider-thumb {-webkit-appearance: none;width: 18px; height: 18px; border-radius: 50%;background: linear-gradient(135deg, #3498db, #5dade2);box-shadow: 0 2px 6px rgba(52,152,219,0.5);cursor: pointer; border: 2px solid #fff;}#${PANEL_ID} input[type="text"] {flex: 1; padding: 6px 10px; font-size: 12px;border: 1px solid rgba(255, 255, 255, 0.6);border-radius: 8px; background: rgba(255, 255, 255, 0.5);outline: none; font-family: ui-monospace, Menlo, Consolas, monospace;color: #2c3e50; min-width: 0;}#${PANEL_ID} input[type="text"]:focus {background: rgba(255, 255, 255, 0.8);border-color: #3498db;}#${PANEL_ID} .bg-preview {margin-top: 12px; height: 64px; border-radius: 10px;border: 1px solid rgba(255, 255, 255, 0.6);position: relative; overflow: hidden;background-image:linear-gradient(45deg, rgba(0,0,0,0.08) 25%, transparent 25%),linear-gradient(-45deg, rgba(0,0,0,0.08) 25%, transparent 25%),linear-gradient(45deg, transparent 75%, rgba(0,0,0,0.08) 75%),linear-gradient(-45deg, transparent 75%, rgba(0,0,0,0.08) 75%);background-size: 16px 16px;background-position: 0 0, 0 8px, 8px -8px, -8px 0;}#${PANEL_ID} .bg-preview-color {position: absolute; inset: 0; transition: background-color 0.2s;}#${PANEL_ID} .bg-preview span {position: absolute; inset: 0;display: flex; align-items: center; justify-content: center;font-size: 13px; color: #fff;text-shadow: 0 1px 3px rgba(0,0,0,0.5);pointer-events: none; z-index: 1;}#${PANEL_ID} .debug-info {margin-top: 10px; padding: 8px 12px; border-radius: 8px;background: rgba(0, 0, 0, 0.06);font-family: ui-monospace, Menlo, Consolas, monospace;font-size: 11px; color: #4a5a6a;word-break: break-all; line-height: 1.6;}#${PANEL_ID} .btn-row {display: flex; gap: 10px; margin-top: 12px; align-items: center;flex-wrap: wrap;}#${PANEL_ID} .btn {padding: 8px 20px; border-radius: 8px;font-size: 13px; font-weight: 500;cursor: pointer; border: 1px solid transparent;font-family: inherit;}#${PANEL_ID} .btn-primary {background: linear-gradient(135deg, #3498db, #5dade2);color: #fff; box-shadow: 0 4px 12px rgba(52,152,219,0.35);}#${PANEL_ID} .btn-secondary {background: rgba(255, 255, 255, 0.35);color: #5a6a7a;border-color: rgba(255, 255, 255, 0.55);}#${PANEL_ID} .btn-mini {padding: 4px 10px; font-size: 11px;}#${PANEL_ID} .save-status {font-size: 12px; color: #27ae60; margin-left: 4px;opacity: 0; transition: opacity 0.3s;}#${PANEL_ID} .save-status.show { opacity: 1; }`;document.head.appendChild(s);}function createPanel() {const manualUrl = GM_getValue(KEY_THEME_BG_URL, '') || '';const panel = document.createElement('div');panel.id = PANEL_ID;panel.innerHTML = `<div class="panel-title">铍洛谷 设置</div><div class="setting-row"><div><div class="setting-label">启用自定义背景板</div><div class="setting-desc">全站统一应用颜色与透明度</div></div><label class="toggle-switch"><input type="checkbox" id="bg-toggle" ${currentEnabled ? 'checked' : ''}><span class="toggle-slider"></span></label></div><div class="bg-input-area ${currentEnabled ? '' : 'disabled'}" id="bg-input-area"><div class="bg-row"><label>背景图 URL</label><input type="text" id="bg-url" placeholder="留空则跟随主题" value="${manualUrl.replace(/"/g, '"')}"><button class="btn btn-primary btn-mini" id="bg-url-apply">应用</button></div><div class="bg-row"><label>颜色</label><input type="color" id="bg-color" value="${currentColor}"><span class="bg-value" id="bg-color-text">${currentColor}</span></div><div class="bg-row"><label>透明度</label><input type="range" id="bg-alpha" min="5" max="100" value="${Math.round(currentAlpha * 100)}"><span class="bg-value" id="bg-alpha-text">${Math.round(currentAlpha * 100)}%</span></div><div class="bg-preview"><div class="bg-preview-color" id="bg-preview-color"></div><span>预览效果</span></div><div class="debug-info" id="bg-debug"></div></div><div class="btn-row"><button class="btn btn-primary" id="bg-save">保存</button><button class="btn btn-secondary" id="bg-reset">重置</button><button class="btn btn-secondary" id="bg-refresh-theme">重新拉取主题</button><button class="btn btn-secondary" id="bg-url-clear">清空手动 URL</button><button class="btn btn-secondary" id="bg-auto-clear">清空自动缓存</button><span class="save-status" id="bg-status">已保存</span></div>`;panel.querySelectorAll('input, textarea').forEach(el => {el.classList.add(INPUT_SKIP_CLASS);});const toggle = panel.querySelector('#bg-toggle');const inputArea = panel.querySelector('#bg-input-area');const colorInput = panel.querySelector('#bg-color');const colorText = panel.querySelector('#bg-color-text');const alphaInput = panel.querySelector('#bg-alpha');const alphaText = panel.querySelector('#bg-alpha-text');const urlInput = panel.querySelector('#bg-url');const previewColor = panel.querySelector('#bg-preview-color');const debugInfo = panel.querySelector('#bg-debug');const status = panel.querySelector('#bg-status');const showStatus = msg => {status.textContent = msg;status.classList.add('show');clearTimeout(status._t);status._t = setTimeout(() => status.classList.remove('show'), 1800);};function refreshDebug() {const manual = GM_getValue(KEY_THEME_BG_URL, '') || '(空)';const auto = GM_getValue(KEY_AUTO_BG_URL, '') || '(空)';const source = lastThemeInfo.source || 'none';const divider = buildTicketDividerColor(currentColor);const frosted = buildFrostedBgValue(currentColor, currentAlpha);debugInfo.innerHTML =`手动 URL: ${manual}<br>` +`自动缓存: ${auto}<br>` +`当前生效来源: <b>${source}</b><br>` +`工单分割线色: <b>${divider}</b><br>` +`弹窗毛玻璃色: <b>${frosted}</b>`;}function liveUpdate() {currentColor = colorInput.value;currentAlpha = parseInt(alphaInput.value, 10) / 100;colorText.textContent = currentColor;alphaText.textContent = `${Math.round(currentAlpha * 100)}%`;previewColor.style.backgroundColor = buildBgValue(currentColor, currentAlpha);bumpPaintVersion();if (currentEnabled) applyCustomBg();refreshDebug();}colorInput.addEventListener('input', liveUpdate);alphaInput.addEventListener('input', liveUpdate);colorInput.addEventListener('change', liveUpdate);alphaInput.addEventListener('change', liveUpdate);previewColor.style.backgroundColor = buildBgValue(currentColor, currentAlpha);refreshDebug();panel.querySelector('#bg-url-apply').addEventListener('click', () => {const url = urlInput.value.trim();GM_setValue(KEY_THEME_BG_URL, url);themeHostEl = null;lastThemeInfo = { imageUrl: null, backColor: null, colorGradient: null, source: 'none' };applyCustomBg();refreshDebug();showStatus(url ? '已应用' : '已切回跟随主题');});panel.querySelector('#bg-refresh-theme').addEventListener('click', () => {preferenceFetched = false;serverThemeFetched = false;serverThemeAttempted = false;themeHostEl = null;lastLuoguThemeImage = '';lastThemeInfo = { imageUrl: null, backColor: null, colorGradient: null, source: 'none' };applyCustomBg();fetchThemeFromApi(true).then(url => {if (url) {GM_setValue(KEY_AUTO_BG_URL, url);applyCustomBg();showStatus('已重新拉取:' + url.slice(0, 40) + '...');} else {showStatus('拉取失败');}refreshDebug();});});panel.querySelector('#bg-url-clear').addEventListener('click', () => {urlInput.value = '';GM_setValue(KEY_THEME_BG_URL, '');themeHostEl = null;lastThemeInfo = { imageUrl: null, backColor: null, colorGradient: null, source: 'none' };applyCustomBg();refreshDebug();showStatus('已清空手动 URL');});panel.querySelector('#bg-auto-clear').addEventListener('click', () => {GM_setValue(KEY_AUTO_BG_URL, '');GM_setValue(KEY_AUTO_BG_BACK, '');GM_setValue(KEY_AUTO_BG_GRAD, '');lastLuoguThemeImage = '';refreshDebug();showStatus('已清空自动缓存');});urlInput.addEventListener('keydown', (e) => {if (e.key === 'Enter') {e.preventDefault();panel.querySelector('#bg-url-apply').click();}});toggle.addEventListener('change', () => {currentEnabled = toggle.checked;GM_setValue(KEY_ENABLED, currentEnabled);inputArea.classList.toggle('disabled', !toggle.checked);bumpPaintVersion();applyCustomBg();refreshDebug();});panel.querySelector('#bg-save').addEventListener('click', () => {GM_setValue(KEY_ENABLED, currentEnabled);GM_setValue(KEY_COLOR, currentColor);GM_setValue(KEY_ALPHA, currentAlpha);GM_setValue(KEY_THEME_BG_URL, urlInput.value.trim());bumpPaintVersion();applyCustomBg();refreshDebug();showStatus('已保存');});panel.querySelector('#bg-reset').addEventListener('click', () => {colorInput.value = '#232329';alphaInput.value = 78;liveUpdate();GM_setValue(KEY_COLOR, '#232329');GM_setValue(KEY_ALPHA, 0.78);showStatus('已重置');});return panel;}function tryInsertPanel() {if (document.getElementById(PANEL_ID)) return true;if (!isSettingPage()) return false;const main = document.querySelector('main');if (!main) return false;injectPanelStyle();const panel = createPanel();const hitoPanel = document.getElementById(HITOKOTO_PANEL_ID);if (hitoPanel && hitoPanel.parentElement === main) {hitoPanel.insertAdjacentElement('afterend', panel);} else {main.appendChild(panel);}return true;}function tryInsertPanelWithWait() {if (tryInsertPanel()) return;let waited = 0;const t = setInterval(() => {waited += 200;if (tryInsertPanel()) { clearInterval(t); return; }if (waited >= 3000) clearInterval(t);}, 200);}/* ============================================================* 调试 & 手动设置接口* ============================================================ */PAGE_WIN.__luoguBgDebug = function () {console.group('==== 铍洛谷调试 v5.5 ====');console.log('enabled:', currentEnabled);console.log('手动 URL:', GM_getValue(KEY_THEME_BG_URL, '') || '(空)');console.log('自动缓存 URL:', GM_getValue(KEY_AUTO_BG_URL, '') || '(空)');console.log('自动缓存 backColor:', GM_getValue(KEY_AUTO_BG_BACK, '') || '(空)');console.log('自动缓存 gradient:', GM_getValue(KEY_AUTO_BG_GRAD, '') || '(空)');console.log('毛玻璃背景色:', buildFrostedBgValue(currentColor, currentAlpha));console.log('lastThemeInfo:', lastThemeInfo);console.log('isHomePage:', isHomePage());console.log('lastLuoguThemeImage:', lastLuoguThemeImage);const themeEl = document.getElementById('luogu-theme');if (themeEl) {try {const t = JSON.parse(themeEl.textContent);console.log('#luogu-theme lBody:', t.lBody);} catch (e) {console.log('#luogu-theme 解析失败:', e);}} else {console.log('#luogu-theme 不存在');}console.groupEnd();return {lastThemeInfo,manual: GM_getValue(KEY_THEME_BG_URL, ''),auto: GM_getValue(KEY_AUTO_BG_URL, ''),};};PAGE_WIN.__luoguBgInspectUserCard = function () {console.log('[铍洛谷] 请在 3 秒内把鼠标悬停到一个用户名上,并保持不动...');setTimeout(() => {const el = document.querySelector('.l-card.float-card');if (!el) {console.warn('[铍洛谷] 未找到 .l-card.float-card,请确认鼠标正悬停在用户名上');return null;}const cs = getComputedStyle(el);const info = {bg: cs.backgroundColor,backdropFilter: cs.backdropFilter || cs.webkitBackdropFilter,border: cs.borderTopWidth + ' ' + cs.borderTopStyle + ' ' + cs.borderTopColor,boxShadow: cs.boxShadow.slice(0, 80),borderRadius: cs.borderTopLeftRadius,inlineStyle: el.getAttribute('style'),};console.log('l-card.float-card:', info);console.log(el);return info;}, 3000);return '等待中... 3 秒后看控制台';};PAGE_WIN.__luoguBgForceRefresh = function () {themeHostEl = null;preferenceFetched = false;serverThemeFetched = false;serverThemeAttempted = false;lastLuoguThemeImage = '';lastThemeInfo = { imageUrl: null, backColor: null, colorGradient: null, source: 'none' };bumpPaintVersion();applyCustomBg();console.log('[铍洛谷] 已强制刷新');return lastThemeInfo;};PAGE_WIN.__luoguBgFetchTheme = function () {preferenceFetched = false;serverThemeFetched = false;serverThemeAttempted = false;lastLuoguThemeImage = '';fetchThemeFromPreference().then(() => {if (!lastThemeInfo.imageUrl) {return fetchThemeFromApi(true).then(url => {if (url) {GM_setValue(KEY_AUTO_BG_URL, url);applyCustomBg();}return url;});}});console.log('[铍洛谷] 已触发主题拉取');};PAGE_WIN.__luoguBgFetchFromServer = function () {serverThemeFetched = false;serverThemeAttempted = false;lastLuoguThemeImage = '';return fetchThemeFromApi(true).then(url => {console.log('[铍洛谷] fetch 结果:', url);if (url) {GM_setValue(KEY_AUTO_BG_URL, url);applyCustomBg();}return url;});};PAGE_WIN.__luoguBgFetchViaIframe = PAGE_WIN.__luoguBgFetchFromServer;PAGE_WIN.__luoguBgSetThemeBg = function (url) {url = (url || '').trim();GM_setValue(KEY_THEME_BG_URL, url);themeHostEl = null;lastThemeInfo = { imageUrl: null, backColor: null, colorGradient: null, source: 'none' };applyCustomBg();console.log('[铍洛谷] 手动 URL =', url || '(已清空)');};PAGE_WIN.__luoguBgSetAutoBg = function (url) {url = (url || '').trim();GM_setValue(KEY_AUTO_BG_URL, url);themeHostEl = null;lastLuoguThemeImage = '';lastThemeInfo = { imageUrl: null, backColor: null, colorGradient: null, source: 'none' };applyCustomBg();console.log('[铍洛谷] 自动缓存 URL =', url || '(已清空)');};PAGE_WIN.__luoguBgForceDisable = function () {GM_setValue(KEY_ENABLED, false);currentEnabled = false;bumpPaintVersion();applyCustomBg();console.log('[铍洛谷] 已强制关闭');};PAGE_WIN.__luoguBgVerbose = function (on) {PAGE_WIN.__LUOGU_BG_VERBOSE = !!on;console.log('[铍洛谷] verbose =', PAGE_WIN.__LUOGU_BG_VERBOSE);};/* ============================================================* 启动* ============================================================ */function boot() {try {const themeData = extractLuoguThemeFromDoc(document);const parsed = themeData ? parseLBody(themeData.lBody) : null;if (parsed) lastLuoguThemeImage = parsed.imageUrl;applyCustomBg();startWatching();addValueListeners();if (isSettingPage()) tryInsertPanelWithWait();if (IS_MAIN_SITE && !getManualBgUrl()) {fetchThemeFromApi().then(url => {if (url && currentEnabled) {const old = GM_getValue(KEY_AUTO_BG_URL, '');if (old !== url) {GM_setValue(KEY_AUTO_BG_URL, url);applyCustomBg();}}});}console.log('[铍洛谷] v5.5 已启动。\n' +' 调试: __luoguBgDebug()\n' +' 悬停卡片调试: __luoguBgInspectUserCard()\n' +' 强制刷新: __luoguBgForceRefresh()\n' +' 重新拉取主题: __luoguBgFetchTheme()\n' +' fetch 拉取: __luoguBgFetchFromServer()\n' +' 强制关闭: __luoguBgForceDisable()');} catch (err) {console.error('[铍洛谷] boot 出错:', err);}}boot();let lastUrl = location.href;setInterval(() => {if (location.href !== lastUrl) {lastUrl = location.href;serverThemeAttempted = false;setTimeout(() => {try {applyCustomBg();startWatching();if (isSettingPage()) tryInsertPanelWithWait();if (IS_MAIN_SITE && !getManualBgUrl()) {fetchThemeFromApi().then(url => {if (url && currentEnabled) {const old = GM_getValue(KEY_AUTO_BG_URL, '');if (old !== url) {GM_setValue(KEY_AUTO_BG_URL, url);applyCustomBg();}}});}} catch (err) {console.error('[铍洛谷] URL 变化后重绘出错:', err);}}, 300);}}, 800);})();```::::::::info[脚本]```javascript// ==UserScript==// @name 铍洛谷// @namespace http://tampermonkey.net/// @version 5.5// @description 洛谷主站(含用户主页)+ 网校 + 有题 + image/paste/ticket 统一背景板// @author Breakon and DeepSeek// @match https://www.luogu.com.cn/*// @match https://class.luogu.com.cn/*// @match https://ti.luogu.com.cn/*// @grant GM_setValue// @grant GM_getValue// @grant GM_addValueChangeListener// @grant unsafeWindow// @run-at document-idle// ==/UserScript==(function () {'use strict';try {if (window.top !== window.self) return;} catch (e) {return;}const PAGE_WIN = (typeof unsafeWindow !== 'undefined') ? unsafeWindow : window;/* ============================================================* 常量* ============================================================ */const KEY_ENABLED = 'bg_custom_enabled';const KEY_COLOR = 'bg_custom_color';const KEY_ALPHA = 'bg_custom_alpha';const KEY_THEME_BG_URL = 'bg_theme_bg_url';const KEY_AUTO_BG_URL = 'bg_auto_bg_url';const KEY_AUTO_BG_BACK = 'bg_auto_back_color';const KEY_AUTO_BG_GRAD = 'bg_auto_gradient';const PANEL_ID = 'luogu-bg-panel';const STYLE_ID = 'luogu-bg-panel-style';const HITOKOTO_PANEL_ID = 'luogu-hitokoto-panel';const GLASS_STYLE_ID = 'luogu-glass-style';const GLASS_VAR_BG = '--luogu-glass-bg';const GLASS_VAR_BG_HD = '--luogu-glass-bg-hd';const GLASS_VAR_BORDER = '--luogu-glass-border';const GLASS_VAR_SHADOW = '--luogu-glass-shadow';const GLASS_VAR_TICKET_DIVIDER = '--luogu-glass-ticket-divider';const GLASS_VAR_FROSTED_BG = '--luogu-glass-frosted-bg'; /* ★ v5.5 */const PAINT_MARK = 'data-bg-painted';const ORIG_BG_ATTR = 'data-bg-orig-bg';const TICKET_TOPBAR_ATTR = 'data-ticket-topbar';const NAV_SOLID_ATTR = 'data-nav-solid';const SHELL_CLEARED_ATTR = 'data-shell-cleared';const INNER_TRANSPARENT_ATTR = 'data-luogu-inner-transparent';const FORCE_ID = 'luogu-glass-force';const FALLBACK_BG_IMAGE = 'https://cdn.luogu.com.cn/upload/image_hosting/e5xgx75m.webp';const INPUT_SKIP_CLASS = 'luogu-bg-skip';const GLASS_BORDER = '1px solid rgba(255, 255, 255, 0.55)';const GLASS_SHADOW = `0 8px 32px rgba(31, 38, 135, 0.12),0 2px 8px rgba(0, 0, 0, 0.05),inset 0 1px 0 rgba(255, 255, 255, 0.6)`;const USER_CARD_BLUR = 'blur(24px) saturate(180%)';const FEED_HEADER_DARKEN = 25;const FEED_HEADER_ALPHA_BOOST = 0.15;const HOST = location.hostname;const IS_MAIN_SITE = HOST === 'www.luogu.com.cn' || HOST === 'www.luogu.org';const IS_CLASS_SITE = HOST === 'class.luogu.com.cn';const IS_TI_SITE = HOST === 'ti.luogu.com.cn';const GRAY_MARK = 'data-darkened-gray';const DARK_GRAY = 'rgb(60, 60, 70)';const SKIP_TAGS = new Set(['INPUT', 'TEXTAREA', 'BUTTON', 'SELECT','IMG', 'SVG', 'PATH', 'IFRAME', 'VIDEO', 'CANVAS','SCRIPT', 'STYLE', 'LINK', 'META', 'HR', 'BR',]);const INLINE_TAGS = new Set(['SPAN', 'A', 'B', 'I', 'EM', 'STRONG', 'SMALL','CODE', 'KBD', 'TIME', 'LABEL', 'CITE', 'Q', 'S', 'U','SUB', 'SUP', 'MARK',]);const FLOATING_EXCLUDE = ['.v-popper__popper', '.v-popper__inner','[class*="popper"]', '[class*="popup"]', '[class*="popover"]','[class*="tooltip"]', '[class*="dropdown"]','.dropdown','[role="tooltip"]', '[role="menu"]','[aria-hidden="true"]',].join(', ');const CONTENT_EXCLUDE = ['.markdown-body','.lfe-markdown','.lg-article-content','.article-content','.feed-comment','.am-comment-bd','[class*="markdown-body"]','[class*="markdown-content"]',].join(', ');const NAV_SELECTOR = ['.top-bar','nav.sidebar','nav.sidebar.lside','.sidebar.lside.bar','.user-nav.rside','#app-sidenav','#app-header',].join(', ');const SHELL_SELECTOR = ['.theme-page','.theme-mid-full','.theme-mid','.main-container','.columba-content-wrap','.main-content','#app','#app-old','.lg-index-content','.lfe-body','main',].join(', ');const CSS_OWNED_SELECTOR = ['.tag-button','.refined-input.search-text','.list-scroll',].join(', ');const CSS_OWNED_SUBTREE = ['.refined-input.search-text','.list-scroll',].join(', ');const CARD_SELECTOR_RAW = ['.l-card', '.lg-article', '.lg-index-stat', '.lg-index-contest','.am-panel', '.n-card', '.training-card', '.category-card','.srqc', '.course-card', '.lesson-card', '.chapter-card','.class-card', '.problemsets', '.problemset-item','.lg-punch',].join(', ');const TEXT_DARKEN_SELECTOR = ['a', 'span', 'strong', 'em', 'small', 'p', 'i', 'b','div', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6','li', 'td', 'th', 'dt', 'dd', 'label', 'time','blockquote', 'figcaption', 'cite', 'q', 'mark','section', 'article', 'header', 'footer', 'aside',].join(', ');/* ★ v5.5:弹窗容器选择器,用于识别模态类 .l-card */const MODAL_CARD_SELECTOR = ['.l-card.container.type-burger','.l-card.container.type-dialog','.l-card.container.type-popup','.l-card.container[class*="type-"]','.l-card[class*="container"][class*="type-"]','.l-modal .l-card','.l-modal__body .l-card','.v-modal .l-card','[class*="modal"] > .l-card','[class*="dialog"] > .l-card','[class*="popup"] > .l-card',].join(', ');/* ============================================================* 状态* ============================================================ */function readAlpha() {let v = parseFloat(GM_getValue(KEY_ALPHA, 0.78));if (isNaN(v) || v <= 0.01) v = 0.78;return Math.min(1, Math.max(0.05, v));}let currentEnabled = !!GM_getValue(KEY_ENABLED, false);let currentColor = GM_getValue(KEY_COLOR, '#232329') || '#232329';let currentAlpha = readAlpha();let lastThemeInfo = { imageUrl: null, backColor: null, colorGradient: null, source: 'none' };let themeHostEl = null;let paintVersion = 0;let paintedElements = new WeakMap();let darkenedElements = new WeakSet();let preferenceFetched = false;let preferenceFetching = false;let serverThemeFetched = false;let serverThemeFetching = false;let serverThemeAttempted = false;let luoguThemePollTimer = null;let lastLuoguThemeImage = '';let userCardGlassTimer = null;let modalGlassTimer = null; /* ★ v5.5 *//* ============================================================* 工具* ============================================================ */function hexToRgb(hex) {let h = String(hex || '#232329').replace('#', '').trim();if (h.length === 3) h = h.split('').map(c => c + c).join('');if (h.length !== 6 || /[^0-9a-fA-F]/.test(h)) h = '232329';return {r: parseInt(h.slice(0, 2), 16) || 0,g: parseInt(h.slice(2, 4), 16) || 0,b: parseInt(h.slice(4, 6), 16) || 0,};}function buildBgValue(hex, alpha) {const { r, g, b } = hexToRgb(hex);return `rgba(${r}, ${g}, ${b}, ${alpha})`;}function buildFeedHeaderBg(hex, alpha) {const { r, g, b } = hexToRgb(hex);const dr = Math.max(0, r - FEED_HEADER_DARKEN);const dg = Math.max(0, g - FEED_HEADER_DARKEN);const db = Math.max(0, b - FEED_HEADER_DARKEN);const a = Math.min(1, alpha + FEED_HEADER_ALPHA_BOOST);return `rgba(${dr}, ${dg}, ${db}, ${a})`;}function buildTicketDividerColor(hex) {const { r, g, b } = hexToRgb(hex);const lum = 0.299 * r + 0.587 * g + 0.114 * b;if (lum > 128) return 'rgba(0, 0, 0, 0.55)';return 'rgba(255, 255, 255, 0.55)';}/* ★ v5.5:根据当前 alpha 计算毛玻璃用的低透明度值 */function buildFrostedBgValue(hex, alpha) {const frostedAlpha = Math.max(0.18, Math.min(0.55, alpha * 0.55));return buildBgValue(hex, frostedAlpha);}function parseRgb(str) {if (!str) return null;const m = str.match(/rgba?\(\s*(\d+)\s*[,\s]\s*(\d+)\s*[,\s]\s*(\d+)/);if (!m) return null;return { r: +m[1], g: +m[2], b: +m[3] };}function parseUrlFromCssValue(raw) {if (!raw) return null;const s = String(raw).trim();if (!s || s === 'none' || s === 'initial' || s === 'unset' || s === 'inherit') return null;const m = s.match(/url\(\s*["']?([^"')]+)["']?\s*\)/);return m && m[1] ? m[1].trim() : null;}function readVarFrom(el, name) {if (!el) return '';try { return getComputedStyle(el).getPropertyValue(name).trim(); } catch (e) { return ''; }}function readAllThemeVarsFrom(el) {if (!el) return { image: '', back: '', gradient: '' };return {image: readVarFrom(el, '--theme-body-image'),back: readVarFrom(el, '--theme-body-back'),gradient: readVarFrom(el, '--theme-body-color'),};}function isVarsNonEmpty(vars) {const imgOk = !!parseUrlFromCssValue(vars.image);const backOk = vars.back && vars.back !== 'none' && vars.back !== '';const gradOk = vars.gradient && vars.gradient !== 'none' && vars.gradient !== '';return imgOk || backOk || gradOk;}function findUrlInObject(obj, depth) {depth = depth || 0;if (depth > 6 || !obj) return null;if (typeof obj === 'string') {if (/^https?:\/\/.*\.(webp|jpg|jpeg|png|gif|svg)(\?|$)/i.test(obj.trim())) {return obj.trim();}const m = obj.match(/url\(\s*["']?(https?:\/\/[^"')]+)["']?\s*\)/);if (m && m[1]) return m[1].trim();return null;}if (Array.isArray(obj)) {for (const item of obj) {const u = findUrlInObject(item, depth + 1);if (u) return u;}return null;}if (typeof obj === 'object') {for (const k of Object.keys(obj)) {if (/image|background|bg/i.test(k)) {const u = findUrlInObject(obj[k], depth + 1);if (u) return u;}}for (const k of Object.keys(obj)) {if (/image|background|bg/i.test(k)) continue;if (/avatar|icon|logo/i.test(k)) continue;const u = findUrlInObject(obj[k], depth + 1);if (u) return u;}}return null;}function extractLuoguThemeFromDoc(doc) {try {const el = doc.getElementById('luogu-theme');if (!el) return null;return JSON.parse(el.textContent);} catch (e) {return null;}}function extractLuoguThemeFromHtml(html) {if (!html || typeof html !== 'string') return null;const m = html.match(/<script[^>]*id=["']luogu-theme["'][^>]*>([\s\S]*?)<\/script>/);if (!m || !m[1]) return null;try {return JSON.parse(m[1]);} catch (e) {return null;}}function parseLBody(lBody) {if (!lBody) return null;const imageUrl = lBody.image;if (!imageUrl || !/^https?:\/\//i.test(imageUrl)) return null;const backColor = (typeof lBody.back === 'string' && lBody.back) ? lBody.back : null;const colorArr = Array.isArray(lBody.color) ? lBody.color : null;const grad = (colorArr && colorArr.length >= 2)? `linear-gradient(167deg, ${colorArr.join(', ')})`: null;return { imageUrl, backColor, colorGradient: grad };}/* ============================================================* 主题变量提取* ============================================================ */function getManualBgUrl() {const u = (GM_getValue(KEY_THEME_BG_URL, '') || '').trim();return u || null;}function getAutoBgUrl() {const u = (GM_getValue(KEY_AUTO_BG_URL, '') || '').trim();return u || null;}function readThemeVarsFromPage() {const candidates = [];if (themeHostEl && document.contains(themeHostEl)) candidates.push(themeHostEl);const selectors = ['.theme-page', '.theme-mid-full', '.theme-mid','.columba-content-wrap', '.main-container','#app', '#app-old', 'main', 'body', 'html',];for (const sel of selectors) {const el = sel === 'html' ? document.documentElement : document.querySelector(sel);if (el && !candidates.includes(el)) candidates.push(el);}for (const el of candidates) {if (!el) continue;const vars = readAllThemeVarsFrom(el);const u = parseUrlFromCssValue(vars.image);if (u) {themeHostEl = el;return {imageUrl: u,backColor: (vars.back && vars.back !== 'none') ? vars.back : null,colorGradient: (vars.gradient && vars.gradient !== 'none') ? vars.gradient : null,};}}const lsUrl = tryReadThemeFromLocalStorage();if (lsUrl) {return { imageUrl: lsUrl, backColor: null, colorGradient: null };}return { imageUrl: null, backColor: null, colorGradient: null };}function tryReadThemeFromLocalStorage() {const fixedKeys = ['luogu-theme', 'LFE_THEME', 'lfe-theme','columba-theme', 'lentille-theme','theme', 'theme-data', 'themeData','luogu-theme-store', 'theme-store',];for (const key of fixedKeys) {const url = tryExtractUrlFromStorage(key);if (url) return url;}try {const n = localStorage.length;for (let i = 0; i < n; i++) {const key = localStorage.key(i);if (!key) continue;if (!/theme|columba|lentille|background|wallpaper/i.test(key)) continue;if (fixedKeys.includes(key)) continue;const url = tryExtractUrlFromStorage(key);if (url) return url;}} catch (e) {}return null;}function tryExtractUrlFromStorage(key) {let raw;try { raw = localStorage.getItem(key); } catch (e) { return null; }if (!raw) return null;const trimmed = raw.trim();if (!trimmed) return null;if (/^https?:\/\//i.test(trimmed) &&/\.(webp|jpg|jpeg|png|gif)(\?|$)/i.test(trimmed)) {return trimmed;}const m = trimmed.match(/--theme-body-image\s*:\s*url\(\s*["']?([^"')]+)["']?\s*\)/);if (m && m[1]) return m[1].trim();const m2 = trimmed.match(/url\(\s*["']?(https?:\/\/[^"')]+)["']?\s*\)/);if (m2 && m2[1]) return m2[1].trim();try {const obj = JSON.parse(trimmed);const u = findUrlInObject(obj);if (u) return u;} catch (e) {}return null;}async function fetchThemeFromPreference() {if (preferenceFetched || preferenceFetching) return;if (!IS_MAIN_SITE) return;preferenceFetching = true;try {const resp = await fetch('/user/setting/preference', {credentials: 'same-origin',headers: { 'Accept': 'text/html' },});preferenceFetched = true;if (!resp.ok) return;const html = await resp.text();const themeData = extractLuoguThemeFromHtml(html);const parsed = themeData ? parseLBody(themeData.lBody) : null;if (parsed && parsed.imageUrl !== GM_getValue(KEY_AUTO_BG_URL, '')) {GM_setValue(KEY_AUTO_BG_URL, parsed.imageUrl);if (parsed.backColor) GM_setValue(KEY_AUTO_BG_BACK, parsed.backColor);if (parsed.colorGradient) GM_setValue(KEY_AUTO_BG_GRAD, parsed.colorGradient);applyCustomBg();}} catch (e) {} finally {preferenceFetching = false;}}async function fetchThemeFromApi(force) {if (serverThemeFetching) return null;if (serverThemeFetched && !force) return null;if (serverThemeAttempted && !force) return null;if (!IS_MAIN_SITE) return null;serverThemeFetching = true;serverThemeAttempted = true;try {let themeData = extractLuoguThemeFromDoc(document);let source = 'current-doc';if (!themeData) {const resp = await fetch('/theme', {credentials: 'same-origin',headers: { 'Accept': 'text/html' },});if (!resp.ok) return null;const html = await resp.text();themeData = extractLuoguThemeFromHtml(html);source = 'fetched-html';}if (!themeData) return null;const parsed = parseLBody(themeData.lBody);if (!parsed) return null;if (parsed.backColor) GM_setValue(KEY_AUTO_BG_BACK, parsed.backColor);if (parsed.colorGradient) GM_setValue(KEY_AUTO_BG_GRAD, parsed.colorGradient);serverThemeFetched = true;if (PAGE_WIN.__LUOGU_BG_VERBOSE) {console.log('[铍洛谷] 从', source, '提取到主题背景:', parsed.imageUrl);}return parsed.imageUrl;} catch (e) {return null;} finally {serverThemeFetching = false;}}function getThemeBackgroundInfo() {const manual = getManualBgUrl();if (manual) {return { imageUrl: manual, backColor: null, colorGradient: null, source: 'manual' };}const themeData = extractLuoguThemeFromDoc(document);const parsed = themeData ? parseLBody(themeData.lBody) : null;if (parsed) {const old = GM_getValue(KEY_AUTO_BG_URL, '');if (old !== parsed.imageUrl) {GM_setValue(KEY_AUTO_BG_URL, parsed.imageUrl);}if (parsed.backColor) GM_setValue(KEY_AUTO_BG_BACK, parsed.backColor);if (parsed.colorGradient) GM_setValue(KEY_AUTO_BG_GRAD, parsed.colorGradient);return {imageUrl: parsed.imageUrl,backColor: parsed.backColor,colorGradient: parsed.colorGradient,source: 'luogu-theme',};}const live = readThemeVarsFromPage();if (live.imageUrl) {const old = GM_getValue(KEY_AUTO_BG_URL, '');if (old !== live.imageUrl) {GM_setValue(KEY_AUTO_BG_URL, live.imageUrl);}return { ...live, source: 'live' };}const auto = getAutoBgUrl();if (auto) {const autoBack = GM_getValue(KEY_AUTO_BG_BACK, '');const autoGrad = GM_getValue(KEY_AUTO_BG_GRAD, '');return {imageUrl: auto,backColor: autoBack || null,colorGradient: autoGrad || null,source: 'auto-cache',};}return { imageUrl: null, backColor: null, colorGradient: null, source: 'none' };}/* ============================================================* 路径判断* ============================================================ */function isSettingPage() {return IS_MAIN_SITE && location.href.includes('/user/setting/preference');}function isImagePage() {return IS_MAIN_SITE && /^\/image(\/|$)/.test(location.pathname);}function isPastePage() {return IS_MAIN_SITE && /^\/paste(\/|$)/.test(location.pathname);}function isTicketPage() {return IS_MAIN_SITE && /^\/ticket(\/|$)/.test(location.pathname);}function isArticleDetailPage() {if (!IS_MAIN_SITE) return false;const p = location.pathname;return /^\/article\/[^\/]+\/?$/.test(p) && !/^\/article\/(mine|_new)\/?$/.test(p);}function isHomePage() {if (!IS_MAIN_SITE) return false;const p = location.pathname;return p === '/' || p === '' || p === '/index';}function isGlassApplyPage() {return IS_MAIN_SITE && (/^\/user\/setting(\/|$)/.test(location.pathname) ||/^\/theme(\/|$)/.test(location.pathname) ||/^\/paste(\/|$)/.test(location.pathname) ||/^\/article(\/|$)/.test(location.pathname) ||/^\/training(\/|$)/.test(location.pathname) ||/^\/problem(\/|$)/.test(location.pathname) ||/^\/benben(\/|$)/.test(location.pathname) ||/^\/chat(\/|$)/.test(location.pathname) ||/^\/contest(\/|$)/.test(location.pathname));}/* ============================================================* CSS 变量同步* ============================================================ */function syncGlassVars() {const root = document.documentElement;root.style.setProperty(GLASS_VAR_BG, buildBgValue(currentColor, currentAlpha));root.style.setProperty(GLASS_VAR_BG_HD, buildFeedHeaderBg(currentColor, currentAlpha));root.style.setProperty(GLASS_VAR_BORDER, GLASS_BORDER);root.style.setProperty(GLASS_VAR_SHADOW, GLASS_SHADOW);root.style.setProperty(GLASS_VAR_TICKET_DIVIDER, buildTicketDividerColor(currentColor));/* ★ v5.5:毛玻璃弹窗专用背景(低 alpha,配合 backdrop-filter 用) */root.style.setProperty(GLASS_VAR_FROSTED_BG, buildFrostedBgValue(currentColor, currentAlpha));}function clearGlassVars() {const root = document.documentElement;root.style.removeProperty(GLASS_VAR_BG);root.style.removeProperty(GLASS_VAR_BG_HD);root.style.removeProperty(GLASS_VAR_BORDER);root.style.removeProperty(GLASS_VAR_SHADOW);root.style.removeProperty(GLASS_VAR_TICKET_DIVIDER);root.style.removeProperty(GLASS_VAR_FROSTED_BG); /* ★ v5.5 */}/* ============================================================* 内联画背景* ============================================================ */function paintBackgroundInline() {if (!currentEnabled) return;const body = document.body;if (!body) return;const root = document.documentElement;const info = lastThemeInfo;const imageUrl = info.imageUrl || FALLBACK_BG_IMAGE;if (info.backColor && info.backColor !== 'transparent') {root.style.setProperty('background-color', info.backColor, 'important');} else {root.style.setProperty('background-color', 'transparent', 'important');}const layers = [];if (imageUrl) layers.push(`url("${imageUrl}")`);if (info.colorGradient && info.colorGradient !== 'none') {layers.push(info.colorGradient);}const n = layers.length;if (n > 0) {const rep = Array(n).fill('cover').join(', ');const pos = Array(n).fill('center').join(', ');const rpt = Array(n).fill('no-repeat').join(', ');const att = Array(n).fill('fixed').join(', ');root.style.setProperty('background-image', layers.join(', '), 'important');root.style.setProperty('background-size', rep, 'important');root.style.setProperty('background-position', pos, 'important');root.style.setProperty('background-repeat', rpt, 'important');root.style.setProperty('background-attachment', att, 'important');} else {root.style.setProperty('background-image', 'none', 'important');root.style.removeProperty('background-attachment');}body.style.setProperty('background', 'transparent', 'important');const shells = document.querySelectorAll(SHELL_SELECTOR);shells.forEach(el => {if (el.matches && el.matches(NAV_SELECTOR)) return;el.style.setProperty('background', 'transparent', 'important');el.style.setProperty('background-color', 'transparent', 'important');el.style.setProperty('background-image', 'none', 'important');el.setAttribute(SHELL_CLEARED_ATTR, '1');});}function clearPaintedBackground() {const root = document.documentElement;const body = document.body;['background-color', 'background-image', 'background-size','background-position', 'background-repeat', 'background-attachment'].forEach(p => root.style.removeProperty(p));if (body) body.style.removeProperty('background');document.querySelectorAll(`[${SHELL_CLEARED_ATTR}]`).forEach(el => {el.style.removeProperty('background');el.style.removeProperty('background-color');el.style.removeProperty('background-image');el.removeAttribute(SHELL_CLEARED_ATTR);});}/* ============================================================* 输入框玻璃化* ============================================================ */function buildInputGlassRules() {const inputSel = ['input[type="text"]', 'input[type="search"]', 'input[type="email"]','input[type="password"]', 'input[type="url"]', 'input[type="number"]','input[type="tel"]', 'input:not([type])', 'textarea','.am-form-field', '.l-input', '.lfe-input',].join(', ');return `main :is(${inputSel}):not(.${INPUT_SKIP_CLASS}):not(#${FORCE_ID}):not([type="hidden"]):not([type="color"]):not([type="range"]):not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="submit"]):not([type="button"]):not([type="reset"]) {background-color: rgba(255, 255, 255, 0.45) !important;background-image: none !important;border: 1px solid rgba(255, 255, 255, 0.65) !important;border-radius: 8px !important;box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.06) !important;backdrop-filter: none !important;-webkit-backdrop-filter: none !important;transition: background-color 0.2s ease,border-color 0.2s ease,box-shadow 0.2s ease;}main :is(${inputSel}):not(.${INPUT_SKIP_CLASS}):not(#${FORCE_ID}):not([type="hidden"]):not([type="color"]):not([type="range"]):not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="submit"]):not([type="button"]):not([type="reset"]):hover {background-color: rgba(255, 255, 255, 0.55) !important;border-color: rgba(255, 255, 255, 0.8) !important;}main :is(${inputSel}):not(.${INPUT_SKIP_CLASS}):not(#${FORCE_ID}):not([type="hidden"]):not([type="color"]):not([type="range"]):not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="submit"]):not([type="button"]):not([type="reset"]):focus {background-color: rgba(255, 255, 255, 0.75) !important;border-color: rgba(52, 152, 219, 0.8) !important;box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.18),inset 0 1px 2px rgba(0, 0, 0, 0.06) !important;outline: none !important;}main .am-input-group:not(#${FORCE_ID}),main .am-input-group:not(#${FORCE_ID}) .am-input-group-label,main .am-input-group:not(#${FORCE_ID}) .am-input-group-btn,main .image-input:not(#${FORCE_ID}) {background-color: transparent !important;background-image: none !important;}`;}/* ============================================================* 题目列表专属元素 + 横向滚动条玻璃化 + 搜索框文字加深* ============================================================ */function buildProblemListGlassRules() {return `.tag-button:not(#${FORCE_ID}) {background-color: var(${GLASS_VAR_BG}) !important;background-image: none !important;border: var(${GLASS_VAR_BORDER}) !important;box-shadow: var(${GLASS_VAR_SHADOW}) !important;backdrop-filter: none !important;-webkit-backdrop-filter: none !important;transition: background-color 0.2s ease,border-color 0.2s ease,box-shadow 0.2s ease;}.tag-button:not(#${FORCE_ID}):hover {background-color: rgba(255, 255, 255, 0.6) !important;border-color: rgba(255, 255, 255, 0.85) !important;}.refined-input.search-text:not(#${FORCE_ID}) {background-color: var(${GLASS_VAR_BG}) !important;background-image: none !important;border: var(${GLASS_VAR_BORDER}) !important;box-shadow: var(${GLASS_VAR_SHADOW}) !important;backdrop-filter: none !important;-webkit-backdrop-filter: none !important;border-radius: 0 !important;}.refined-input.search-text:not(#${FORCE_ID}) input,.refined-input.search-text:not(#${FORCE_ID}) input:not(#${FORCE_ID}),.refined-input.search-text:not(#${FORCE_ID}) input[type="text"],.refined-input.search-text:not(#${FORCE_ID}) input.search-text,.refined-input.search-text:not(#${FORCE_ID}) input:hover,.refined-input.search-text:not(#${FORCE_ID}) input:focus {background: transparent !important;background-color: transparent !important;background-image: none !important;border: none !important;border-radius: 0 !important;box-shadow: none !important;outline: none !important;}.refined-input.search-text:not(#${FORCE_ID}) > *,.refined-input.search-text:not(#${FORCE_ID}) .east,.refined-input.search-text:not(#${FORCE_ID}) .east *,.refined-input.search-text:not(#${FORCE_ID}) .search-icon {background: transparent !important;background-color: transparent !important;background-image: none !important;box-shadow: none !important;}.refined-input.search-text:not(#${FORCE_ID}) .search-icon {color: #2c3e50 !important;}section .search-option .lfe-caption,section .search-option .lfe-caption label,section .search-option .lfe-caption span,section .search-option .lfe-caption label svg {color: #2c3e50 !important;}section .search-option .lfe-caption input[type="checkbox"] {color: inherit;}.refined-input.text:not(#${FORCE_ID}):not(.search-text) *,.refined-input.text:not(#${FORCE_ID}):not(.search-text)::before,.refined-input.text:not(#${FORCE_ID}):not(.search-text)::after,.refined-input.text:not(#${FORCE_ID}):not(.search-text) > *::before,.refined-input.text:not(#${FORCE_ID}):not(.search-text) > *::after {background-color: transparent !important;background-image: none !important;border-color: transparent !important;box-shadow: none !important;backdrop-filter: none !important;-webkit-backdrop-filter: none !important;}.refined-input.text:not(#${FORCE_ID}):not(.search-text) input,.refined-input.text:not(#${FORCE_ID}):not(.search-text) input:hover,.refined-input.text:not(#${FORCE_ID}):not(.search-text) input:focus {background-color: transparent !important;background-image: none !important;border: none !important;border-radius: 0 !important;box-shadow: none !important;outline: none !important;}.refined-input.text:not(#${FORCE_ID}):not(.search-text) .search-icon {color: #2c3e50 !important;}.solution-filter.lfe-caption,.solution-filter.lfe-caption label,.solution-filter.lfe-caption span,.solution-filter.lfe-caption label svg {color: #2c3e50 !important;}.solution-filter.lfe-caption input[type="checkbox"] {color: inherit;}.list-scroll:not(#${FORCE_ID}),.list-scroll.overflow:not(#${FORCE_ID}) {scrollbar-width: thin;scrollbar-color: rgba(255, 255, 255, 0.65) rgba(255, 255, 255, 0.2);}.list-scroll:not(#${FORCE_ID})::-webkit-scrollbar {width: 10px; height: 10px; background: transparent;}.list-scroll:not(#${FORCE_ID})::-webkit-scrollbar:horizontal { height: 10px; }.list-scroll:not(#${FORCE_ID})::-webkit-scrollbar:vertical { width: 10px; }.list-scroll:not(#${FORCE_ID})::-webkit-scrollbar-track {background: rgba(255, 255, 255, 0.18) !important;border-radius: 5px;border: 1px solid rgba(255, 255, 255, 0.3);}.list-scroll:not(#${FORCE_ID})::-webkit-scrollbar-thumb {background: rgba(255, 255, 255, 0.55) !important;background-image: linear-gradient(180deg, rgba(255,255,255,0.75), rgba(255,255,255,0.4)) !important;border: 1px solid rgba(255, 255, 255, 0.7) !important;border-radius: 5px;box-shadow: inset 0 1px 0 rgba(255,255,255,0.8), 0 1px 3px rgba(31,38,135,0.08);}.list-scroll:not(#${FORCE_ID})::-webkit-scrollbar-thumb:hover {background: rgba(255, 255, 255, 0.75) !important;}.list-scroll:not(#${FORCE_ID})::-webkit-scrollbar-corner { background: transparent; }.list-scroll:not(#${FORCE_ID}) .list-wrap:not(#${FORCE_ID}),.list-scroll:not(#${FORCE_ID}) .header-wrap:not(#${FORCE_ID}),.list-scroll:not(#${FORCE_ID}) .row-wrap:not(#${FORCE_ID}),.list-scroll:not(#${FORCE_ID}) .row:not(#${FORCE_ID}) {background-color: transparent !important;background-image: none !important;}`;}/* ============================================================* 用户名悬停卡片 —— CSS 层面兜底(JS 内联是主方案)* ============================================================ */function buildUserCardGlassRules() {return `body .l-card.float-card:not(#${FORCE_ID}),body .dropdown.shown .l-card:not(#${FORCE_ID}),body .dropdown.shown > .l-card.float-card:not(#${FORCE_ID}),body .dropdown .l-card.float-card:not(#${FORCE_ID}) {background-color: var(${GLASS_VAR_BG}) !important;background-image: none !important;border: 1px solid rgba(255, 255, 255, 0.55) !important;box-shadow: 0 8px 32px rgba(31, 38, 135, 0.2),0 2px 8px rgba(0, 0, 0, 0.08),inset 0 1px 0 rgba(255, 255, 255, 0.6) !important;backdrop-filter: ${USER_CARD_BLUR} !important;-webkit-backdrop-filter: ${USER_CARD_BLUR} !important;border-radius: 12px !important;}body .l-card.float-card:not(#${FORCE_ID}) .user-info,body .l-card.float-card:not(#${FORCE_ID}) .user-action {background-color: transparent !important;background-image: none !important;}`;}/* ============================================================* ★ v5.5:弹窗 / 模态框毛玻璃* ============================================================ */function buildModalGlassRules() {return `/* 弹窗容器:真正的毛玻璃 */${MODAL_CARD_SELECTOR.split(',').map(s => s.trim() + ':not(#' + FORCE_ID + ')').join(',\n ')} {background-color: var(${GLASS_VAR_FROSTED_BG}) !important;background-image: none !important;backdrop-filter: ${USER_CARD_BLUR} !important;-webkit-backdrop-filter: ${USER_CARD_BLUR} !important;border: var(${GLASS_VAR_BORDER}) !important;box-shadow: 0 16px 48px rgba(31, 38, 135, 0.22),0 4px 12px rgba(0, 0, 0, 0.08),inset 0 1px 0 rgba(255, 255, 255, 0.6) !important;border-radius: 12px !important;}/* 弹窗内部结构透明,露出毛玻璃 */${MODAL_CARD_SELECTOR.split(',').map(s => s.trim() + ':not(#' + FORCE_ID + ') > *').join(',\n ')},${MODAL_CARD_SELECTOR.split(',').map(s => s.trim() + ':not(#' + FORCE_ID + ') > * > *').join(',\n ')},${MODAL_CARD_SELECTOR.split(',').map(s => s.trim() + ':not(#' + FORCE_ID + ') form').join(',\n ')},${MODAL_CARD_SELECTOR.split(',').map(s => s.trim() + ':not(#' + FORCE_ID + ') .l-form-layout').join(',\n ')},${MODAL_CARD_SELECTOR.split(',').map(s => s.trim() + ':not(#' + FORCE_ID + ') .radio-group').join(',\n ')},${MODAL_CARD_SELECTOR.split(',').map(s => s.trim() + ':not(#' + FORCE_ID + ') .radio-group > *').join(',\n ')} {background-color: transparent !important;background-image: none !important;}/* 弹窗标题栏字符保持白色高对比 */${MODAL_CARD_SELECTOR.split(',').map(s => s.trim() + ':not(#' + FORCE_ID + ') .lfe-h3').join(',\n ')},${MODAL_CARD_SELECTOR.split(',').map(s => s.trim() + ':not(#' + FORCE_ID + ') h3').join(',\n ')} {color: #f0f0f5 !important;text-shadow: 0 1px 2px rgba(0,0,0,0.35) !important;}${MODAL_CARD_SELECTOR.split(',').map(s => s.trim() + ':not(#' + FORCE_ID + ') .l-form-layout > span').join(',\n ')},${MODAL_CARD_SELECTOR.split(',').map(s => s.trim() + ':not(#' + FORCE_ID + ') label').join(',\n ')} {color: #e8e8f0 !important;}${MODAL_CARD_SELECTOR.split(',').map(s => s.trim() + ':not(#' + FORCE_ID + ') .close svg').join(',\n ')} {color: #e8e8f0 !important;cursor: pointer;}`;}/* ============================================================* 玻璃 CSS* ============================================================ */function injectGlassCSS() {let styleEl = document.getElementById(GLASS_STYLE_ID);if (!styleEl) {styleEl = document.createElement('style');styleEl.id = GLASS_STYLE_ID;document.head.appendChild(styleEl);}if (!currentEnabled) {if (styleEl.textContent !== '') styleEl.textContent = '';return;}const imageRules = isImagePage() ? `.image-card, .image-item,[class*="image-card"], [class*="image-item"] {background-color: var(${GLASS_VAR_BG}) !important;background-image: none !important;border: var(${GLASS_VAR_BORDER}) !important;box-shadow: var(${GLASS_VAR_SHADOW}) !important;backdrop-filter: none !important;-webkit-backdrop-filter: none !important;}` : '';const pasteRules = isPastePage() ? `.code-block, .paste-code,.am-pre-scrollable, .markdown-body pre,[class*="paste-code"], [class*="code-block"] {background-color: var(${GLASS_VAR_BG}) !important;background-image: none !important;border: var(${GLASS_VAR_BORDER}) !important;box-shadow: var(${GLASS_VAR_SHADOW}) !important;border-radius: 8px !important;backdrop-filter: none !important;-webkit-backdrop-filter: none !important;}` : '';const ticketRules = isTicketPage() ? `.ticket-card {background-color: transparent !important;background-image: none !important;border-color: transparent !important;box-shadow: none !important;backdrop-filter: none !important;-webkit-backdrop-filter: none !important;}.ticket-card > *,.list-wrap, .list-wrap > *,.row-wrap, .row-wrap > *,.wrapper, .wrapper > *,.left-status, .left-status > * {background-color: transparent !important;background-image: none !important;box-shadow: none !important;}.list-wrap:not(#${FORCE_ID}) > .row-wrap:not(#${FORCE_ID}):not(:first-child),.list-wrap:not(#${FORCE_ID}) > .row:not(#${FORCE_ID}):not(:first-child) {border-top: 1px solid var(${GLASS_VAR_TICKET_DIVIDER}, rgba(128, 128, 128, 0.6)) !important;margin-top: 16px !important;padding-top: 16px !important;}.list-wrap:not(#${FORCE_ID}) > .row:not(#${FORCE_ID}) {border-bottom: none !important;}` : '';const classSiteRules = IS_CLASS_SITE ? `.fix nav.hidden, .fix .hidden { display: none !important; }` : '';const tiRules = IS_TI_SITE ? `#app-header, #app-body, #app-footer,.width-wrap, .full-container {background-color: transparent !important;background-image: none !important;box-shadow: none !important;border-color: transparent !important;}.bg-wrap:not(#${FORCE_ID}),.bg-wrap:not(#${FORCE_ID}) .bg {background: transparent !important;background-color: transparent !important;background-image: none !important;border: none !important;box-shadow: none !important;backdrop-filter: none !important;-webkit-backdrop-filter: none !important;}.problemsets.card, .problemsets {background-color: var(${GLASS_VAR_BG}) !important;background-image: none !important;border: var(${GLASS_VAR_BORDER}) !important;box-shadow: var(${GLASS_VAR_SHADOW}) !important;border-radius: 12px !important;}.problemsets .problemset-item,.problemsets .row,.problemsets .problemset-item *,.problemsets .row * {background-color: transparent !important;background-image: none !important;box-shadow: none !important;}` : '';const navSolidRules = `.top-bar:not(#${FORCE_ID}),nav.sidebar:not(#${FORCE_ID}),nav.sidebar.lside:not(#${FORCE_ID}),.sidebar.lside.bar:not(#${FORCE_ID}),.user-nav.rside:not(#${FORCE_ID}),#app-sidenav:not(#${FORCE_ID}),#app-header:not(#${FORCE_ID}) {background-color: var(--theme-navi-back, #1f1f28) !important;background-image: none !important;backdrop-filter: none !important;-webkit-backdrop-filter: none !important;}`;const pseudoMaskRules = `.theme-page:not(#${FORCE_ID})::before,.theme-page:not(#${FORCE_ID})::after,.theme-mid-full:not(#${FORCE_ID})::before,.theme-mid-full:not(#${FORCE_ID})::after,.theme-mid:not(#${FORCE_ID})::before,.theme-mid:not(#${FORCE_ID})::after,#app:not(#${FORCE_ID})::before,#app:not(#${FORCE_ID})::after,#app-old:not(#${FORCE_ID})::before,#app-old:not(#${FORCE_ID})::after,body:not(#${FORCE_ID})::before,body:not(#${FORCE_ID})::after {background: transparent !important;background-color: transparent !important;background-image: none !important;box-shadow: none !important;backdrop-filter: none !important;-webkit-backdrop-filter: none !important;}`;const helperTextRules = `.lg-small:not(#${FORCE_ID}):not([class*="lg-fg-"]):not([class*="lcolor--"]) {color: rgb(60, 60, 70) !important;}`;const inputGlassRules = buildInputGlassRules();const problemListGlassRules = buildProblemListGlassRules();const userCardGlassRules = buildUserCardGlassRules();const modalGlassRules = buildModalGlassRules(); /* ★ v5.5 */const content = `${navSolidRules}${pseudoMaskRules}${helperTextRules}.l-card, .lg-article, .lg-index-stat, .lg-index-contest,.am-panel, .n-card, .training-card, .category-card,.srqc, .course-card, .lesson-card, .chapter-card,.class-card, .problemsets, .problemset-item {background-color: var(${GLASS_VAR_BG}) !important;background-image: none !important;}.lg-punch {background-color: transparent !important;background-image: none !important;}.l-card > div:not(.user-header-top),.l-card > section, .l-card > header, .l-card > footer,.l-card > ul, .l-card > li,.l-card .list-scroll, .l-card .list-wrap, .l-card .header-wrap,.l-card .header, .l-card .row-wrap, .l-card .row, .l-card .block,.l-card .filter-section, .l-card .search-row, .l-card .combo-wrapper,.l-card .toolbar, .l-card .result,.lg-article > div, .lg-article > section,.n-card > .n-card-header, .n-card > .n-card__content, .n-card > .n-card__footer,.am-panel > .am-panel-hd, .am-panel > .am-panel-bd, .am-panel > .am-panel-ft {background-color: transparent !important;background-image: none !important;}footer, .footer, [class*="footer"] {background-color: transparent !important;background-image: none !important;border: none !important;box-shadow: none !important;}.am-comment-main {background-color: var(${GLASS_VAR_BG}) !important;background-image: none !important;}.am-comment-hd {background-color: var(${GLASS_VAR_BG_HD}) !important;background-image: none !important;backdrop-filter: none !important;-webkit-backdrop-filter: none !important;border-bottom: var(${GLASS_VAR_BORDER}) !important;box-shadow: var(${GLASS_VAR_SHADOW}) !important;border-radius: 8px 8px 0 0 !important;}.am-comment-bd, .am-comment-meta {background-color: transparent !important;background-image: none !important;}li.feed-li {background-color: transparent !important;background-image: none !important;}.bottom-wrap.float {background: var(${GLASS_VAR_BG}) !important;backdrop-filter: none !important;-webkit-backdrop-filter: none !important;border: var(${GLASS_VAR_BORDER}) !important;box-shadow: var(${GLASS_VAR_SHADOW}) !important;border-radius: 12px !important;padding: 6px 10px !important;}.bottom-wrap.float .btn-checkbox {background: transparent !important;background-color: transparent !important;background-image: none !important;border-color: transparent !important;box-shadow: none !important;backdrop-filter: none !important;-webkit-backdrop-filter: none !important;}.bottom-wrap.float .page-bar button {background: var(${GLASS_VAR_BG}) !important;backdrop-filter: none !important;-webkit-backdrop-filter: none !important;border: var(${GLASS_VAR_BORDER}) !important;box-shadow: var(${GLASS_VAR_SHADOW}) !important;border-radius: 8px !important;}.bottom-wrap.float .toolbar {background: transparent !important;}${imageRules}${pasteRules}${ticketRules}${classSiteRules}${tiRules}${inputGlassRules}${problemListGlassRules}${userCardGlassRules}${modalGlassRules}.user-header-top:not(#${FORCE_ID}) {background-color: transparent !important;box-shadow: none !important;border: none !important;}`;if (styleEl.textContent !== content) styleEl.textContent = content;}/* ============================================================* 导航栏不透明兜底* ============================================================ */function solidifyNavigationBars() {if (!currentEnabled) return;const els = document.querySelectorAll(NAV_SELECTOR);els.forEach(el => {if (el.matches && el.matches(SHELL_SELECTOR)) {if (el.hasAttribute(NAV_SOLID_ATTR)) {el.removeAttribute(NAV_SOLID_ATTR);el.style.removeProperty('background-color');el.style.removeProperty('background-image');el.style.removeProperty('backdrop-filter');el.style.removeProperty('-webkit-backdrop-filter');}return;}const cs = getComputedStyle(el);const bg = cs.backgroundColor;const rgb = parseRgb(bg);if (!rgb) return;const isOpaque = !/rgba\(/.test(bg) || /rgba\([^)]*,\s*1(\.0*)?\s*\)/.test(bg);if (isOpaque && el.hasAttribute(NAV_SOLID_ATTR)) return;el.style.setProperty('background-color', `rgb(${rgb.r}, ${rgb.g}, ${rgb.b})`, 'important');el.style.setProperty('background-image', 'none', 'important');el.style.setProperty('backdrop-filter', 'none', 'important');el.style.setProperty('-webkit-backdrop-filter', 'none', 'important');el.setAttribute(NAV_SOLID_ATTR, '1');});}function clearSolidNavigationBars() {document.querySelectorAll(`[${NAV_SOLID_ATTR}]`).forEach(el => {el.style.removeProperty('background-color');el.style.removeProperty('background-image');el.style.removeProperty('backdrop-filter');el.style.removeProperty('-webkit-backdrop-filter');el.removeAttribute(NAV_SOLID_ATTR);});}/* ============================================================* 白卡玻璃化* ============================================================ */function bumpPaintVersion() {paintVersion++;}function applyWhiteCardsGlass() {if (!isGlassApplyPage() || !currentEnabled) return;const userBg = buildBgValue(currentColor, currentAlpha);const ver = paintVersion;const all = document.querySelectorAll('body *');all.forEach(el => {if (SKIP_TAGS.has(el.tagName)) return;if (INLINE_TAGS.has(el.tagName)) return;if (el.matches && el.matches('.l-card')) return;if (el.matches && el.matches('.user-header-top')) return;if (el.matches && el.matches(NAV_SELECTOR)) return;if (el.matches && el.matches(CSS_OWNED_SELECTOR)) return;if (el.closest && el.closest(`#${PANEL_ID}`)) return;try { if (el.closest('svg')) return; } catch (e) {}try { if (el.closest(CONTENT_EXCLUDE)) return; } catch (e) {}try { if (el.closest(CSS_OWNED_SUBTREE)) return; } catch (e) {}try { if (el.closest(NAV_SELECTOR)) return; } catch (e) {}try { if (el.closest('.l-card.float-card, .dropdown.shown .l-card')) return; } catch (e) {}try { if (el.closest(MODAL_CARD_SELECTOR)) return; } catch (e) {} /* ★ v5.5 */try { if (el.closest(FLOATING_EXCLUDE)) return; } catch (e) {}if (paintedElements.get(el) === ver) return;const inlineBg = el.style && el.style.backgroundColor;if (inlineBg && inlineBg !== 'transparent' && inlineBg !== 'rgba(0, 0, 0, 0)') {const rgb = parseRgb(inlineBg);if (rgb) {const max = Math.max(rgb.r, rgb.g, rgb.b);const min = Math.min(rgb.r, rgb.g, rgb.b);if (!(max - min <= 20 && min >= 240)) return;} else return;}let cs;try { cs = getComputedStyle(el); } catch { return; }const bg = cs.backgroundColor;if (!bg || bg === 'transparent' || bg === 'rgba(0, 0, 0, 0)') return;const rgb = parseRgb(bg);if (!rgb) return;const max = Math.max(rgb.r, rgb.g, rgb.b);const min = Math.min(rgb.r, rgb.g, rgb.b);if (max - min > 25) return;if (min < 210) return;if (!el.hasAttribute(ORIG_BG_ATTR)) {const orig = el.style.getPropertyValue('background-color');if (orig && orig !== 'transparent' && orig !== 'rgba(0, 0, 0, 0)') {el.setAttribute(ORIG_BG_ATTR, orig);}}el.style.setProperty('background-color', userBg, 'important');el.style.setProperty('background-image', 'none', 'important');el.style.setProperty('backdrop-filter', 'none', 'important');el.style.setProperty('-webkit-backdrop-filter', 'none', 'important');el.style.setProperty('border', GLASS_BORDER, 'important');el.style.setProperty('box-shadow', GLASS_SHADOW, 'important');el.setAttribute(PAINT_MARK, '1');paintedElements.set(el, ver);});}function clearWhiteCardsPaint() {document.querySelectorAll(`[${PAINT_MARK}]`).forEach(el => {el.style.removeProperty('background-color');if (el.hasAttribute(ORIG_BG_ATTR)) {const orig = el.getAttribute(ORIG_BG_ATTR);if (orig) el.style.setProperty('background-color', orig);el.removeAttribute(ORIG_BG_ATTR);}el.style.removeProperty('background-image');el.style.removeProperty('backdrop-filter');el.style.removeProperty('-webkit-backdrop-filter');el.style.removeProperty('border');el.style.removeProperty('box-shadow');el.removeAttribute(PAINT_MARK);});paintedElements = new WeakMap();document.querySelectorAll('.l-card.float-card, .dropdown.shown .l-card').forEach(el => {el.style.removeProperty('background-color');el.style.removeProperty('background-image');el.style.removeProperty('backdrop-filter');el.style.removeProperty('-webkit-backdrop-filter');el.style.removeProperty('border');el.style.removeProperty('box-shadow');el.style.removeProperty('border-radius');});document.querySelectorAll('.l-card.float-card .user-info, .l-card.float-card .user-action, ' +'.dropdown.shown .l-card .user-info, .dropdown.shown .l-card .user-action').forEach(el => {el.style.removeProperty('background-color');el.style.removeProperty('background-image');});}/* ============================================================* JS 内联 !important 强制悬停卡片毛玻璃* ============================================================ */function forceUserCardGlass() {if (!currentEnabled) return;const bg = buildBgValue(currentColor, currentAlpha);const cards = document.querySelectorAll('.l-card.float-card, .dropdown.shown .l-card');if (!cards.length) return;cards.forEach(el => {el.style.setProperty('background-color', bg, 'important');el.style.setProperty('background-image', 'none', 'important');el.style.setProperty('backdrop-filter', USER_CARD_BLUR, 'important');el.style.setProperty('-webkit-backdrop-filter', USER_CARD_BLUR, 'important');el.style.setProperty('border', GLASS_BORDER, 'important');el.style.setProperty('box-shadow', GLASS_SHADOW, 'important');el.style.setProperty('border-radius', '12px', 'important');});document.querySelectorAll('.l-card.float-card .user-info, .l-card.float-card .user-action').forEach(el => {el.style.setProperty('background-color', 'transparent', 'important');el.style.setProperty('background-image', 'none', 'important');});}function startUserCardGlassLoop() {if (userCardGlassTimer) return;userCardGlassTimer = setInterval(forceUserCardGlass, 300);}function stopUserCardGlassLoop() {if (userCardGlassTimer) {clearInterval(userCardGlassTimer);userCardGlassTimer = null;}}/* ============================================================* ★ v5.5:JS 内联强制弹窗毛玻璃(CSS 兜底 + JS 强化)* ============================================================ */function forceModalGlass() {if (!currentEnabled) return;const bg = buildFrostedBgValue(currentColor, currentAlpha);const modals = document.querySelectorAll(MODAL_CARD_SELECTOR);if (!modals.length) return;modals.forEach(el => {el.style.setProperty('background-color', bg, 'important');el.style.setProperty('background-image', 'none', 'important');el.style.setProperty('backdrop-filter', USER_CARD_BLUR, 'important');el.style.setProperty('-webkit-backdrop-filter', USER_CARD_BLUR, 'important');el.style.setProperty('border', GLASS_BORDER, 'important');el.style.setProperty('box-shadow','0 16px 48px rgba(31, 38, 135, 0.22), 0 4px 12px rgba(0, 0, 0, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.6)','important');el.style.setProperty('border-radius', '12px', 'important');/* 内层结构清透明 */el.querySelectorAll(':scope > *, :scope > * > *').forEach(child => {if (child.closest(`#${PANEL_ID}`)) return;child.style.setProperty('background-color', 'transparent', 'important');child.style.setProperty('background-image', 'none', 'important');});});}function startModalGlassLoop() {if (modalGlassTimer) return;modalGlassTimer = setInterval(forceModalGlass, 400);}function stopModalGlassLoop() {if (modalGlassTimer) {clearInterval(modalGlassTimer);modalGlassTimer = null;}}function clearModalGlass() {document.querySelectorAll(MODAL_CARD_SELECTOR).forEach(el => {el.style.removeProperty('background-color');el.style.removeProperty('background-image');el.style.removeProperty('backdrop-filter');el.style.removeProperty('-webkit-backdrop-filter');el.style.removeProperty('border');el.style.removeProperty('box-shadow');el.style.removeProperty('border-radius');el.querySelectorAll(':scope > *, :scope > * > *').forEach(child => {child.style.removeProperty('background-color');child.style.removeProperty('background-image');});});}/* ============================================================* 强制 .refined-input.text 的内层元素透明* ============================================================ */function forceTextInnerTransparent() {if (!currentEnabled) return;const containers = document.querySelectorAll('.refined-input.text:not(.search-text)');if (!containers.length) return;containers.forEach(container => {const inner = container.querySelectorAll('*');inner.forEach(el => {if (el.closest('svg') && el.tagName.toLowerCase() !== 'svg') return;el.style.setProperty('background-color', 'transparent', 'important');el.style.setProperty('background-image', 'none', 'important');el.style.setProperty('background', 'transparent', 'important');el.style.setProperty('border', 'none', 'important');el.style.setProperty('box-shadow', 'none', 'important');el.style.setProperty('outline', 'none', 'important');el.style.setProperty('backdrop-filter', 'none', 'important');el.style.setProperty('-webkit-backdrop-filter', 'none', 'important');el.setAttribute(INNER_TRANSPARENT_ATTR, '1');});});}function clearTextInnerTransparent() {document.querySelectorAll(`[${INNER_TRANSPARENT_ATTR}]`).forEach(el => {el.style.removeProperty('background-color');el.style.removeProperty('background-image');el.style.removeProperty('background');el.style.removeProperty('border');el.style.removeProperty('box-shadow');el.style.removeProperty('outline');el.style.removeProperty('backdrop-filter');el.style.removeProperty('-webkit-backdrop-filter');el.removeAttribute(INNER_TRANSPARENT_ATTR);});}/* ============================================================* 工单顶栏黑* ============================================================ */function applyTicketTopBarBlack() {if (!isTicketPage() || !currentEnabled) return;const topBar = document.querySelector('.top-bar');if (!topBar) return;const rect = topBar.getBoundingClientRect();if (rect.top > 100) return;if (topBar.hasAttribute(TICKET_TOPBAR_ATTR)) return;topBar.style.setProperty('background-color', '#1a1a1a', 'important');topBar.style.setProperty('background-image', 'none', 'important');topBar.style.setProperty('backdrop-filter', 'none', 'important');topBar.style.setProperty('-webkit-backdrop-filter', 'none', 'important');topBar.style.setProperty('border-bottom', '1px solid rgba(255,255,255,0.1)', 'important');topBar.setAttribute(TICKET_TOPBAR_ATTR, '1');topBar.querySelectorAll('a, span, div, h1, h2, h3, h4, p, li').forEach(child => {if (child.closest('svg')) return;child.style.setProperty('color', '#e0e0e0', 'important');});topBar.querySelectorAll('svg').forEach(svg => {svg.style.setProperty('color', '#e0e0e0', 'important');});}function clearTicketTopBarBlack() {document.querySelectorAll(`[${TICKET_TOPBAR_ATTR}]`).forEach(el => {el.style.removeProperty('background-color');el.style.removeProperty('background-image');el.style.removeProperty('backdrop-filter');el.style.removeProperty('-webkit-backdrop-filter');el.style.removeProperty('border-bottom');el.querySelectorAll('a, span, div, h1, h2, h3, h4, p, li, svg').forEach(child => {child.style.removeProperty('color');});el.removeAttribute(TICKET_TOPBAR_ATTR);});}/* ============================================================* 文字加深 —— 只保留灰色* ============================================================ */function isGrayish(r, g, b) {const max = Math.max(r, g, b);const min = Math.min(r, g, b);if (max - min > 30) return false;if (max < 40) return false;if (min > 220) return false;return true;}function isAlreadyDarkGray(r, g, b) {return Math.abs(r - 60) < 12 && Math.abs(g - 60) < 12 && Math.abs(b - 70) < 12;}5 行未改动if (!containers.length) return;containers.forEach(card => {if (card.closest && card.closest(`#${PANEL_ID}`)) return;if (card.matches && card.matches(MODAL_CARD_SELECTOR)) return; /* ★ v5.5:弹窗交给 modal 规则 */if (card.closest && card.closest(MODAL_CARD_SELECTOR)) return; /* ★ v5.5 */card.querySelectorAll(TEXT_DARKEN_SELECTOR).forEach(el => {if (el.children.length > 0) return;if (SKIP_TAGS.has(el.tagName)) return;3 行未改动if (el.closest('.user-header-top')) return;if (el.closest(NAV_SELECTOR)) return;if (el.closest(`.${INPUT_SKIP_CLASS}`)) return;if (el.closest(`#${PANEL_ID}`)) return;if (el.closest(MODAL_CARD_SELECTOR)) return; /* ★ v5.5 */try { if (el.closest(CONTENT_EXCLUDE)) return; } catch (e) {}try { if (el.closest('.refined-input.search-text')) return; } catch (e) {}try { if (el.closest('.refined-input.text')) return; } catch (e) {}try { if (el.closest('.search-option')) return; } catch (e) {}23 行未改动try { cs = getComputedStyle(el); } catch { return; }const rgb = parseRgb(cs.color);if (!rgb) return;if (!isAlreadyDarkGray(rgb.r, rgb.g, rgb.b) && isGrayish(rgb.r, rgb.g, rgb.b)) {el.style.setProperty('color', DARK_GRAY, 'important');el.setAttribute(GRAY_MARK, '1');darkenedElements.add(el);2 行未改动});}function clearColorText() {document.querySelectorAll(`[${GRAY_MARK}]`).forEach(el => {el.style.removeProperty('color');el.removeAttribute(GRAY_MARK);});darkenedElements = new WeakSet();}12 行未改动clearWhiteCardsPaint();clearTextInnerTransparent();clearSolidNavigationBars();clearPaintedBackground();clearModalGlass(); /* ★ v5.5 */stopThemeBgWatcher();stopLuoguThemePoll();stopUserCardGlassLoop();stopModalGlassLoop(); /* ★ v5.5 */lastThemeInfo = { imageUrl: null, backColor: null, colorGradient: null, source: 'none' };return;}7 行未改动applyTicketTopBarBlack();applyWhiteCardsGlass();forceUserCardGlass();startUserCardGlassLoop();forceModalGlass(); /* ★ v5.5 */startModalGlassLoop(); /* ★ v5.5 */forceTextInnerTransparent();darkenColorText();startThemeBgWatcher();startLuoguThemePoll();182 行未改动全部展开transform: translateX(20px);}#${PANEL_ID} .bg-input-area { margin-top: 14px; transition: opacity 0.3s; }#${PANEL_ID} .bg-input-area.disabled { opacity: 0.45; pointer-events: none; }#${PANEL_ID} .bg-input-area.disabled .btn-row { pointer-events: auto; }#${PANEL_ID} .bg-row {display: flex; align-items: center; gap: 12px;padding: 10px 12px; border-radius: 10px;background: rgba(255, 255, 255, 0.25);134 行未改动全部展开<div class="bg-preview-color" id="bg-preview-color"></div><span>预览效果</span></div><div class="debug-info" id="bg-debug"></div></div><div class="btn-row"><button class="btn btn-primary" id="bg-save">保存</button><button class="btn btn-secondary" id="bg-reset">重置</button><button class="btn btn-secondary" id="bg-refresh-theme">重新拉取主题</button><button class="btn btn-secondary" id="bg-url-clear">清空手动 URL</button><button class="btn btn-secondary" id="bg-auto-clear">清空自动缓存</button><span class="save-status" id="bg-status">已保存</span></div>`;panel.querySelectorAll('input, textarea').forEach(el => {el.classList.add(INPUT_SKIP_CLASS);21 行未改动const manual = GM_getValue(KEY_THEME_BG_URL, '') || '(空)';const auto = GM_getValue(KEY_AUTO_BG_URL, '') || '(空)';const source = lastThemeInfo.source || 'none';const divider = buildTicketDividerColor(currentColor);const frosted = buildFrostedBgValue(currentColor, currentAlpha);debugInfo.innerHTML =`手动 URL: ${manual}<br>` +`自动缓存: ${auto}<br>` +`当前生效来源: <b>${source}</b><br>` +`工单分割线色: <b>${divider}</b><br>` +`弹窗毛玻璃色: <b>${frosted}</b>`;}function liveUpdate() {currentColor = colorInput.value;71 行未改动});toggle.addEventListener('change', () => {currentEnabled = toggle.checked;GM_setValue(KEY_ENABLED, currentEnabled);inputArea.classList.toggle('disabled', !toggle.checked);bumpPaintVersion();applyCustomBg();refreshDebug();51 行未改动/* ============================================================* 调试 & 手动设置接口* ============================================================ */PAGE_WIN.__luoguBgDebug = function () {console.group('==== 铍洛谷调试 v5.5 ====');console.log('enabled:', currentEnabled);console.log('手动 URL:', GM_getValue(KEY_THEME_BG_URL, '') || '(空)');console.log('自动缓存 URL:', GM_getValue(KEY_AUTO_BG_URL, '') || '(空)');console.log('自动缓存 backColor:', GM_getValue(KEY_AUTO_BG_BACK, '') || '(空)');console.log('自动缓存 gradient:', GM_getValue(KEY_AUTO_BG_GRAD, '') || '(空)');console.log('毛玻璃背景色:', buildFrostedBgValue(currentColor, currentAlpha));console.log('lastThemeInfo:', lastThemeInfo);console.log('isHomePage:', isHomePage());console.log('lastLuoguThemeImage:', lastLuoguThemeImage);106 行未改动全部展开applyCustomBg();console.log('[铍洛谷] 自动缓存 URL =', url || '(已清空)');};PAGE_WIN.__luoguBgForceDisable = function () {GM_setValue(KEY_ENABLED, false);currentEnabled = false;bumpPaintVersion();applyCustomBg();console.log('[铍洛谷] 已强制关闭');};PAGE_WIN.__luoguBgVerbose = function (on) {PAGE_WIN.__LUOGU_BG_VERBOSE = !!on;console.log('[铍洛谷] verbose =', PAGE_WIN.__LUOGU_BG_VERBOSE);};24 行未改动});}console.log('[铍洛谷] v5.5 已启动。\n' +' 调试: __luoguBgDebug()\n' +' 悬停卡片调试: __luoguBgInspectUserCard()\n' +' 强制刷新: __luoguBgForceRefresh()\n' +' 重新拉取主题: __luoguBgFetchTheme()\n' +' fetch 拉取: __luoguBgFetchFromServer()\n' +' 强制关闭: __luoguBgForceDisable()');} catch (err) {console.error('[铍洛谷] boot 出错:', err);}28 行未改动}, 300);}}, 800);})();```::::---199 行未改动全部展开**注**:本文包括插件由DeepSeek协助完成***::::warning[叠甲]由于这是作者第一次探索类似的插件,以及这个项目目前还处于测试阶段,所以可能有各种各样的BUG。::::::::warning[免责声明]铍洛谷是一个美化洛谷的插件,不含任何爬取/滥用数据或API或修改了洛谷的核心功能或数据或影响其他用户或服务器稳定性等损害洛谷或其他用户利益的功能。如果用户因为铍洛谷(包括从第三方下载、私自修改等)被封禁,铍洛谷概不负责。如果洛谷官方明令禁止,请立即停止使用此脚本。::::::::info[更新日志]V5.4 修复了一些已知问题V5.4.8 修复了很多已知问题V5.5 修复了一些已知问题::::