: 太大了。
*C register_badge
: 加上了注册脚本。也可以在 exlg.cc 使用。
: 写这个东西的人已经在崩溃的边缘了,球球各位不要催了。`;var Pr=".exlg-update-log-text{overflow-x:auto;white-space:nowrap;text-align:left}";v.reg_chore("update","检查更新","1D",".*",null,async()=>{let[e,t]=await Qe();t==="<<"&&N(`<p>检测到新版本 ${e},点击确定将安装。</p>`,"检测到新版本",()=>location.href="https://exlg.oss-cn-shanghai.aliyuncs.com/latest/dist/extend-luogu.min.user.js")});var Xo=["$","#<@"].map(e=>e.split("")),qr={Ty:{"-":"添加",x:"删减","!":"重大","*":"修改","^":"修复",$:"重构"},Op:{"-":"特性","?":"文档","#":"依赖","<":"代码风格",">":"命令",M:"模块",H:"钩子","@":"GitHub Action"}};v.reg("update-log","更新日志显示","@/.*",{last_version:{ty:"string",priv:!0},style:{ty:"enum",vals:["Commit Message","自然语言"],get:"id",info:["The way to display log","显示 Log 的方式"]},keep_dev:{ty:"boolean",dft:!0,info:["Keep developer messages","保留开发者更新信息"]}},({msto:e})=>{if(location.href.includes("blog"))return;let{version:t}=GM_info.script,r=!1,n=o=>{let i=`<div class="exlg-update-log-text" style="font-family: ${I["code-block-ex"].copy_code_font};">`;return o.split(`
`).forEach(s=>{let l=s.trimStart();if(l.length){if(e.keep_dev)r=!1;else if(l[0]===":"){if(!r)return}else if(Xo.some((d,u)=>d.includes(l[u]))){r=!1;return}else r=!0;e.style===1&&l[0]!==":"&&(s=" ".repeat(s.length-l.length)+qr.Ty[l[0]]+qr.Op[l[1]]+l.substring(2))}i+=`<div>${s.replace(/ /g," ")}</div>`}),`${i}</div>`};switch(pe(e.last_version,t)){case"==":break;case"<<":N(n(Rr),`extend-luogu ver. ${t} 更新日志`);case">>":e.last_version=t}},Pr,"module");var Br='<svg class="icon exlg-usercom-edit" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="942"><path d="M295.384615 708.923077h433.23077a19.692308 19.692308 0 1 1 0 39.384615h-433.23077a19.692308 19.692308 0 1 1 0-39.384615zM590.769231 303.576615L618.653538 275.692308l72.979693 73.019077-27.844923 27.844923L590.769231 303.576615z m-236.307693 196.923077L382.345846 472.615385l89.284923 89.324307-27.844923 27.844923L354.461538 500.499692zM401.329231 616.841846l308.342154-308.342154-55.689847-55.689846-308.381538 308.342154-8.152615 63.881846 63.881846-8.192z m-93.065846-74.043077l317.833846-317.833846a39.384615 39.384615 0 0 1 55.729231 0l55.689846 55.689846a39.384615 39.384615 0 0 1 0 55.689846l-317.833846 317.833847-127.763693 16.344615 16.344616-127.724308z" p-id="943"></path></svg>';var Ur=".exlg-usercom-edit{transition:all .4s;opacity:0;border-radius:.2em;margin-left:.2em;width:1em;height:1em;vertical-align:middle;fill:currentColor;overflow:hidden}.exlg-usercom-edit:hover{transition:all .4s;opacity:.8;background:rgba(0,0,0,.1)}.exlg-usercom-tag{color:#8a7b7b;font-weight:lighter;font-size:.9em;margin-left:.3em;line-height:1em;font-family:Consolas}";var V=null;v.reg_hook_new("user-comment","用户备注",".*",{comments:{ty:"string",dft:"{}",priv:!0},direct_display:{ty:"boolean",dft:!0,info:["Directly replace username","直接替换用户名"]}},({msto:e,result:t,args:r})=>{let n=(o,i,s=o.attr("exlg-usercom"))=>{if(!o||!o.length)return;if(o.length>1){o.each((d,u)=>n(g(u),i));return}let l=o;o.children("span[style]").length&&(l=o.children("span[style]")),e.direct_display?(l.css("white-space","pre"),l.text(i??s)):(l.children("span.exlg-usercom-tag").remove(),i&&l.append(`<span class="exlg-usercmt exlg-usercom-tag">(${i})</span>`))};if(!t){V=JSON.parse(e.comments);for(let[o,i]of Object.entries(V))(i===null||i==="")&&delete V[o];if(/^\/user\/[1-9][0-9]{0,}$/.test(location.pathname)){let o=g(".user-header-top > .user-info > div.user-name"),i=o[0].firstElementChild.innerText.trim(),s=+location.pathname.slice(6),l=g('<span id="exlg-name-text" style="font-size: medium;color: #ddd;" class="exlg-usercom-tag"></span>').appendTo(o);l.text(`(${s in V?V[s]:i})`),s in V||l.hide();let d=g(`<span title="修改用户备注">${Br}</span>`);o.append(d),d.on("click",()=>{N(`<div>请设置用户 <span style="font-family: Consolas;">${i} (uid: ${s})</span> 的备注名。<br/><small>留空则清除备注。</small></div><input exlg-badge-register type="text" style="font-family: Consolas;line-height: 1.5;padding: .1em;" class="am-form-field exlg-badge-input" placeholder="${i}" name="username" id="exlg-user-com-input">`,"exlg 用户备注",()=>{let u=g("#exlg-user-com-input").val();return u.trim()===""?(delete V[s],u=i,l.hide()):(V[s]=u.trim(),l.show()),n(g(`a[href="/user/${s}"][target=_blank]`),e.direct_display?V[s]??i:V[s],i),e.comments=JSON.stringify(V),l.text(`(${s in V?V[s]:i})`),!0}),g("#exlg-user-com-input").val(s in V?V[s]:i)})}}r.forEach(o=>{let i=g(o),s=o.href.split("/").at(-1);typeof i.attr("exlg-usercom")<"u"||(i.attr("exlg-usercom",i.text().trim()),(!s||s==="javascript:void 0")&&(s=g(o.parentNode.parentNode.previousElementSibling??o.parentNode.parentNode.parentNode.parentNode.parentNode.previousElementSibling).find("img").attr("src").replace(/[^0-9]/ig,"")),s in V&&n(i,V[s]))})},e=>{if(/^\/user\/[0-9]{0,}.*$/.test(location.pathname)&&(g(e.target).hasClass("feed")&&!g(e.target).hasClass("exlg-badge-feed")||/^#following/.test(location.hash)&&g(e.target).parent().hasClass("sub-body"))){let r=Array.from(e.target.querySelectorAll("a[target='_blank']")).filter(n=>!n.querySelectorAll("svg").length);return{result:r.length,args:r}}let t=e.target.querySelectorAll('a[href^="/user"][target=_blank]');return{result:t.length>0,args:t}},()=>{if(/^\/user\/[0-9]{0,}.*$/.test(location.pathname)){if(location.hash==="#activity")return Array.from(document.querySelectorAll(".feed .wrapper>a[target='_blank']")).filter(e=>!e.querySelectorAll("svg").length);if(/^#following/.test(location.hash))return Array.from(document.querySelectorAll(".follow-container .wrapper>a[target='_blank']")).filter(e=>!e.querySelectorAll("svg").length)}return document.querySelectorAll("a[target='_blank'][href^='/user/']")},Ur,"module");var Zr="iframe{border:none;display:block}iframe::-webkit-scrollbar{display:none}";v.reg_user_tab("user-intro-ins","用户首页_HTML_显示","main",null,null,()=>{function e(){g(".introduction > *").each(async(r,n,o=g(n))=>{let i,s=o.children()[0];g(s).length!==0&&s.nodeName==="A"?i=g(s).attr("href"):i=o.text();let[,,l,d]=i.match(/^(exlg.|%)([a-z|-]+):([^]+)$/)??[];if(!l)return;let u=d.split(/(?<!!)%/g).map(a=>a.replace(/!%/g,"%")),c=g(g(".user-action").children()[0]);if(l==="html")o.replaceWith(g(`<p exlg="exlg">${me.process(u[0])}</p>`));else if(l==="frame")o.replaceWith(Pe({type:"page",url:encodeURI(u[0]),confirm:!0},`width: ${u[1]}; height: ${u[2]};`));else if(l==="blog"){if(c.text().trim()!=="个人博客")return;c.attr("href",u),o.remove()}else if(l==="html-paste"){if(u[0].trim()==="")return;let a=await X(`/paste/${u[0].trim()}`);o.replaceWith(g(`<p exlg="exlg">${me.process(a.currentData.paste.data)}</p>`))}})}e();function t(r,n){return n===0?r:g(t(g(r.children()[0]),n-1))}t(g("section.main"),3).addClass("lg-editt"),g("button.lg-editt").on("click",()=>{let r=t(g("section.main"),2),n=g(r.children()[0]),o=g(r.children()[1]);n.addClass("lg-editt"),o.addClass("lg-editt"),e()})},Zr,"module");var gt={NOT_AT_PRACTICE_PAGE:-1,NONE:-2,COMMENT_TAG:-3,NOT_A_PROBLEM_ELEMENT:-4,PRIVATE_INFORMATION:-5,ADD_COMPARE:1};var Gr=".main>.card>h3{display:inline-block}";v.reg_v2({name:"user-problem-color",info:"题目颜色数量和比较",path:"@/user/[0-9]{0,}.*",cate:"module"},{problem_compare:{ty:"boolean",strict:!0,dft:!0,info:["AC compare","AC 题目比较"],migration:!0}},e=>{let t={SUBMITTED_PROBLEMS:0,PASSED_PROBLEMS:1},r=[[191,191,191],[254,76,97],[243,156,17],[255,193,22],[82,196,26],[52,152,219],[157,61,207],[14,29,105]],n,o,i=-1,s=t.SUBMITTED_PROBLEMS,l=-1;e.preload({name:"compare-problem",info:"比较通过的题目"},null,({gsto:d})=>{n=typeof E.submittedProblems>"u"||typeof E.passedProblems>"u",d.problem_compare&&!n&&(o=new Promise(u=>{X(`/user/${T.uid}`).then(c=>{u(new Set(c.currentData.passedProblems.map(a=>a.pid)))}).catch(c=>{U(c)})}))}),e.hook({name:"problem-color",info:"题目颜色"},null,({gsto:d,args:u})=>{if(n)return;let c=a=>`rgb(${r[a][0]},${r[a][1]},${r[a][2]})`;u.forEach(a=>{if(a.target.href!=="javascript:void 0"&&(a.target.style.setProperty("color",c([(a.board_id?E.passedProblems:E.submittedProblems)[a.position].difficulty]),"important"),a.board_id===t.PASSED_PROBLEMS&&a.position===E.passedProblems.length-1||E.passedProblems.length===0&&a.board_id===t.SUBMITTED_PROBLEMS&&a.position===E.submittedProblems.length-1)){g(".exlg-counter").remove();let p=a.target.parentNode.parentNode.parentNode.parentNode,f=[p.firstChild.childNodes[2],p.lastChild.childNodes[2]];for(let x=0;x<2;++x){let h=f[x],m=E[["submittedProblems","passedProblems"][x]];h.before(g(`<span id="exlg-problem-count-${x}" class="exlg-counter" exlg="exlg">${m.length}</span>`)[0])}if(!d.problem_compare||E.user.uid===T.uid)return;o.then(x=>{let h=0,m=f[1],b=E.passedProblems;m.querySelectorAll("a").forEach((w,k)=>{k<b.length&&x.has(b[k].pid)&&(h++,w.style.backgroundColor="rgba(82, 196, 26, 0.3)")}),g("#exlg-problem-count-1").html(`<span class="exlg-counter" exlg="exlg">${b.length} <> ${x.size} : ${h}<i class="exlg-icon exlg-info" name="ta 的 <> 我的 : 相同"></i></span>`)})}})},d=>{if(location.hash!=="#practice")return{result:!1};if(!E.submittedProblems.length&&!E.passedProblems.length){if(d.target.className==="card padding-default")if(g(d.target).children(".problems").length){let p=E[["submittedProblems","passedProblems"][l]];if(g(d.target.firstChild).after(`<span id="exlg-problem-count-${l}" class="exlg-counter" exlg="exlg" style="margin-left: 5px">${p.length}</span>`),++l>1)return{result:!0,args:{message:gt.ADD_COMPARE}}}else g(d.target).children(".difficulty-tags").length&&(l=0);return{result:!1,args:{message:gt.NONE}}}if(d.target.tagName.toLowerCase()!=="a"||d.target.className!=="color-default"||!d.target.pathname.startsWith("/problem/"))return{result:!1};let u=d.target,c=[E.submittedProblems[0]?.pid,E.passedProblems[0]?.pid].indexOf(u.href.slice(33)),a=c!==-1;return a?(s=c,i=0):i++,{result:!0,args:[{onchange:a,board_id:s,position:i,target:u}]}})},Gr);var Vr="#exlg-vp{margin-right:.5em;display:inline-block;flex:none;outline:0;cursor:pointer;color:#fff;font-weight:inherit;line-height:1.5;text-align:center;vertical-align:middle;background:0 0;border-radius:3px;border:1px solid;border-color:#52c41a;background-color:#52c41a}";v.reg("virtual-participation","创建重现赛","@/contest/[0-9]*(#.*)?",{},()=>{if(E.contest.name.match("Virtual Participation")){let e=g(".items"),t=()=>{(location.hash||"#main")==="#problems"&&g(".pid").length!==0&&E.contest.startTime>W()&&(g("a.title.color-default").on("click",()=>{N("比赛尚未开始,请开始后再查看题目")}),g("a.title.color-default").removeAttr("href"))};e.on("click",t),t();return}if(E.contest.endTime>W()){Q("Contest has not started or ended.");return}g("<button id='exlg-vp' class='lfe-form-sz-middle'>重现比赛</button>").appendTo(g("div.operation")).click(async()=>{N(`<div>
<p>设置「${E.contest.name}」的重现赛</p>
<p>开始时间:<input type="date" id="vpTmDt"/> <input type="time" id="vpTmClk"/></p>
</div><br>`,"创建重现赛",async()=>{let e=g("#vpTmDt")[0].value.split("-"),t=g("#vpTmClk")[0].value.split(":"),r=new Date(e[0],e[1]-1,e[2],t[0],t[1],0,0);r=r.getTime()/1e3;let n=[],o={};g.each(E.contestProblems,(d,u)=>{n.push(String(u.problem.pid)),o[u.problem.pid]=u.problem.fullScore});let i=null;i=await we("/fe/api/contest/new",JSON.stringify({settings:{name:`Virtual Participation for ${E.contest.name}`,description:E.contest.description,visibilityType:5,invitationCodeType:1,ruleType:E.contest.ruleType,startTime:r,endTime:r+E.contest.endTime-E.contest.startTime,rated:!1,ratingGroup:null},hostID:T.uid}));let s=i.id.toString();(i.status??200)===200?s=i.id.toString():U(`Failed to modify contest ${s} with status code ${i.status}.`),i=null;try{i=await we(`/fe/api/contest/editProblem/${s}`,JSON.stringify({pids:n,scores:o}))}catch{return setTimeout(N("<p>本场比赛的题目不公开</p>","重现赛创建失败"),500),!1}let l=await X(`/contest/edit/${s}`);return await we(`/fe/api/contest/join/${s}`,`{"code": "${l.currentData.contest.joinCode}"}`),N(`<p>邀请码: ${l.currentData.contest.joinCode}</p>
<p>点确定自动跳转</p>`,"重现赛创建成功",()=>(location.href=`https://www.luogu.com.cn/contest/${s}`,!0)),!1})})},Vr,"module");v.reg("meta-discussion-guiding","元讨论引导",["@/discuss/lists\\?forumname=(siteaffairs|problem|academics|relevantaffairs|service).*"],{},()=>{let e="432028",t=[/exlg/i,/ex(tend)?[- ]luogu/i,/badge/i],r=g("#newpost"),n=g(".lg-input-title"),o=g("#submitpost"),i=o.wrap("<div></div>").parent(),s=`<a href="/discuss/${e}"><b>专贴</b></a>`;r.after(`<p>exlg 相关问题请在 ${s} 讨论</p>`),i[0].addEventListener("click",l=>{let d=A.markdownPalettes.content?.toLowerCase(),u=n.val(),c=t.map(a=>[d.match(a)?.[0],u.match(a)?.[0]]).flat().filter((a,p,f)=>a&&a!==f[p+1]);if(c.length){l.stopPropagation();let a;N(`检测到您将要发送的讨论内容包含与 exlg 有关的关键词:<br />${c.map(p=>`“${p}”`).join(", ")}<br />建议前往 ${s} 讨论。<br />这是为了防止占用讨论资源,营造一个更高质量的社区。 <br />我们很担心 exlg 相关讨论霸占版面,造成负面影响。<br /><span style="color: orange"><b>洛谷管理员提醒您:发布无意义讨论可能导致禁言。</b> <br /><small>* 无意义讨论包括但不限于“大家看得到我的 badge 吗” 等等</small></span> <br />如果您确定要发送,请在下方输入框键入 “放心” 后确定。<br/><small comment>(输入框过一会才会出现)</small>`,"exlg 提醒您",{onconfirm:()=>!a||a.val()!=="放心"?!1:(setTimeout(o.trigger("click"),500),!0),onopen:async({dom:{$main:p}})=>{await Jt(3e3),p.find("small[comment]").remove(),a=g('<input type="text" />').appendTo(p)}})}},!0)},"","module");v.reg_lfe("import-problem-to-cph","添加到 cph",["@/problem/[A-Z]+[0-9]+[A-Z]*(#.*)?(\\?contestId=[0-9]*)?","@/record/.*","@/contest/[0-9]+(#.*)?"],{auto_hide_button:{ty:"boolean",dft:!0,strict:!0,info:["Auto Hide Button","自动隐藏按钮"]},problem_template:{ty:"string",dft:"Luogu_${pid}",info:["Custom Problemname Template (Not Contest)","自定义题目名称格式(非比赛)"]},contest_template:{ty:"string",dft:"Luogu_${cid}_${pid}",info:["Custom Problemname Template (Contest)","自定义题目名称格式(比赛)"]}},async e=>{function t(i,s="problem",l=0){g.get(i,d=>{function u(f){return new DOMParser().parseFromString(f,"text/html").documentElement}let c;d=u(d);for(let f of d.querySelectorAll("script")){let x=f.textContent;if(x.startsWith("window._feInjection")){let h=x.indexOf('"'),m=x.substr(h+1).indexOf('"'),b=x.substr(h+1,m);c=JSON.parse(decodeURIComponent(b)).currentData.problem}}if(c==null)throw new Error("Failed to find problem data");let a=[];for(let f of c.samples)a.push({input:f[0],output:f[1]});let p=e.msto.problem_template;s==="contest"&&(p=e.msto.contest_template,p=p.replace("${cid}",`${l}`)),p=p.replace("${pid}",c.pid),GM_xmlhttpRequest({url:"http://localhost:27121/",method:"POST",data:JSON.stringify({batch:{id:"exlg",size:1},name:p,group:"Luogu",url:i,interactive:"false",memoryLimit:Math.floor(Math.max(...c.limits.memory)/1024),timeLimit:Math.max(...c.limits.time),tests:a,input:{type:"stdin"},output:{type:"stdout"},language:{java:{mainClass:"Main",taskClass:c.pid}},testType:"single"}),onload(f){f.status===502&&N("未启动 cph,传输失败!")},onerror(){N("未启动 cph,传输失败!")}})})}if(!g("div.operation").length||window.location.href.search("/record/")!==-1)return;let r=new Promise(i=>{GM_xmlhttpRequest({url:"http://localhost:27121/",method:"POST",onload(){i(!0)},onerror(){i(!1)}})});function n(){window.location.href.search("/contest/")!==-1?g("button.exlg-cph").click(async()=>{let{href:i}=window.location,s=i.search("#");s!==-1&&(i=i.substring(0,s));let l=await X(i);l.currentData.contestProblems===null&&N("比赛未开始!");let d=l.currentData.contestProblems;for(let u=0;u<d.length;u++)t(`https://www.luogu.com.cn/problem/${d[u].problem.pid}`,"contest",l.currentData.contest.id)}):g("button.exlg-cph").click(()=>{t(window.location.href)})}!await r&&e.msto.auto_hide_button||(g("button.lfe-form-sz-middle").addClass("lg-btm"),window.location.href.search("#submit")===-1&&g("button.exlg-cph").length===0&&(g("div.operation").append('<button data-v-7ade990c="" data-v-43063e73="" type="button" class="exlg-cph lfe-form-sz-middle" data-v-2dfcfd35="" style="border-color: rgb(52, 152, 219); background-color: rgb(52, 152, 219);"> 传送至 cph </button>'),n()),g("button.lg-btm").click(()=>{window.location.href.search("#submit")===-1?g("button.exlg-cph").length===0&&(g("button.lfe-form-sz-middle").addClass("lg-btm"),g("div.operation").append('<button data-v-7ade990c="" data-v-43063e73="" type="button" class="exlg-cph lfe-form-sz-middle" data-v-2dfcfd35="" style="border-color: rgb(52, 152, 219); background-color: rgb(52, 152, 219);"> 传送至 cph </button>'),n()):g("button.exlg-cph").remove()}))},null,"module");var Fr=e=>JSON.parse(JSON.stringify(e)),F=(e,t)=>{throw globalThis[e](`[ProxyData] ${t}`)},pt=()=>({get:GM_getValue,set:GM_setValue,del:GM_deleteValue,list:GM_listValues});var ni=e=>e?.__scm__?.ty?e.__scm__.ty:e===null?"null":Array.isArray(e)?"array":e instanceof RegExp?"regexp":typeof e,oi={string_number:e=>+e,string_regexp:e=>e,number_string:e=>""+e,number_boolean:e=>!!e},ii={object:{layer:1,container:()=>({})},tuple:{layer:1,container:()=>[]},array:{layer:2,container:()=>[],api:(e,t,r=t.__scm__,n=t.__tar__)=>({$new(o,i=1){for(let s=o+i;o<s;o++){let l=e.scm.lvs[s];l&&F("ReferenceError",`Leaf @ ${l.path} already exists, but was attempted to re-new.`),Je(e,s,t,n,!0)}},get $length(){return r.lvs.length},$push(...o){return o.forEach(i=>t[r.lvs.length]=i),r.lvs.length},$fill(o,i=0,s=r.lvs.length){for(;i<s;i++)t[i]=o;return t},$pop(){let o=r.lvs.length,i=t[o-1];return delete t[o-1],r.lvs.length--,i},$splice(o,i){let s=r.lvs.length;for(i??=s,i=Math.min(s-o,i);o<s;o++)t[o]=o+i<s?t[o+i]:void 0;r.lvs.length-=i},$swap(o,i){t.__tmp__=t[o],t[o]=t[i],t[i]=t.__tmp__,delete t.__tmp__},$reverse(){let o=r.lvs.length,i=Math.floor(o/2);for(let s=0;s<i;s++)s in r.lvs&&t.$swap(s,o-s-1);return t},$includes(o){let i=r.lvs.length;for(let s=0;s<i;s++)if(s in r.lvs&&o===t[s])return!0;return!1},$indexOf(o){let i=r.lvs.length;for(let s=0;s<i;s++)if(s in r.lvs&&o===t[s])return+s;return-1},$lastIndexOf(o){for(let i=r.lvs.length-1;i>=0;i--)if(i in r.lvs&&o===t[i])return+i;return-1},$find(o){let i=r.lvs.length;for(let s=0;s<i;s++)if(s in r.lvs){let l=t[s];if(o(l))return l}},$findIndex(o){let i=r.lvs.length;for(let s=0;s<i;s++)if(s in r.lvs){let l=t[s];if(o(l))return+s}},$forEach(o){let i=r.lvs.length;for(let s=0;s<i;s++)s in r.lvs&&o(t[s],+s,t)},$at(o){return o<0?t[r.lvs.length+o]:t[o]},*[Symbol.iterator](){for(let o in r.lvs)yield t[o]}})}},Je=(e,t,r,n,o)=>{let{data:i,map:s,scm:l,oldRoot:d,old:u,access:c}=e;o&&(l.lvs[t]=Fr(l.itm));let a=l.lvs[t];a.path=(l.path??"")+"."+t;let p=ii[a.ty];a.layer=p?.layer??0,a.layer&&(i[t]=p.container(),a.layer>1&&(a.lvs=p.container()));let f=h=>JSON.stringify(h,null,2)+": ";a.ty==="enum"&&(a.get??="val",a.set??="val",a.fromOld=h=>{let m=a.set;a.set="id",r[t]=h,a.set=m},a.get!=="both"&&a.set==="both"&&F("SyntaxError",f(a)+"{ ty: 'enum' → ¬(get: 'both' ∧ set: ¬ 'both') }")),a.ty==="tuple"&&(a.lvs=a.lvs.flatMap(h=>{let m=1;return"repeat"in h&&(m=h.repeat,(typeof m!="number"||m<0||m%1)&&F("SyntaxError",f(a)+"{ ty: 'tuple' → itm: [ ∀ i: { repeat?: integer } } ]"),delete h.repeat),Array.from({length:m},()=>Fr(h))})),s(a),a.pathRoot=a.root?"#"+a.path:l.pathRoot??t,a.raw=(a.root?null:l.raw)??(()=>i[t]);let x={data:i[t],map:s,scm:a,oldRoot:d,old:u?.[t],access:c};if(a.layer)n[t]=Hr(x);else{let h=a.root?d[a.pathRoot]:u?.[t];h!==void 0?a.ty==="enum"?a.fromOld(h):r[t]=h:"dft"in a&&(r[t]=a.dft)}p?.api&&(a.api=p.api(x,n[t]))},Hr=e=>{let{data:t,scm:r,oldRoot:n,old:o,access:i}=e,s={},l=`Parent ${r.ty} @ ${r.path}`,d=c=>{if(typeof c!="symbol"&&r.ty==="array"){let a=l+` requires the index to be in [ ${r.minIdx??=0}, ${r.maxIdx??=1/0} ], but got ${c}. `;(c<r.minIdx||c>r.maxIdx)&&F("RangeError",a)}},u=new Proxy(s,{get:(c,a)=>{if(a==="__scm__")return r;if(a==="__tar__")return s;if(r.api&&a in r.api)return r.api[a];if(d(a),!r.lvs[a])switch(r.layer){case 1:F("TypeError",l+` doesn't have leaf ${a}.`);break;case 2:return}let p=r.lvs[a];if(p.ty==="enum")switch(p.get){case"id":return s[a];case"val":return p.vals[s[a]];case"both":return{get id(){return s[a]},set id(f){let x=p.set;p.set="id",u[a]=f,p.set=x},get val(){return p.vals[s[a]]},set val(f){let x=p.set;p.set="val",u[a]=f,p.set=x}}}return s[a]},set:(c,a,p)=>{if(d(a),!r.lvs[a])switch(r.layer){case 1:F("TypeError",l+` doesn't have leaf ${a}.`);break;case 2:Je(e,a,u,s,!0);break}r.api&&a in r.api&&F("TypeError",l+` has API ${a}. Failed.`);let f=r.lvs[a],x=`Leaf @ ${f.path}`,h="Failed strictly.",m=x+` is ${["simple","fixed complex","flexible complex"][f.layer]} type, `;f.locked&&F("TypeError",x+" is locked, but was attempted to modify.");let b=ni(p);if(b==="undefined"){if(r.layer===1&&!r.del&&F("TypeError",m+"but its "+x+" was attempted to delete."),f.layer){f.del=!0;for(let w in f.lvs)delete s[a][w]}delete r.lvs[a]}else if(b==="array"&&f.lvs instanceof Array||b==="object"&&f.lvs&&!(f.lvs instanceof Array)){for(let w in f.lvs)s[a][w]=p[w];return!0}else if(!["any","enum"].includes(f.ty)&&b!==f.ty){let w=x+` requires type ${f.ty}, but got ${b}: ${p}. `;f.strict&&F("TypeError",w+h);let k=oi[`${b}_${f.ty}`];k?p=k(p):F("TypeError",w+"Failed to convert.")}if(f.ty==="number"){let w=x+` requires to be in [ ${f.min??-1/0}, ${f.max??1/0} ], but got ${p}. `;(p<f.min||p>f.max)&&F("RangeError",w),f.int&&p%1&&(f.strict&&F("RangeError",x+" requires to be an integer. "+h),p=Math.floor(p))}else if(f.ty==="enum")switch(f.set){case"id":(typeof p!="number"||!p in f.vals)&&F("RangeError",x+` requires to be an enum index in [ ${0}, ${f.vals.length} ], but got ${p}.`);break;case"val":p=f.vals.findIndex(w=>w===p),p<0&&F("RangeError",x+` requires to be in the enum { ${f.vals.join(", ")} }, but got ${p}.`);break;case"both":F("TypeError",x+" is an enum accepting both id and value ways of modification, but was attempted to modify without using any setter.")}if(s[a]=t[a]=p,f.quick||f.root){let w=f.raw();w===void 0?i.del(f.pathRoot):i.set(f.pathRoot,w)}return!0},deleteProperty:(c,a)=>(u[a]=void 0,!0),has:(c,a)=>a in r.lvs});switch(r.layer){case 1:for(let a in r.lvs)Je(e,a,u,s);break;case 2:(r.itmRoot?Object.keys(n).map(a=>a.match(String.raw`^#${r.path}\.([^.]+)`)?.[1]).filter(a=>a):Object.keys(o??{})).forEach(a=>Je(e,a,u,s,!0));break}return u},Se=class{loadData(t,{access:r,autoSave:n,old:o,map:i}){return this.raw&&F("Error","ProxyData cannot be loaded multiple times."),this.raw={},this.access=r,o??=r.list().reduce((s,l)=>(s[l]=r.get(l),s),{}),n&&window.addEventListener("beforeunload",()=>this.saveData()),Hr({data:this.raw,scm:{lvs:t,layer:1},map:i??(s=>s),old:o,oldRoot:o,access:r})}saveData(t=this.raw){Object.keys(t).forEach(r=>this.access.set(r,t[r]))}clearData(){this.raw=null,this.access.list().forEach(this.access.del)}};M("Exposing");var Jr=new Se,Qr=Jr.loadData({settingVersion:{ty:"number",dft:0}},{access:pt()});Qr.settingVersion===0&&(GM_listValues().every(e=>typeof GM_getValue(e)=="string")&&GM_listValues().forEach(e=>GM_setValue(e,JSON.parse(GM_getValue(e)))),Qr.settingVersion=1,Jr.saveData());var Wr=new Se,Xr=Wr.loadData(J,{access:pt(),map:e=>{e.root=!e.rec,e.itmRoot=e.rec===2}});v.fake_sto=oe.sto=Xr;Object.assign(A,{exlg:{mod:v,compo:oe,scm:J,log:M,error:U,queues:ce,springboard:Pe,version_cmp:pe,lg_alert:Wt,lg_content:X,register_badge:He,lg_post:we,exlg_alert:N,xss:me,pd:Wr,sto:Xr},GM:{GM_info,GM_addStyle,GM_setClipboard,GM_xmlhttpRequest,GM_getValue,GM_setValue,GM_deleteValue,GM_listValues},$$:g});v.preload();v.execute_v2();ce.preload.apply();g(()=>{M("Launching"),ce.onload.apply()});})();
剪贴板
剪贴板 noky5r9t
剪贴板信息
剪贴板信息
- 收录
- 更新