正文
增加 5982 行删除 11 行
16 行未改动17181920212223242526272829303136 行未改动6869707172737475103 行未改动全部展开17918018118218318418518621 行未改动20820921021121221321421524 行未改动240241242243244245246247353 行未改动全部展开601602603604605606607608609610611612613614615616272 行未改动全部展开889890891892893894895896146 行未改动全部展开1043104410451046104710481049105093 行未改动1144114511461147114811491150115171 行未改动1223122412251226122712281229123063 行未改动12941295129612971298129913001301130239 行未改动1342134313441345134613471348134994 行未改动144414451446144714481449145014513 行未改动1455145614571458145914601461146255 行未改动151815191520152115221523152415251526152715287 行未改动15361537153815391540154115421543181 行未改动全部展开172517261727172817291730173117321733103 行未改动全部展开18371838183918401841184218431844184563 行未改动190919101911191219131914191519161917191819191920192169 行未改动19911992199319941995199619971998199954 行未改动20542055205620572058205920602061206220632064206520662067106 行未改动全部展开21742175217621772178217921802181218232 行未改动22152216221722182219222022212222222336 行未改动2260226122622263226422652266226722682269215 行未改动全部展开248524862487248824892490249116 行未改动1. 浏览器装 **Tampermonkey** 扩展2. 打开 Tampermonkey 面板 → 新建脚本3. 把整份脚本粘进去 → 保存(Ctrl+S)4. 打开任意洛谷页面,F5 刷新,看到控制台打印 `[铍洛谷] v5.4.1 已启动。` 就说明成功了::::info[脚本]{open}// ==UserScript==// @name 铍洛谷// @namespace http://tampermonkey.net/// @version 5.4.1// @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';103 行未改动全部展开'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);}/* ============================================================* 内联画背景272 行未改动全部展开`;}/* ============================================================* 玻璃 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;63 行未改动el.style.removeProperty('box-shadow');el.style.removeProperty('border-radius');});/* ★ 修复 4:补清 forceUserCardGlass 在 user-info / user-action 上留下的内联样式 */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 => {39 行未改动}}/* ============================================================* 强制 .refined-input.text 的内层元素透明* ============================================================ */function forceTextInnerTransparent() {if (!currentEnabled) return;94 行未改动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) {}55 行未改动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();181 行未改动全部展开#${PANEL_ID} .toggle-switch input:checked + .toggle-slider::before {transform: translateX(20px);}#${PANEL_ID} .bg-input-area { margin-top: 14px; transition: opacity 0.3s; }/* ★ 修复 2:只把“输入区”变灰不可点,按钮行在 DOM 上已移出本容器,所以不受影响 */#${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;103 行未改动全部展开const manualUrl = GM_getValue(KEY_THEME_BG_URL, '') || '';const panel = document.createElement('div');panel.id = PANEL_ID;/* ★ 修复 1:把 .btn-row 移出 .bg-input-area,这样关闭开关时按钮不会被 pointer-events:none 波及 */panel.innerHTML = `<div class="panel-title">铍洛谷 设置</div><div class="setting-row"><div>63 行未改动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;69 行未改动panel.querySelector('#bg-url-apply').click();}});/* ★ 修复 3:开关切换立即持久化,关得下去、刷新不回弹 */toggle.addEventListener('change', () => {currentEnabled = toggle.checked;GM_setValue(KEY_ENABLED, currentEnabled);inputArea.classList.toggle('disabled', !toggle.checked);54 行未改动/* ============================================================* 调试 & 手动设置接口* ============================================================ */PAGE_WIN.__luoguBgDebug = function () {console.group('==== 铍洛谷调试 v5.4.1 ====');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 || '(已清空)');};/* ★ 新增:一键彻底关闭并清干净(万一 UI 出问题可在控制台调用) */PAGE_WIN.__luoguBgForceDisable = function () {GM_setValue(KEY_ENABLED, false);currentEnabled = false;bumpPaintVersion();32 行未改动});}console.log('[铍洛谷] v5.4.1 已启动。\n' +' 调试: __luoguBgDebug()\n' +' 悬停卡片调试: __luoguBgInspectUserCard()\n' +' 强制刷新: __luoguBgForceRefresh()\n' +' 重新拉取主题: __luoguBgFetchTheme()\n' +36 行未改动}, 800);})();```::::---## 三、打开设置面板215 行未改动全部展开::::info[更新日志]V5.4 修复了一些已知问题V5.5.1 修复了很多已知问题::::16 行未改动17181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347936 行未改动351635173518351935203521352235233524103 行未改动全部展开3628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365021 行未改动36723673367436753676367736783679368024 行未改动3705370637073708370937103711371237133714371537163717353 行未改动全部展开4071407240734074407540764077407840794080408140824083408440854086408740884089272 行未改动全部展开436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415146 行未改动全部展开45624563456445654566456745684569457093 行未改动46644665466646674668466946704671467271 行未改动47444745474647474748474947504751475263 行未改动4816481748184819482048214822482339 行未改动4863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492794 行未改动50225023502450255026502750285029503050313 行未改动50355036503750385039504050415042504355 行未改动50995100510151025103510451055106510751085109511051117 行未改动5119512051215122512351245125512651275128181 行未改动全部展开53105311531253135314531553165317103 行未改动全部展开5421542254235424542554265427542863 行未改动54925493549454955496549754985499550055015502550355045505550669 行未改动5576557755785579558055815582558354 行未改动563856395640564156425643564456455646564756485649565056515652106 行未改动全部展开5759576057615762576357645765576632 行未改动57995800580158025803580458055806580736 行未改动584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237215 行未改动全部展开845384548455845684578458845984608461846216 行未改动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';103 行未改动全部展开'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 */}/* ============================================================* 内联画背景272 行未改动全部展开`;}/* ============================================================* ★ 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;63 行未改动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 => {39 行未改动}}/* ============================================================* ★ 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;94 行未改动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) {}55 行未改动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();181 行未改动全部展开#${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;103 行未改动全部展开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>63 行未改动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;69 行未改动panel.querySelector('#bg-url-apply').click();}});toggle.addEventListener('change', () => {currentEnabled = toggle.checked;GM_setValue(KEY_ENABLED, currentEnabled);inputArea.classList.toggle('disabled', !toggle.checked);54 行未改动/* ============================================================* 调试 & 手动设置接口* ============================================================ */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();32 行未改动});}console.log('[铍洛谷] v5.5 已启动。\n' +' 调试: __luoguBgDebug()\n' +' 悬停卡片调试: __luoguBgInspectUserCard()\n' +' 强制刷新: __luoguBgForceRefresh()\n' +' 重新拉取主题: __luoguBgFetchTheme()\n' +36 行未改动}, 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;}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);})();```::::---## 三、打开设置面板215 行未改动全部展开::::info[更新日志]V5.4 修复了一些已知问题V5.4.8 修复了很多已知问题V5.5 修复了一些已知问题::::