标题
增加 1 行删除 1 行
1洛谷简易插件1洛谷简易插件·LuoguSP
正文
增加 644 行删除 51 行
16 行未改动1718192021222324252651 行未改动7879808182838485868788899091929326 行未改动12012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215317 行未改动171172173174175176177178179145 行未改动全部展开32532632732832933033133286 行未改动41942042142242342442542642720 行未改动448449450451452453454455456457458266 行未改动全部展开725726727728729730731732733715 行未改动全部展开14491450145114521453145414551456145714581459146014611462146314641465106 行未改动全部展开157215731574157515761577157815791580158127 行未改动160916101611161216131614161516161617161816191620162116221623106 行未改动全部展开1730173117321733173417351736173710 行未改动174817491750175117521753175417559 行未改动16 行未改动```javascript// ==UserScript==// @name LuoguSP// @namespace https://github.com/ShanireZ/LuoguSP// @version 2.9.2// @description LuoguSP:题目难度着色 / 私信 Ctrl+Click(用户名+头像) 跳转主页 / 显示隐藏的个人简介 / IDE 一键测试样例// @author ShanireZ, realskc (Until 1.8.2)// @license GPL-3.0// @match https://www.luogu.com.cn/*// @homepageURL https://github.com/ShanireZ/LuoguSP51 行未改动ideTextarea: "textarea.ide-textarea", // 输入/输出面板的文本域ideSampleBlock: ".io-sample-block", // 题面样例块(输入 #N / 输出 #N 各一块)cmContent: ".cm-content", // CodeMirror 6 内容层lentilleContext: "script#lentille-context", // 新版页面数据(JSON,含 problem.samples)};// 功能开关:key → 显示名。新增功能只需在此登记 + 在底部 FEATURES 注册启动器。const FEATURE_LABELS = new Map([[`${STORAGE_PREFIX}addProblemsColor`, "显示题目颜色"],[`${STORAGE_PREFIX}addMessageLink`, "私信界面 Ctrl+Click 打开用户主页"],[`${STORAGE_PREFIX}showIntro`, "显示隐藏的个人简介"],[`${STORAGE_PREFIX}ideBatchSampleTest`, "IDE 一键测试样例"],]);const storage = {get: (k) => localStorage.getItem(k) === "true",26 行未改动#luogusp-settings .luogusp-primary:hover{background:#0879bd;border-color:#0879bd;color:#fff;}#luogusp-settings .luogusp-primary:active{background:#066ca9;border-color:#066ca9;color:#fff;}#luogusp-settings .luogusp-hint{margin:10px 0 0;color:#888;font-size:12px;}.luogusp-setting-entry{cursor:pointer;}.luogusp-intro-card li:has(> input[type="checkbox"]){list-style:none;margin-left:-1.2em;}.luogusp-intro-card li > input[type="checkbox"]{margin-right:.4em;}.luogusp-intro-card .code-container{margin:1rem 0;position:relative;}.luogusp-intro-card .code-container:hover>.copy-button{opacity:1;}.luogusp-intro-card .code-container:hover>.copy-button:hover{background-color:#ddd;}.luogusp-intro-card .copy-button{position:absolute;top:.5em;right:.5em;padding:.6em;display:flex;align-items:center;justify-content:center;transition:opacity .2s ease-in-out,color .2s ease-in-out,background-color .2s ease-in-out;opacity:0;background-color:transparent;border:0;border-radius:4px;cursor:pointer;color:#555;}.luogusp-intro-card .copy-button:focus{opacity:1;outline:1px solid #ddd;}.luogusp-intro-card .copy-button.copied{color:#52c41a;}.luogusp-intro-card .copy-icon{width:1em;height:1em;}.luogusp-intro-card .code-container>pre{background:#fafafa;color:#383a42;padding:1em;margin:0;overflow:auto;border-radius:.3em;}.luogusp-intro-card .code-container>pre code{font-family:"Fira Code","Fira Mono",Menlo,Consolas,"DejaVu Sans Mono",monospace;line-height:1.5;tab-size:2;}.luogusp-intro-card pre[class*="language-"],.luogusp-intro-card code[class*="language-"]{background:#fafafa;color:#383a42;font-family:"Fira Code","Fira Mono",Menlo,Consolas,"DejaVu Sans Mono",monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;line-height:1.5;tab-size:2;hyphens:none;}.luogusp-intro-card pre[class*="language-"]{padding:1em;margin:.5em 0;overflow:auto;border-radius:.3em;}.luogusp-intro-card .code-container>pre[class*="language-"]{margin:0;}.luogusp-intro-card pre code.hljs{display:block;overflow-x:visible;padding:0;background:transparent;}.luogusp-intro-card code.hljs{color:#383a42;background:#fafafa;}.luogusp-intro-card .hljs-comment,.luogusp-intro-card .hljs-quote{color:#a0a1a7;font-style:italic;}.luogusp-intro-card .hljs-doctag,.luogusp-intro-card .hljs-formula,.luogusp-intro-card .hljs-keyword{color:#a626a4;}.luogusp-intro-card .hljs-deletion,.luogusp-intro-card .hljs-name,.luogusp-intro-card .hljs-section,.luogusp-intro-card .hljs-selector-tag,.luogusp-intro-card .hljs-subst{color:#e45649;}.luogusp-intro-card .hljs-literal{color:#0184bb;}.luogusp-intro-card .hljs-addition,.luogusp-intro-card .hljs-attribute,.luogusp-intro-card .hljs-meta .hljs-string,.luogusp-intro-card .hljs-regexp,.luogusp-intro-card .hljs-string{color:#50a14f;}.luogusp-intro-card .hljs-attr,.luogusp-intro-card .hljs-number,.luogusp-intro-card .hljs-selector-attr,.luogusp-intro-card .hljs-selector-class,.luogusp-intro-card .hljs-selector-pseudo,.luogusp-intro-card .hljs-template-variable,.luogusp-intro-card .hljs-type,.luogusp-intro-card .hljs-variable{color:#986801;}.luogusp-intro-card .hljs-bullet,.luogusp-intro-card .hljs-link,.luogusp-intro-card .hljs-meta,.luogusp-intro-card .hljs-selector-id,.luogusp-intro-card .hljs-symbol,.luogusp-intro-card .hljs-title{color:#4078f2;}.luogusp-intro-card .hljs-built_in,.luogusp-intro-card .hljs-class .hljs-title,.luogusp-intro-card .hljs-title.class_,.luogusp-intro-card .hljs-title.function_{color:#c18401;}.luogusp-intro-card .hljs-emphasis{font-style:italic;}.luogusp-intro-card .hljs-strong{font-weight:700;}.luogusp-ide-tabbar{display:flex;gap:20px;padding:0 12px;border-bottom:1px solid #e8e8e8;flex:none;}.luogusp-ide-tab{font-size:13px;color:#606266;padding:7px 2px 5px;cursor:pointer;border-bottom:2px solid transparent;}.luogusp-ide-tab.on{color:#3498db;border-bottom-color:#3498db;font-weight:500;}.luogusp-ide-panel{overflow:auto;flex:1 1 0;min-height:0;padding:8px 12px 12px;font-size:13px;color:#333;}17 行未改动.luogusp-ide-pane pre{margin:0;border:1px solid #e6e6e6;border-radius:4px;background:#fff;padding:6px 8px;font-size:12px;line-height:1.55;color:#333;overflow-x:auto;min-height:40px;font-family:"Fira Code","Fira Mono",Menlo,Consolas,"DejaVu Sans Mono",monospace;}.luogusp-ide-pane .luogusp-ide-diffline{background:#fcebeb;color:#a32d2d;display:block;margin:0 -8px;padding:0 8px;}.luogusp-ide-note{font-size:12px;color:#a32d2d;margin:0 0 8px;}.luogusp-ide-empty{color:#aaa;font-style:italic;}.luogusp-ide-legend{display:flex;flex-wrap:wrap;gap:6px;align-items:center;margin-top:10px;padding-top:8px;border-top:1px dashed #eee;font-size:12px;color:#999;}.luogusp-ide-panel .code-container:hover>.copy-button{opacity:1;}.luogusp-ide-panel .copy-button{position:absolute;top:.3em;right:.3em;padding:.45em;display:flex;align-items:center;justify-content:center;transition:opacity .2s;opacity:0;background:transparent;border:0;border-radius:4px;cursor:pointer;color:#555;}.luogusp-ide-panel .copy-button.copied{color:#52c41a;}.luogusp-ide-panel .copy-icon{width:1em;height:1em;}145 行未改动全部展开unit.parentNode.insertBefore(clone, unit.nextSibling);}// 洛谷是 SPA:首页顶栏↔内容页侧栏随路由切换而重挂,入口须在导航变化时补上(rAF 节流,加了就早退)。function watchSettingButton() {let scheduled = false;const tick = () => {scheduled = false;86 行未改动// ============================================================// 显示隐藏的个人简介// 洛谷把个人简介改为「仅国际站可见」,但境内站服务器仍把 introduction 下发到页面同源数据里// (SSR 脚本 / _contentOnly 接口),只是前端不渲染。这里读同源数据自行补显,无需跨域。// ============================================================function digIntro(obj, wantUid) {let result = null;(function walk(o, depth) {20 行未改动} catch (e) {/* 非纯 JSON,跳过 */}}// 2) SPA 换页等:同源 _contentOnly 接口try {const r = await fetch(`/user/${uid}?_contentOnly=1`);const intro = digIntro(await r.json(), uid);if (intro != null) return intro;} catch (e) {console.error("LuoguSP intro fetch:", e);266 行未改动全部展开const nativeCard = document.querySelector(".l-card");const card = nativeCard? nativeCard.cloneNode(false): document.createElement("div");card.className = "l-card luogusp-intro-card";card.removeAttribute("id");card.removeAttribute("style"); // ★清掉克隆源卡的内联样式:某些卡带 --l-card--padding:0 会让内容贴框card.style.setProperty("--l-card--padding", "20.8px"); // 用国际站 intro 卡的内边距(洛谷 .l-card 靠此变量控制)// 头部:用国际站原生结构(.header > h3[margin=0]),让标题继承浏览器 h3 的字号与粗细。715 行未改动全部展开),);}// 实测原生内联配色(侦察实录 §5);MLE/OLE/UKE 未实测,行内以运行时复制为准const IDE_LEGEND = [["AC", "rgb(83,196,26)", "rgb(80,161,39)", "#fff"],["WA", "rgb(231,77,60)", "rgb(208,69,53)", "#fff"],["TLE", "rgb(5,34,66)", "rgb(10,31,54)", "#fff"],["RE", "rgb(156,61,207)", "rgb(138,62,179)", "#fff"],["CE", "rgb(250,219,20)", "rgb(215,190,28)", "#614700"],["UKE", "#3d3d3d", "#333", "#fff"],];function finishIdeSummary() {if (!IDE_BATCH.summaryEl || !IDE_BATCH.results) return;const rs = IDE_BATCH.results;const counts = {};106 行未改动全部展开'<span class="luogusp-ide-title">样例测试</span>' +'<span class="luogusp-ide-summary">尚未运行</span>' +'<span class="luogusp-ide-headbtns"></span>' +"</div>" +'<div class="luogusp-ide-rows"></div>' +'<div class="luogusp-ide-legend"></div>';// 停止/重新测试:同样克隆原生「自测」继承样式const tpl = [...document.querySelectorAll(`${SELECTORS.ideToolbar} button`),].find(27 行未改动IDE_BATCH.panel = panel;IDE_BATCH.ioLayout = ioLayout;IDE_BATCH.rowsEl = panel.querySelector(".luogusp-ide-rows");IDE_BATCH.summaryEl = panel.querySelector(".luogusp-ide-summary");panel.querySelector(".luogusp-ide-legend").innerHTML ="图例:" +IDE_LEGEND.map(([t, bg, bd, fg]) =>`<span class="luogusp-ide-pill" style="background-color:${bg};border-color:${bd};color:${fg};">${t}</span>`,).join("") +'<span style="margin-left:4px;">行内颜色实时取自洛谷原生结果</span>';syncIdeTabVisibility();}function switchIdeTab(tab) {IDE_BATCH.activeTab = tab;106 行未改动全部展开ensureIdeBatchUI();}// ============================================================// 启动// ============================================================const isChatPage = location.href.startsWith("https://www.luogu.com.cn/chat");10 行未改动},},{ key: `${STORAGE_PREFIX}showIntro`, run: watchHiddenIntro },{ key: `${STORAGE_PREFIX}ideBatchSampleTest`, run: watchIdeBatch },];injectStyle();for (const f of FEATURES) {9 行未改动16 行未改动1718192021222324252651 行未改动787980818283848586878889909192939495969726 行未改动12412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615717 行未改动175176177178179180181182145 行未改动全部展开32832933033133233333433533633733886 行未改动42542642742842943043143243320 行未改动454455456457458459460461462463464465466467468266 行未改动全部展开735736737738739740741742743715 行未改动全部展开14591460146114621463146414651466106 行未改动全部展开15731574157515761577157815791580158127 行未改动16091610161116121613161416151616106 行未改动全部展开172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232910 行未改动2340234123422343234423452346234723489 行未改动16 行未改动```javascript// ==UserScript==// @name LuoguSP// @namespace https://github.com/ShanireZ/LuoguSP// @version 2.10.7// @description LuoguSP:题目难度着色 / 私信 Ctrl+Click(用户名+头像) 跳转主页 / 显示隐藏的个人简介 / IDE 一键测试样例 / 受限文章剪贴板就地显示// @author ShanireZ, realskc (Until 1.8.2)// @license GPL-3.0// @match https://www.luogu.com.cn/*// @homepageURL https://github.com/ShanireZ/LuoguSP51 行未改动ideTextarea: "textarea.ide-textarea", // 输入/输出面板的文本域ideSampleBlock: ".io-sample-block", // 题面样例块(输入 #N / 输出 #N 各一块)cmContent: ".cm-content", // CodeMirror 6 内容层lentilleContext: "script#lentille-context", // 新版页面数据(JSON,含 problem.samples)// —— 安全访问中心拦截页(侦察实录 docs/superpowers/specs/2026-07-22-saver-api-recon-notes.md)——restrictedUrlPre: "pre#url", // 拦截页里的目标链接文本restrictedGoButton: "button#go", // 拦截页「继续访问」按钮};// 功能开关:key → 显示名。新增功能只需在此登记 + 在底部 FEATURES 注册启动器。const FEATURE_LABELS = new Map([[`${STORAGE_PREFIX}addProblemsColor`, "显示题目颜色"],[`${STORAGE_PREFIX}addMessageLink`, "私信界面 Ctrl+Click 打开用户主页"],[`${STORAGE_PREFIX}showIntro`, "显示隐藏的个人简介"],[`${STORAGE_PREFIX}ideBatchSampleTest`, "IDE 一键测试样例"],[`${STORAGE_PREFIX}showRestrictedContent`, "受限文章/剪贴板就地显示"],]);const storage = {get: (k) => localStorage.getItem(k) === "true",26 行未改动#luogusp-settings .luogusp-primary:hover{background:#0879bd;border-color:#0879bd;color:#fff;}#luogusp-settings .luogusp-primary:active{background:#066ca9;border-color:#066ca9;color:#fff;}#luogusp-settings .luogusp-hint{margin:10px 0 0;color:#888;font-size:12px;}.luogusp-setting-entry{cursor:pointer;}.luogusp-mdstyle li:has(> input[type="checkbox"]){list-style:none;margin-left:-1.2em;}.luogusp-mdstyle li > input[type="checkbox"]{margin-right:.4em;}.luogusp-mdstyle .code-container{margin:1rem 0;position:relative;}.luogusp-mdstyle .code-container:hover>.copy-button{opacity:1;}.luogusp-mdstyle .code-container:hover>.copy-button:hover{background-color:#ddd;}.luogusp-mdstyle .copy-button{position:absolute;top:.5em;right:.5em;padding:.6em;display:flex;align-items:center;justify-content:center;transition:opacity .2s ease-in-out,color .2s ease-in-out,background-color .2s ease-in-out;opacity:0;background-color:transparent;border:0;border-radius:4px;cursor:pointer;color:#555;}.luogusp-mdstyle .copy-button:focus{opacity:1;outline:1px solid #ddd;}.luogusp-mdstyle .copy-button.copied{color:#52c41a;}.luogusp-mdstyle .copy-icon{width:1em;height:1em;}.luogusp-mdstyle .code-container>pre{background:#fafafa;color:#383a42;padding:1em;margin:0;overflow:auto;border-radius:.3em;}.luogusp-mdstyle .code-container>pre code{font-family:"Fira Code","Fira Mono",Menlo,Consolas,"DejaVu Sans Mono",monospace;line-height:1.5;tab-size:2;}.luogusp-mdstyle pre[class*="language-"],.luogusp-mdstyle code[class*="language-"]{background:#fafafa;color:#383a42;font-family:"Fira Code","Fira Mono",Menlo,Consolas,"DejaVu Sans Mono",monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;line-height:1.5;tab-size:2;hyphens:none;}.luogusp-mdstyle pre[class*="language-"]{padding:1em;margin:.5em 0;overflow:auto;border-radius:.3em;}.luogusp-mdstyle .code-container>pre[class*="language-"]{margin:0;}.luogusp-mdstyle pre code.hljs{display:block;overflow-x:visible;padding:0;background:transparent;}.luogusp-mdstyle code.hljs{color:#383a42;background:#fafafa;}.luogusp-mdstyle .hljs-comment,.luogusp-mdstyle .hljs-quote{color:#a0a1a7;font-style:italic;}.luogusp-mdstyle .hljs-doctag,.luogusp-mdstyle .hljs-formula,.luogusp-mdstyle .hljs-keyword{color:#a626a4;}.luogusp-mdstyle .hljs-deletion,.luogusp-mdstyle .hljs-name,.luogusp-mdstyle .hljs-section,.luogusp-mdstyle .hljs-selector-tag,.luogusp-mdstyle .hljs-subst{color:#e45649;}.luogusp-mdstyle .hljs-literal{color:#0184bb;}.luogusp-mdstyle .hljs-addition,.luogusp-mdstyle .hljs-attribute,.luogusp-mdstyle .hljs-meta .hljs-string,.luogusp-mdstyle .hljs-regexp,.luogusp-mdstyle .hljs-string{color:#50a14f;}.luogusp-mdstyle .hljs-attr,.luogusp-mdstyle .hljs-number,.luogusp-mdstyle .hljs-selector-attr,.luogusp-mdstyle .hljs-selector-class,.luogusp-mdstyle .hljs-selector-pseudo,.luogusp-mdstyle .hljs-template-variable,.luogusp-mdstyle .hljs-type,.luogusp-mdstyle .hljs-variable{color:#986801;}.luogusp-mdstyle .hljs-bullet,.luogusp-mdstyle .hljs-link,.luogusp-mdstyle .hljs-meta,.luogusp-mdstyle .hljs-selector-id,.luogusp-mdstyle .hljs-symbol,.luogusp-mdstyle .hljs-title{color:#4078f2;}.luogusp-mdstyle .hljs-built_in,.luogusp-mdstyle .hljs-class .hljs-title,.luogusp-mdstyle .hljs-title.class_,.luogusp-mdstyle .hljs-title.function_{color:#c18401;}.luogusp-mdstyle .hljs-emphasis{font-style:italic;}.luogusp-mdstyle .hljs-strong{font-weight:700;}.luogusp-ide-tabbar{display:flex;gap:20px;padding:0 12px;border-bottom:1px solid #e8e8e8;flex:none;}.luogusp-ide-tab{font-size:13px;color:#606266;padding:7px 2px 5px;cursor:pointer;border-bottom:2px solid transparent;}.luogusp-ide-tab.on{color:#3498db;border-bottom-color:#3498db;font-weight:500;}.luogusp-ide-panel{overflow:auto;flex:1 1 0;min-height:0;padding:8px 12px 12px;font-size:13px;color:#333;}17 行未改动.luogusp-ide-pane pre{margin:0;border:1px solid #e6e6e6;border-radius:4px;background:#fff;padding:6px 8px;font-size:12px;line-height:1.55;color:#333;overflow-x:auto;min-height:40px;font-family:"Fira Code","Fira Mono",Menlo,Consolas,"DejaVu Sans Mono",monospace;}.luogusp-ide-pane .luogusp-ide-diffline{background:#fcebeb;color:#a32d2d;display:block;margin:0 -8px;padding:0 8px;}.luogusp-ide-note{font-size:12px;color:#a32d2d;margin:0 0 8px;}.luogusp-ide-empty{color:#aaa;font-style:italic;}.luogusp-ide-panel .code-container:hover>.copy-button{opacity:1;}.luogusp-ide-panel .copy-button{position:absolute;top:.3em;right:.3em;padding:.45em;display:flex;align-items:center;justify-content:center;transition:opacity .2s;opacity:0;background:transparent;border:0;border-radius:4px;cursor:pointer;color:#555;}.luogusp-ide-panel .copy-button.copied{color:#52c41a;}.luogusp-ide-panel .copy-icon{width:1em;height:1em;}145 行未改动全部展开unit.parentNode.insertBefore(clone, unit.nextSibling);}// 洛谷是 SPA:首页顶栏↔内容页侧栏随路由切换而重挂,入口须在导航变化时补上(rAF 节流,加了就早退)。// ★受限内容接管页 document.write 后旧 body 上的观察器全灭——接管流程会重新调用本函数。// 格式随导航自适应:旧版竖排栏(nav.lfe-body,首页/剪贴板同款)=「插件/设置」两行,// 新版侧栏(nav.sidebar,columba 文章页等)=「插件设置」单行。function watchSettingButton() {let scheduled = false;const tick = () => {scheduled = false;86 行未改动// ============================================================// 显示隐藏的个人简介// 洛谷把个人简介改为「仅国际站可见」,但境内站服务器仍把 introduction 下发到页面同源数据里// (SSR 脚本 / lentille 接口),只是前端不渲染。这里读同源数据自行补显,无需跨域。// ============================================================function digIntro(obj, wantUid) {let result = null;(function walk(o, depth) {20 行未改动} catch (e) {/* 非纯 JSON,跳过 */}}// 2) SPA 换页等:同源 lentille 接口,返回 {template:"user.show",data:{user:{…introduction}}}。// 注意:旧 `?_contentOnly=1` 已死(返回 HTML 壳页,拦截页源实测 2026-07-22),// 正确姿势是带 x-lentille-request 头。try {const r = await fetch(`/user/${uid}`, {headers: { "x-lentille-request": "content-only" },});const intro = digIntro(await r.json(), uid);if (intro != null) return intro;} catch (e) {console.error("LuoguSP intro fetch:", e);266 行未改动全部展开const nativeCard = document.querySelector(".l-card");const card = nativeCard? nativeCard.cloneNode(false): document.createElement("div");card.className = "l-card luogusp-intro-card luogusp-mdstyle"; // mdstyle=纯样式作用域;intro-card=本功能所有权标记(勿混用)card.removeAttribute("id");card.removeAttribute("style"); // ★清掉克隆源卡的内联样式:某些卡带 --l-card--padding:0 会让内容贴框card.style.setProperty("--l-card--padding", "20.8px"); // 用国际站 intro 卡的内边距(洛谷 .l-card 靠此变量控制)// 头部:用国际站原生结构(.header > h3[margin=0]),让标题继承浏览器 h3 的字号与粗细。715 行未改动全部展开),);}function finishIdeSummary() {if (!IDE_BATCH.summaryEl || !IDE_BATCH.results) return;const rs = IDE_BATCH.results;const counts = {};106 行未改动全部展开'<span class="luogusp-ide-title">样例测试</span>' +'<span class="luogusp-ide-summary">尚未运行</span>' +'<span class="luogusp-ide-headbtns"></span>' +"</div>" +'<div class="luogusp-ide-rows"></div>';// 停止/重新测试:同样克隆原生「自测」继承样式const tpl = [...document.querySelectorAll(`${SELECTORS.ideToolbar} button`),].find(27 行未改动IDE_BATCH.panel = panel;IDE_BATCH.ioLayout = ioLayout;IDE_BATCH.rowsEl = panel.querySelector(".luogusp-ide-rows");IDE_BATCH.summaryEl = panel.querySelector(".luogusp-ide-summary");syncIdeTabVisibility();}function switchIdeTab(tab) {IDE_BATCH.activeTab = tab;106 行未改动全部展开ensureIdeBatchUI();}// ============================================================// 受限文章/剪贴板就地显示(原生壳注入)// 国内站访问非本人/未审核的 /article、/paste 会落在「安全访问中心」拦截页// (独立静态页、零全站样式、无 CSP)。本功能在拦截页上重建官方页面:// 1) 壳骨架收割:从 .cn 同源页拿官方壳(columba 源=/ranking 等,lfe 源=/image 等;// 骨架自带真实 csrf、当前登录用户、用户主题、官方脚本当前版本——全部活取,绝不写死);// 2) 数据合成:把保存站存档映射为官方数据壳// (文章=lentille-context template "article.show";剪贴板=window._feInjection "PasteShow");// 3) document.write 重建文档并加载官方前端 JS——顶栏/侧栏/主题/登录态/markdown/评论组件// 全部由洛谷原生前端渲染,本脚本零复刻(2026-07-22 owner 拍板弃手工烘焙路线);// 4) fetch 拦截(window 不随 document.write 重建,包装器天然存活):// 评论接口 GET /article/{id}/replies 喂保存站存档,// 形状 {replySlice:[{id,author:userSummary,time,content}]},sort=time-d、after=<id> 分页(20/页);// 5) 官方渲染完成后注入两枚蓝色扩展按钮(申请更新 / 国际站原文):// 文章页=互动条 button-2line 挂「不推荐」右侧;剪贴板页=源码卡下方 lfe 实心按钮。// 数据源=洛谷保存站 api.luogu.me(CORS 开放、匿名;owner 拍板纯保存站+更新仅手动);// 作者数据走 .cn 同源 /api/user/search(owner 要求不吃保存站/国际站的用户数据)。// ★保存站硬边界:payload 的 createdAt 是入档时间,非原文发布时间(无接口可取原始时间)。// ============================================================const SAVER_API = "https://api.luogu.me";async function saverGet(path) {const res = await fetch(SAVER_API + path);return res.json(); // 统一壳 {code,message,data};业务码 404=未收录}async function saverPost(path, body) {const res = await fetch(SAVER_API + path, {method: "POST",headers: body ? { "content-type": "application/json" } : undefined,body: body ? JSON.stringify(body) : undefined,});return res.json();}// 拦截页判定:URL 形态 + 标题 + pre#url 内容三重锚点;不满足=正常页面,绝不接管function restrictedPageInfo() {const m = location.pathname.match(/^\/(article|paste)\/([A-Za-z0-9]+)\/?$/);if (!m) return null;if (document.title.indexOf("安全访问中心") === -1) return null;const pre = document.querySelector(SELECTORS.restrictedUrlPre);const target = pre ? (pre.textContent || "").trim() : "";if (target.indexOf(`/${m[1]}/${m[2]}`) === -1) return null;return {type: m[1],id: m[2],origUrl: target || `https://www.luogu.com/${m[1]}/${m[2]}`,};}// 最小自有样式:加载层/失败卡(注入拦截页文档),扩展按钮样式随壳 HTML 走(见 RST_EXTRA_CSS)function injectRstStyle() {if (document.getElementById("luogusp-rst-style")) return;const style = document.createElement("style");style.id = "luogusp-rst-style";style.textContent = `.luogusp-rst-loader{position:fixed;inset:0;z-index:2147483000;background:#f5f5f5;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:14px;color:#595959;font:14px/1.5 -apple-system,BlinkMacSystemFont,"Helvetica Neue","PingFang SC","Noto Sans SC","Microsoft YaHei",sans-serif;}.luogusp-rst-spinner{width:36px;height:36px;border:3px solid rgba(52,152,219,.25);border-top-color:#3498db;border-radius:50%;animation:luogusp-rst-spin .8s linear infinite;}@keyframes luogusp-rst-spin{to{transform:rotate(360deg);}}.luogusp-rst-plain{margin:0;background:#f5f5f5;font:16px/1.5 -apple-system,BlinkMacSystemFont,"Helvetica Neue","PingFang SC","Noto Sans SC","Microsoft YaHei",sans-serif;color:#404040;}.luogusp-rst-plain a{color:#3498db;text-decoration:none;}.luogusp-rst-plaincard{max-width:640px;margin:15vh auto 0;background:#fff;border-radius:4px;box-shadow:0 1px 3px rgba(26,26,26,.1);padding:1.5em;}.luogusp-rst-note{color:#999;font-size:12px;text-align:center;margin:24px 0;}`;(document.head || document.documentElement).appendChild(style);}// 扩展按钮样式(写进壳文档;蓝色=与原生灰色互动钮区分,owner 拍板)。// ★button-2line 的官方规则是 data-v 作用域的,注入节点吃不到 → 布局自带(镜像官方值)。const RST_EXTRA_CSS =".luogusp-rst-abtn{display:flex;flex-direction:column;align-items:center;margin:0 1em;cursor:pointer;}" +".luogusp-rst-abtn .icon{font-size:1.25em;margin-bottom:.3em;}" +".luogusp-rst-abtn .text{text-align:center;font-size:.75em;}" +".luogusp-rst-abtn>*{color:#3498db !important;}" +".luogusp-rst-pactions{display:flex;align-items:center;}" +".luogusp-rst-pbtn{font-size:.875em;line-height:1.5;padding:.3125em 1em;margin-left:.5em;color:#fff;background:#3498db;border:1px solid #3498db;border-radius:3px;cursor:pointer;}" +".luogusp-rst-pbtn:hover{background:rgba(52,152,219,.9);}";// 扩展按钮图标(FontAwesome Free 6.7.2 solid 原版 path:arrows-rotate / arrow-up-right-from-square)const RST_BTN_ICONS = {refresh: {vb: "0 0 512 512",d: "M105.1 202.6c7.7-21.8 20.2-42.3 37.8-59.8c62.5-62.5 163.8-62.5 226.3 0L386.3 160 352 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l111.5 0c0 0 0 0 0 0l.4 0c17.7 0 32-14.3 32-32l0-112c0-17.7-14.3-32-32-32s-32 14.3-32 32l0 35.2L414.4 97.6c-87.5-87.5-229.3-87.5-316.8 0C73.2 122 55.6 150.7 44.8 181.4c-5.9 16.7 2.9 34.9 19.5 40.8s34.9-2.9 40.8-19.5zM39 289.3c-5 1.5-9.8 4.2-13.7 8.2c-4 4-6.7 8.8-8.1 14c-.3 1.2-.6 2.5-.8 3.8c-.3 1.7-.4 3.4-.4 5.1L16 432c0 17.7 14.3 32 32 32s32-14.3 32-32l0-35.1 17.6 17.5c0 0 0 0 0 0c87.5 87.4 229.3 87.4 316.7 0c24.4-24.4 42.1-53.1 52.9-83.8c5.9-16.7-2.9-34.9-19.5-40.8s-34.9 2.9-40.8 19.5c-7.7 21.8-20.2 42.3-37.8 59.8c-62.5 62.5-163.8 62.5-226.3 0l-.1-.1L125.6 352l34.4 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L48.4 288c-1.6 0-3.2 .1-4.8 .3s-3.1 .5-4.6 1z",},external: {vb: "0 0 512 512",d: "M320 0c-17.7 0-32 14.3-32 32s14.3 32 32 32l82.7 0L201.4 265.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L448 109.3l0 82.7c0 17.7 14.3 32 32 32s32-14.3 32-32l0-160c0-17.7-14.3-32-32-32L320 0zM80 32C35.8 32 0 67.8 0 112L0 432c0 44.2 35.8 80 80 80l320 0c44.2 0 80-35.8 80-80l0-112c0-17.7-14.3-32-32-32s-32 14.3-32 32l0 112c0 8.8-7.2 16-16 16L80 448c-8.8 0-16-7.2-16-16l0-320c0-8.8 7.2-16 16-16l112 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L80 32z",},};function rstAvatar(uid) {return `https://cdn.luogu.com.cn/upload/usericon/${uid}.png`;}// 作者等用户数据一律走国内站同源接口(owner 要求:不吃保存站/国际站的用户数据;头像也全走 .cn CDN)。// 接口=/api/user/search?keyword={uid}(拦截页源实测可用;旧 /user/{uid}?_contentOnly=1 已死,返回 HTML),// 返回 userSummary:{uid,name,avatar,slogan,badge,color,ccfLevel,xcpcLevel,…}。失败回退存档快照。const rstUserCache = new Map();async function rstCnUser(uid) {if (!uid) return null;if (rstUserCache.has(uid)) return rstUserCache.get(uid);let user = null;try {const res = await fetch(`/api/user/search?keyword=${encodeURIComponent(uid)}`,);const json = await res.json();const list = (json && json.users) || [];user = list.find((u) => u && Number(u.uid) === Number(uid)) || null;} catch (e) {/* 回退存档快照 */}rstUserCache.set(uid, user);return user;}// 官方 userSummary:.cn 接口结果优先,保存站作者快照兜底补形function rstUserSummary(cnUser, snapshot, uid) {if (cnUser) return cnUser;const s = snapshot || {};return {uid: Number(uid) || 0,avatar: rstAvatar(uid || 0),name: s.name || `用户 ${uid || "?"}`,slogan: "",badge: s.badge || null,isAdmin: false,isBanned: false,color: s.color || "Gray",ccfLevel: s.ccfLevel || 0,xcpcLevel: s.xcpcLevel || 0,background: "",};}// 加载动效覆盖层:检测命中后立即出现(盖住拦截页),document.write 重建文档时自然消失function rstShowLoader(text) {injectRstStyle();let el = document.getElementById("luogusp-rst-loader");if (!el) {el = document.createElement("div");el.id = "luogusp-rst-loader";el.className = "luogusp-rst-loader";el.innerHTML ='<div class="luogusp-rst-spinner"></div><div class="msg">加载中…</div>';(document.body || document.documentElement).appendChild(el);}el.querySelector(".msg").textContent = text || "加载中…";}function rstHideLoader() {const el = document.getElementById("luogusp-rst-loader");if (el) el.remove();}function rstBuildFailure(info, reason) {document.title =(info.type === "article" ? "文章" : "云剪贴板") + " - 洛谷";document.body.className = "luogusp-rst-plain";document.body.innerHTML = `<div class="luogusp-rst-plaincard"><h1 style="font-size:20px;margin:0 0 10px;">未能获取内容</h1><p></p><p>可能原因:内容未公开、未通过审核,或保存站暂时不可用。</p><p><a href="${info.origUrl}" rel="noopener noreferrer">前往国际站查看原文 →</a></p><p class="luogusp-rst-note">此页面由 LuoguSP 生成 · 数据来源:洛谷保存站</p></div>`;document.querySelector(".luogusp-rst-plaincard p").textContent =String(reason);}// 壳骨架收割:候选源逐个尝试(2026-07-22 实测:/ranking、/discuss 已迁 columba;// /image、/theme/list 仍为 lfe。任一命中即用;全挂=降级失败卡)async function rstHarvest(kind) {const sources =kind === "columba" ? ["/ranking", "/discuss"] : ["/image", "/theme/list"];const marker = kind === "columba" ? "lentille-context" : "_feInjection";for (const src of sources) {try {const res = await fetch(src);const html = await res.text();if (html.includes(marker)) return html;} catch (e) {/* 换下一个源 */}}return null;}// 嵌入 <script> 的 JSON 防拆壳(内容里出现 </script> 会截断壳文档)function rstJsonForScript(obj) {return JSON.stringify(obj).replace(/</g, "\\u003C");}// 评论接口桩:官方文章组件启动后会 GET /article/{lid}/replies(?sort=&after=)。// window.fetch 包装器不随 document.write 重建,天然对新文档生效;其余请求全部放行。function rstStubReplies(lid, comments) {const mapped = comments.map((c, i) => {const a = c.author || {};return {id: i + 1,author: rstUserSummary(null, a, a.id),time: Number(c.time) || 0,content: String(c.content || ""),};});const re = new RegExp(`/article/${lid}/replies`);const realFetch = window.fetch.bind(window);window.fetch = function (input, init) {const url =typeof input === "string" ? input : (input && input.url) || "";if (re.test(url)) {let list = mapped;try {const q = new URL(url, location.origin).searchParams;if (q.get("sort") === "time-d")list = [...mapped].sort((x, y) => y.time - x.time);const after = Number(q.get("after"));let start = 0;if (after) {const idx = list.findIndex((r) => r.id === after);start = idx >= 0 ? idx + 1 : list.length;}list = list.slice(start, start + 20);} catch (e) {list = mapped.slice(0, 20);}return Promise.resolve(new Response(JSON.stringify({ replySlice: list }), {status: 200,headers: { "content-type": "application/json" },}),);}return realFetch(input, init);};}// 文章页:合成 lentille-context(template article.show)+ 官方 columba 前端async function rstBootArticle(info, data) {const [scaffold, cnUser, commentsQ] = await Promise.all([rstHarvest("columba"),rstCnUser(data.authorId),saverGet(`/article/comments/${info.id}`).catch(() => null),]);if (!scaffold)return rstBuildFailure(info, "无法获取洛谷页面骨架,暂不能就地渲染。");const pick = (re) => {const m = scaffold.match(re);return m ? m[1] : null;};const ctxRaw = pick(/<script id="lentille-context" type="application\/json">([\s\S]*?)<\/script>/,);const themeRaw =pick(/<script id="luogu-theme" type="application\/json">([\s\S]*?)<\/script>/,) || "";const csrf = pick(/<meta name="csrf-token" content="([^"]+)"/) || "";const globalsRaw =pick(/<script>\s*(window\.__feInitLocalTime[\s\S]*?)<\/script>/) || "";const scripts = [...scaffold.matchAll(/<script src="(https:\/\/fecdn\.luogu\.com\.cn\/[^"]+)"[^>]*><\/script>/g,),].map((m) => m[1]);const cssLinks = [...scaffold.matchAll(/<link rel="stylesheet" href="(https:\/\/fecdn\.luogu\.com\.cn\/[^"]+)"/g,),].map((m) => m[1]);if (!ctxRaw || !scripts.length)return rstBuildFailure(info, "洛谷页面骨架解析失败(结构可能已改版)。");let viewer = null;try {viewer = JSON.parse(ctxRaw).user || null;} catch (e) {/* 匿名兜底 */}const comments =(commentsQ && commentsQ.data && commentsQ.data.comments) || [];const ctx = {instance: "main",template: "article.show",status: 200,locale: "zh-CN",data: {article: {lid: data.id,title: data.title || "",category: data.category != null ? data.category : 1,// ★保存站只有入档时间(无原文发布时间接口),此处为已知近似time: Math.floor(new Date(data.createdAt).getTime() / 1000) || 0,author: rstUserSummary(cnUser, data.author, data.authorId),upvote: Number(data.upvote) || 0,replyCount: comments.length,favorCount: Number(data.favorCount) || 0,status: 2,solutionFor: null,promoteStatus: 0,collection: null,content: String(data.content || ""),contentFull: true,adminNote: null,},favored: false,voted: null,canReply: !!viewer,canEdit: false,},user: viewer,time: Math.floor(Date.now() / 1000),};rstStubReplies(info.id, comments);const title = String(data.title || "文章").replace(/</g, "<");const html =`<!DOCTYPE html><html lang="zh-CN" class="no-js"><head><meta charset="utf-8">` +`<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">` +`<meta name="csrf-token" content="${csrf}">` +`<title>${title} - 洛谷专栏</title>` +`<link rel="icon" href="https://fecdn.luogu.com.cn/favicon.ico">` +`<script>${globalsRaw}<\/script>` +`<script id="lentille-context" type="application/json">${rstJsonForScript(ctx)}<\/script>` +scripts.map((s) => `<script src="${s}" charset="utf-8" defer><\/script>`).join("") +cssLinks.map((c) => `<link rel="stylesheet" href="${c}" />`).join("") +`<script id="luogu-theme" type="application/json">${themeRaw}<\/script>` +`<style>${RST_EXTRA_CSS}</style>` +`</head><body><div id="app"></div></body></html>`;document.open();document.write(html);document.close();rstMountArticleButtons(info);// document.write 抹掉了启动期挂在旧 body 上的设置入口观察器 → 重挂(格式随导航自适应)injectStyle();watchSettingButton();}// 剪贴板页:合成 window._feInjection(currentTemplate PasteShow)+ 官方 lfe 前端async function rstBootPaste(info, data) {const [scaffold, cnUser] = await Promise.all([rstHarvest("lfe"),rstCnUser(data.authorId),]);if (!scaffold)return rstBuildFailure(info, "无法获取洛谷页面骨架,暂不能就地渲染。");const injRaw = (scaffold.match(/_feInjection = JSON\.parse\(decodeURIComponent\("([^"]+)"\)\)/,) || [])[1];const feCfg = (scaffold.match(/window\._feConfigVersion=(\d+)/) || [])[1];const tagVer = (scaffold.match(/window\._tagVersion=(\d+)/) || [])[1];const csrf =(scaffold.match(/<meta name="csrf-token" content="([^"]+)"/) || [])[1] ||"";const loaderCss = (scaffold.match(/<link rel="stylesheet" href="(https:\/\/fecdn\.luogu\.com\.cn\/[^"]+loader\.css[^"]*)"/,) || [])[1];const loaderJs = (scaffold.match(/<script src="(https:\/\/fecdn\.luogu\.com\.cn\/[^"]+loader\.js[^"]*)"/,) || [])[1];if (!injRaw || !loaderJs || !loaderCss)return rstBuildFailure(info, "洛谷页面骨架解析失败(结构可能已改版)。");let scafInj = {};try {scafInj = JSON.parse(decodeURIComponent(injRaw)) || {};} catch (e) {/* 匿名/默认主题兜底 */}const inj = {code: 200,currentTemplate: "PasteShow",currentData: {paste: {id: data.id,user: rstUserSummary(cnUser, data.author, data.authorId),// ★保存站只有入档时间(无原文发布时间接口),此处为已知近似time: Math.floor(new Date(data.createdAt).getTime() / 1000) || 0,public: true,data: String(data.content || ""),},canEdit: false,},currentTitle: "云剪贴板",currentTheme: scafInj.currentTheme || null,currentUser: scafInj.currentUser || null,currentTime: Math.floor(Date.now() / 1000),};const html =`<!DOCTYPE html><html class="no-js" lang="zh"><head><meta charset="utf-8">` +`<meta http-equiv="X-UA-Compatible" content="IE=edge">` +`<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">` +`<meta name="csrf-token" content="${csrf}">` +`<meta name="renderer" content="webkit">` +`<title>云剪贴板 - 洛谷 | 计算机科学教育新生态</title>` +`<link rel="shortcut icon" type="image/x-icon" href="https://fecdn.luogu.com.cn/favicon.ico" media="screen"/>` +`<link rel="stylesheet" href="${loaderCss}">` +`<style>${RST_EXTRA_CSS}</style>` +`<script>window._feInjection = JSON.parse(decodeURIComponent("${encodeURIComponent(JSON.stringify(inj))}"));window._feConfigVersion=${feCfg};window._tagVersion=${tagVer};<\/script>` +`<script src="${loaderJs}" charset="utf-8" defer><\/script>` +`</head><body><div id="app"><noscript><h3>请<b style="color:#f00;">不要禁用</b>脚本,否则网页无法正常加载</h3></noscript></div></body></html>`;document.open();document.write(html);document.close();rstMountPasteButtons(info);// document.write 抹掉了启动期挂在旧 body 上的设置入口观察器 → 重挂(格式随导航自适应)injectStyle();watchSettingButton();}// 扩展按钮(文章页):等官方前端渲染出互动条再注入;Vue 重渲染会抹节点,观察器负责补种function rstMountArticleButtons(info) {const make = (icon, extraCls, text, title, onClick) => {const div = document.createElement("div");div.className = `button-2line luogusp-rst-abtn ${extraCls}`;div.title = title;div.innerHTML = `<svg class="svg-inline--fa icon" style="font-size:1.25em" viewBox="${icon.vb}" aria-hidden="true"><path fill="currentColor" d="${icon.d}"/></svg><span class="text">${text}</span>`;div.addEventListener("click", onClick);return div;};const inject = () => {document.querySelectorAll(".article-content .actions").forEach((bar) => {// owner 拍板:左浮条(left-mode)不放扩展按钮,只挂内联互动条if (bar.classList.contains("left-mode")) return;if (bar.querySelector(".luogusp-rst-abtn")) return;bar.appendChild(make(RST_BTN_ICONS.refresh,"luogusp-rst-btn-refresh","申请更新","向保存站申请更新存档",() => rstManualRefresh(info),),);bar.appendChild(make(RST_BTN_ICONS.external,"","国际站原文","前往国际站查看原文(可点赞/收藏/评论)",() => window.open(info.origUrl, "_blank", "noopener"),),);});};inject();new MutationObserver(inject).observe(document.body || document.documentElement,{ childList: true, subtree: true },);}// 扩展按钮(剪贴板页):内容卡首行(content-card-top)最右侧两枚实心蓝钮// (首行是 flex space-between,作者信息在左,本容器落位最右)function rstMountPasteButtons(info) {const inject = () => {const top = document.querySelector(".card .content-card-top");if (!top || top.querySelector(".luogusp-rst-pactions")) return;const mk = (extraCls, text, title, onClick) => {const b = document.createElement("button");b.type = "button";b.className = `luogusp-rst-pbtn ${extraCls}`;b.textContent = text;b.title = title;b.addEventListener("click", onClick);return b;};const box = document.createElement("div");box.className = "luogusp-rst-pactions";box.append(mk("luogusp-rst-btn-refresh", "申请更新", "向保存站申请更新存档", () =>rstManualRefresh(info),),mk("", "国际站原文", "前往国际站查看原文", () =>window.open(info.origUrl, "_blank", "noopener"),),);top.appendChild(box);};inject();new MutationObserver(inject).observe(document.body || document.documentElement,{ childList: true, subtree: true },);}function rstQuery(info) {return saverGet(`/${info.type}/query/${info.id}`);}function rstTriggerSave(info) {return saverPost(`/workflow/create/template/${info.type}-save-pipeline`, {targetId: info.id,});}async function rstPollFresh(info, oldHash, times, gapMs) {for (let i = 0; i < times; i++) {await sleep(gapMs);let q;try {q = await rstQuery(info);} catch (e) {continue; // 网络抖动,下轮再试}if (q && q.code === 200 && q.data && q.data.contentHash !== oldHash)return q.data;}return null;}// 申请更新:发保存工作流(文章同时刷评论存档)→ 轮询到新档 → 整页重载重走接管;无变化=提示已最新let rstRefreshing = false;async function rstManualRefresh(info) {if (rstRefreshing) return;rstRefreshing = true;const setText = (t) => {document.querySelectorAll(".luogusp-rst-btn-refresh .text").forEach((el) => (el.textContent = t));document.querySelectorAll("button.luogusp-rst-btn-refresh").forEach((el) => (el.textContent = t));};setText("更新中…");try {const cur = await rstQuery(info);await rstTriggerSave(info);if (info.type === "article")saverPost(`/article/comments/${info.id}/refresh`).catch(() => {});const fresh = await rstPollFresh(info,cur && cur.data ? cur.data.contentHash : "",10,3000,);if (fresh) return location.reload();setText("已是最新");setTimeout(() => setText("申请更新"), 3000);} catch (e) {console.error("LuoguSP restricted refresh:", e);setText("更新失败");setTimeout(() => setText("申请更新"), 3000);} finally {rstRefreshing = false;}}async function rstBootPage(info, data) {try {if (info.type === "article") await rstBootArticle(info, data);else await rstBootPaste(info, data);} catch (e) {console.error("LuoguSP restricted boot:", e);rstBuildFailure(info, `原生页面装配失败:${e}`);}}async function rstRun() {const info = restrictedPageInfo();if (!info) return;let q;try {q = await rstQuery(info);} catch (e) {// 保存站不可达:撤掉加载层还原拦截页,仅置顶提示,保留原生跳转能力console.error("LuoguSP restricted:", e);rstHideLoader();const tip = document.createElement("p");tip.style.cssText ="margin:12px auto;max-width:640px;color:#e74c3c;font-size:13px;text-align:center;";tip.textContent ="LuoguSP:保存站(api.luogu.me)不可达,无法就地显示该内容。";document.body.insertBefore(tip, document.body.firstChild);return;}injectRstStyle();if (q && q.code === 200 && q.data) {// 已收录:直接装配存档,不自动申请更新(owner 拍板:更新只走「申请更新」按钮)return rstBootPage(info, q.data);}// 未收录:发起保存并等待入库(加载层持续转圈,完成后装配)rstShowLoader("该内容尚未被保存站收录,已自动发起收录…");try {await rstTriggerSave(info);} catch (e) {console.error("LuoguSP restricted save:", e);return rstBuildFailure(info, "向保存站发起收录请求失败。");}for (let i = 0; i < 15; i++) {await sleep(3000);let poll;try {poll = await rstQuery(info);} catch (e) {continue;}if (poll && poll.code === 200 && poll.data) {return rstBootPage(info, poll.data);}}rstBuildFailure(info, "保存站在限定时间内未能完成收录。");}function watchRestrictedPage() {// 拦截页是独立静态页,无 SPA。命中即刻盖上加载动效层(不闪原生跳转确认页),// 随后异步取数装配;取数失败会撤层还原拦截页。try {if (restrictedPageInfo()) rstShowLoader();} catch (e) {console.error("LuoguSP restricted loader:", e);}rstRun().catch((e) => console.error("LuoguSP restricted:", e));}// ============================================================// 启动// ============================================================const isChatPage = location.href.startsWith("https://www.luogu.com.cn/chat");10 行未改动},},{ key: `${STORAGE_PREFIX}showIntro`, run: watchHiddenIntro },{ key: `${STORAGE_PREFIX}ideBatchSampleTest`, run: watchIdeBatch },{ key: `${STORAGE_PREFIX}showRestrictedContent`, run: watchRestrictedPage },];injectStyle();for (const f of FEATURES) {9 行未改动