From e6ca3d73fa51c79d233980b31bc0416775b45526 Mon Sep 17 00:00:00 2001 From: boomzero Date: Fri, 3 Oct 2025 18:28:33 +0800 Subject: [PATCH 01/14] Update CSS selector (#868) --- XMOJ.user.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/XMOJ.user.js b/XMOJ.user.js index 69dfca7f..e0cb1829 100644 --- a/XMOJ.user.js +++ b/XMOJ.user.js @@ -1726,6 +1726,9 @@ async function main() { if (SubmitLink == null) { //为什么这个破东西老是换位置 SubmitLink = document.querySelector('.mt-3 > center:nth-child(1) > a:nth-child(7)'); } + if (SubmitLink == null) { //tmd又换位置 + SubmitLink = document.querySelector('.mt-3 > center:nth-child(1) > a:nth-child(8)'); + } let SubmitButton = document.createElement('button'); SubmitButton.id = 'SubmitButton'; SubmitButton.className = 'btn btn-outline-secondary'; From a6d9d067fb6597a62d4a88ef59065bc4ccad518b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 3 Oct 2025 10:30:12 +0000 Subject: [PATCH 02/14] 2.4.5 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 169470fd..a3ac3141 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xmoj-script", - "version": "2.4.4", + "version": "2.4.5", "description": "an improvement script for xmoj.tech", "main": "AddonScript.js", "scripts": { From 76864317db669c04876971159eca757f189452cb Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 3 Oct 2025 10:30:18 +0000 Subject: [PATCH 03/14] Update version info to 2.4.5 --- Update.json | 11 +++++++++++ XMOJ.user.js | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Update.json b/Update.json index 96f64b2d..9c4a525a 100644 --- a/Update.json +++ b/Update.json @@ -3124,6 +3124,17 @@ } ], "Notes": "#860 ..." + }, + "2.4.5": { + "UpdateDate": 1759487413226, + "Prerelease": true, + "UpdateContents": [ + { + "PR": 869, + "Description": "Update CSS selector (again...)" + } + ], + "Notes": "为什么这个破东西老是换位置" } } } \ No newline at end of file diff --git a/XMOJ.user.js b/XMOJ.user.js index e0cb1829..f10f0fa4 100644 --- a/XMOJ.user.js +++ b/XMOJ.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name XMOJ -// @version 2.4.4 +// @version 2.4.5 // @description XMOJ增强脚本 // @author @XMOJ-Script-dev, @langningchen and the community // @namespace https://github/langningchen From 84054aa0959963d827e998592a97ebe1cbc9999b Mon Sep 17 00:00:00 2001 From: boomzero Date: Sat, 4 Oct 2025 11:32:31 +0800 Subject: [PATCH 04/14] Add tooltip for ProblemSwitcher --- XMOJ.user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/XMOJ.user.js b/XMOJ.user.js index f10f0fa4..f6e4f285 100644 --- a/XMOJ.user.js +++ b/XMOJ.user.js @@ -1695,7 +1695,7 @@ async function main() { if (problemList[i].url === location.href) { activeClass = "active"; } - problemSwitcher.innerHTML += `${buttonText}`; + problemSwitcher.innerHTML += `${buttonText}`; } document.body.appendChild(problemSwitcher); } From a0727e2595abf8b84d1b431cd863d0e0b5b2d98a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 4 Oct 2025 03:35:58 +0000 Subject: [PATCH 05/14] 2.4.6 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a3ac3141..d377dcd3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xmoj-script", - "version": "2.4.5", + "version": "2.4.6", "description": "an improvement script for xmoj.tech", "main": "AddonScript.js", "scripts": { From 822bb4ded3b3d7ebf03c68cadfd9e40b7c3eca0a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 4 Oct 2025 03:36:03 +0000 Subject: [PATCH 06/14] Update version info to 2.4.6 --- Update.json | 11 +++++++++++ XMOJ.user.js | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Update.json b/Update.json index 9c4a525a..f47aa41b 100644 --- a/Update.json +++ b/Update.json @@ -3135,6 +3135,17 @@ } ], "Notes": "为什么这个破东西老是换位置" + }, + "2.4.6": { + "UpdateDate": 1759548958578, + "Prerelease": true, + "UpdateContents": [ + { + "PR": 871, + "Description": "Add tooltip for ProblemSwitcher" + } + ], + "Notes": "现在, 你只需要将鼠标悬浮在比赛题目切换器上方, 即可查看题目名称" } } } \ No newline at end of file diff --git a/XMOJ.user.js b/XMOJ.user.js index f6e4f285..5db634a6 100644 --- a/XMOJ.user.js +++ b/XMOJ.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name XMOJ -// @version 2.4.5 +// @version 2.4.6 // @description XMOJ增强脚本 // @author @XMOJ-Script-dev, @langningchen and the community // @namespace https://github/langningchen From 4aaa1a3227b3b2435abffcb1796a50d1d1b848e6 Mon Sep 17 00:00:00 2001 From: boomzero Date: Sat, 4 Oct 2025 11:47:19 +0800 Subject: [PATCH 07/14] =?UTF-8?q?Revert=20"=E5=88=A0=E9=99=A4=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E6=95=B0=E6=8D=AE=E5=8A=9F=E8=83=BD"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 3b4873f59aae28c1055557ffe71140a0983dba1d. --- XMOJ.user.js | 117 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 116 insertions(+), 1 deletion(-) diff --git a/XMOJ.user.js b/XMOJ.user.js index 5db634a6..290bb789 100644 --- a/XMOJ.user.js +++ b/XMOJ.user.js @@ -1469,7 +1469,7 @@ async function main() { "Name": "恢复讨论与短消息功能" }, { "ID": "MoreSTD", "Type": "F", "Name": "查看到更多标程" - }, { + }, {"ID": "ApplyData", "Type": "A", "Name": "获取数据功能"}, { "ID": "AutoCheat", "Type": "A", "Name": "自动提交当年代码" }, {"ID": "Rating", "Type": "A", "Name": "添加用户评分和用户名颜色"}, { "ID": "AutoRefresh", "Type": "A", "Name": "比赛列表、比赛排名界面自动刷新" @@ -3477,6 +3477,121 @@ async function main() { if (document.getElementById("apply_data")) { let ApplyDiv = document.getElementById("apply_data").parentElement; console.log("启动!!!"); + if (UtilityEnabled("ApplyData")) { + let GetDataButton = document.createElement("button"); + GetDataButton.className = "ms-2 btn btn-outline-secondary"; + GetDataButton.innerText = "获取数据"; + console.log("按钮创建成功"); + ApplyDiv.appendChild(GetDataButton); + GetDataButton.addEventListener("click", async () => { + GetDataButton.disabled = true; + GetDataButton.innerText = "正在获取数据..."; + let PID = localStorage.getItem("UserScript-Solution-" + SearchParams.get("sid") + "-Problem"); + if (PID == null) { + GetDataButton.innerText = "失败! 无法获取PID"; + GetDataButton.disabled = false; + await new Promise((resolve) => { + setTimeout(resolve, 800); + }); + GetDataButton.innerText = "获取数据"; + return; + } + let Code = ""; + if (localStorage.getItem(`UserScript-Problem-${PID}-IOFilename`) !== null) { + Code = `#define IOFile "${localStorage.getItem(`UserScript-Problem-${PID}-IOFilename`)}"\n`; + } + Code += `//XMOJ-Script 获取数据代码 + #include +using namespace std; +string Base64Encode(string Input) +{ + const string Base64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + string Output; + for (int i = 0; i < Input.length(); i += 3) + { + Output.push_back(i + 0 > Input.length() ? '=' : Base64Chars[(Input[i + 0] & 0xfc) >> 2]); + Output.push_back(i + 1 > Input.length() ? '=' : Base64Chars[((Input[i + 0] & 0x03) << 4) + ((Input[i + 1] & 0xf0) >> 4)]); + Output.push_back(i + 2 > Input.length() ? '=' : Base64Chars[((Input[i + 1] & 0x0f) << 2) + ((Input[i + 2] & 0xc0) >> 6)]); + Output.push_back(i + 3 > Input.length() ? '=' : Base64Chars[Input[i + 2] & 0x3f]); + } + return Output; +} +int main() +{ +#ifdef IOFile + freopen(IOFile ".in", "r", stdin); + freopen(IOFile ".out", "w", stdout); +#endif + string Input; + while (1) + { + char Data = getchar(); + if (Data == EOF) + break; + Input.push_back(Data); + } + throw runtime_error("[" + Base64Encode(Input.c_str()) + "]"); + return 0; +}`; + + await fetch("https://www.xmoj.tech/submit.php", { + "headers": { + "content-type": "application/x-www-form-urlencoded" + }, + "referrer": "https://www.xmoj.tech/submitpage.php?id=" + PID, + "method": "POST", + "body": "id=" + PID + "&" + "language=1&" + "source=" + encodeURIComponent(Code) + "&" + "enable_O2=on" + }); + + let SID = await fetch("https://www.xmoj.tech/status.php").then((Response) => { + return Response.text(); + }).then((Response) => { + let ParsedDocument = new DOMParser().parseFromString(Response, "text/html"); + return ParsedDocument.querySelector("#result-tab > tbody > tr:nth-child(1) > td:nth-child(2)").innerText; + }); + + await new Promise((Resolve) => { + let Interval = setInterval(async () => { + await fetch("status-ajax.php?solution_id=" + SID).then((Response) => { + return Response.text(); + }).then((Response) => { + if (Response.split(",")[0] >= 4) { + clearInterval(Interval); + Resolve(); + } + }); + }, 500); + }); + + await fetch(`https://www.xmoj.tech/reinfo.php?sid=${SID}`).then((Response) => { + return Response.text(); + }).then((Response) => { + let ParsedDocument = new DOMParser().parseFromString(Response, "text/html"); + let ErrorData = ParsedDocument.getElementById("errtxt").innerText; + let MatchResult = ErrorData.match(/\what\(\): \[([A-Za-z0-9+\/=]+)\]/g); + if (MatchResult === null) { + GetDataButton.innerText = "获取数据失败"; + GetDataButton.disabled = false; + return; + } + for (let i = 0; i < MatchResult.length; i++) { + let Data = CryptoJS.enc.Base64.parse(MatchResult[i].substring(10, MatchResult[i].length - 1)).toString(CryptoJS.enc.Utf8); + ApplyDiv.appendChild(document.createElement("hr")); + ApplyDiv.appendChild(document.createTextNode("数据" + (i + 1) + ":")); + let CodeElement = document.createElement("div"); + ApplyDiv.appendChild(CodeElement); + CodeMirror(CodeElement, { + value: Data, + theme: (UtilityEnabled("DarkMode") ? "darcula" : "default"), + lineNumbers: true, + readOnly: true + }).setSize("100%", "auto"); + } + GetDataButton.innerText = "获取数据成功"; + GetDataButton.disabled = false; + }); + }); + } document.getElementById("apply_data").addEventListener("click", () => { let ApplyElements = document.getElementsByClassName("data"); for (let i = 0; i < ApplyElements.length; i++) { From 1d8db8bcfdf6729c9b6d7eddafda07458bea3e47 Mon Sep 17 00:00:00 2001 From: boomzero Date: Sat, 4 Oct 2025 11:48:58 +0800 Subject: [PATCH 08/14] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- XMOJ.user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/XMOJ.user.js b/XMOJ.user.js index 290bb789..5223c9c9 100644 --- a/XMOJ.user.js +++ b/XMOJ.user.js @@ -3530,7 +3530,7 @@ int main() break; Input.push_back(Data); } - throw runtime_error("[" + Base64Encode(Input.c_str()) + "]"); + throw logic_error("[" + Base64Encode(Input.c_str()) + "]"); return 0; }`; From b297b717f10cf689fb268a04a689a8e9768f94c2 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 4 Oct 2025 03:50:26 +0000 Subject: [PATCH 09/14] 2.4.7 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d377dcd3..bed46fd2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xmoj-script", - "version": "2.4.6", + "version": "2.4.7", "description": "an improvement script for xmoj.tech", "main": "AddonScript.js", "scripts": { From eef02d8ec437bd0414f49f12488985316b0d6acf Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 4 Oct 2025 03:50:31 +0000 Subject: [PATCH 10/14] Update version info to 2.4.7 --- Update.json | 11 +++++++++++ XMOJ.user.js | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Update.json b/Update.json index f47aa41b..3cfa82ff 100644 --- a/Update.json +++ b/Update.json @@ -3146,6 +3146,17 @@ } ], "Notes": "现在, 你只需要将鼠标悬浮在比赛题目切换器上方, 即可查看题目名称" + }, + "2.4.7": { + "UpdateDate": 1759549826774, + "Prerelease": true, + "UpdateContents": [ + { + "PR": 872, + "Description": "修复获取数据" + } + ], + "Notes": "funny" } } } \ No newline at end of file diff --git a/XMOJ.user.js b/XMOJ.user.js index 5223c9c9..a27eb5ec 100644 --- a/XMOJ.user.js +++ b/XMOJ.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name XMOJ -// @version 2.4.6 +// @version 2.4.7 // @description XMOJ增强脚本 // @author @XMOJ-Script-dev, @langningchen and the community // @namespace https://github/langningchen From ef32bc926bd3ca63bccfec0d60e6fdef1c86e206 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 4 Oct 2025 08:55:03 +0000 Subject: [PATCH 11/14] 2.5.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index bed46fd2..b0598518 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xmoj-script", - "version": "2.4.7", + "version": "2.5.0", "description": "an improvement script for xmoj.tech", "main": "AddonScript.js", "scripts": { From a33be0b5d570828f5c8c47b06aa2f389544138eb Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 4 Oct 2025 08:55:04 +0000 Subject: [PATCH 12/14] Update to release 2.5.0 --- Update.json | 35 +++++++++++++++++++++++++++++++++++ XMOJ.user.js | 2 +- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/Update.json b/Update.json index 3cfa82ff..7c45a663 100644 --- a/Update.json +++ b/Update.json @@ -3157,6 +3157,41 @@ } ], "Notes": "funny" + }, + "2.5.0": { + "UpdateDate": 1759568103629, + "Prerelease": false, + "UpdateContents": [ + { + "PR": 861, + "Description": "Update CSS selector" + }, + { + "PR": 863, + "Description": "修复“NaN年前“" + }, + { + "PR": 865, + "Description": "删除获取数据功能" + }, + { + "PR": 866, + "Description": "比赛题目页面里左侧栏加入题目序号列表" + }, + { + "PR": 869, + "Description": "Update CSS selector (again...)" + }, + { + "PR": 871, + "Description": "Add tooltip for ProblemSwitcher" + }, + { + "PR": 872, + "Description": "修复获取数据" + } + ], + "Notes": "XMOJ-Script 2.5.0 新增了比赛题目切换器,方便您在题目之间快速切换。此功能默认启用,您也可以在设置中禁用它。本版本还修复了一个导致时间显示为“NaN年前”的错误, 更新了一些 CSS selector,以适应 XMOJ 网站的最新变化." } } } \ No newline at end of file diff --git a/XMOJ.user.js b/XMOJ.user.js index a27eb5ec..9382516b 100644 --- a/XMOJ.user.js +++ b/XMOJ.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name XMOJ -// @version 2.4.7 +// @version 2.5.0 // @description XMOJ增强脚本 // @author @XMOJ-Script-dev, @langningchen and the community // @namespace https://github/langningchen From 9f5c20833e7888972c4407447633e45d352112ba Mon Sep 17 00:00:00 2001 From: Zhu Chenrui Date: Tue, 7 Oct 2025 17:51:57 +0800 Subject: [PATCH 13/14] refactor: simplify SubmitLink selection by querying all anchors and finding by text --- Update.json | 11 +++++++++++ XMOJ.user.js | 23 +++-------------------- package.json | 2 +- 3 files changed, 15 insertions(+), 21 deletions(-) diff --git a/Update.json b/Update.json index 7c45a663..127f787f 100644 --- a/Update.json +++ b/Update.json @@ -3192,6 +3192,17 @@ } ], "Notes": "XMOJ-Script 2.5.0 新增了比赛题目切换器,方便您在题目之间快速切换。此功能默认启用,您也可以在设置中禁用它。本版本还修复了一个导致时间显示为“NaN年前”的错误, 更新了一些 CSS selector,以适应 XMOJ 网站的最新变化." + }, + "2.5.1": { + "UpdateDate": 1759830659949, + "Prerelease": true, + "UpdateContents": [ + { + "PR": 876, + "Description": "refactor: simplify SubmitLink selection by querying all anchors and finding by text" + } + ], + "Notes": "No release notes were provided for this release." } } } \ No newline at end of file diff --git a/XMOJ.user.js b/XMOJ.user.js index 9382516b..cf08940d 100644 --- a/XMOJ.user.js +++ b/XMOJ.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name XMOJ -// @version 2.5.0 +// @version 2.5.1 // @description XMOJ增强脚本 // @author @XMOJ-Script-dev, @langningchen and the community // @namespace https://github/langningchen @@ -1710,25 +1710,8 @@ async function main() { document.querySelector("body > div > div.mt-3 > center").lastElementChild.style.marginLeft = "10px"; } //修复提交按钮 - let SubmitLink = document.querySelector('.mt-3 > center:nth-child(1) > a:nth-child(12)'); - if (SubmitLink == null) { //a special type of problem - SubmitLink = document.querySelector('.mt-3 > center:nth-child(1) > a:nth-child(10)'); - } - if (SubmitLink == null) { - SubmitLink = document.querySelector('.mt-3 > center:nth-child(1) > a:nth-child(11)'); - } - if (SubmitLink == null) { - SubmitLink = document.querySelector('.mt-3 > center:nth-child(1) > a:nth-child(13)'); - } - if (SubmitLink == null) { - SubmitLink = document.querySelector('.mt-3 > center:nth-child(1) > a:nth-child(9)'); - } - if (SubmitLink == null) { //为什么这个破东西老是换位置 - SubmitLink = document.querySelector('.mt-3 > center:nth-child(1) > a:nth-child(7)'); - } - if (SubmitLink == null) { //tmd又换位置 - SubmitLink = document.querySelector('.mt-3 > center:nth-child(1) > a:nth-child(8)'); - } + const links = document.querySelectorAll('.mt-3 > center:nth-child(1) > a'); + const SubmitLink = Array.from(links).find(a => a.textContent.trim() === '提交'); let SubmitButton = document.createElement('button'); SubmitButton.id = 'SubmitButton'; SubmitButton.className = 'btn btn-outline-secondary'; diff --git a/package.json b/package.json index b0598518..7dc97daa 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xmoj-script", - "version": "2.5.0", + "version": "2.5.1", "description": "an improvement script for xmoj.tech", "main": "AddonScript.js", "scripts": { From 10d68067ae61c2d804da5e7ab85e87193ab1996c Mon Sep 17 00:00:00 2001 From: Zhu Chenrui Date: Tue, 7 Oct 2025 22:06:18 +0800 Subject: [PATCH 14/14] =?UTF-8?q?fix:=20problem=20PID=20=E5=8F=AF=E8=83=BD?= =?UTF-8?q?=E4=B8=BA=20null=20(#877)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: problem PID 可能为 null * 2.5.2 * Update version info to 2.5.2 --------- Co-authored-by: github-actions[bot] --- Update.json | 11 +++++++++++ XMOJ.user.js | 28 ++++++++++++++++++++++++---- package.json | 2 +- 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/Update.json b/Update.json index 127f787f..043b5b37 100644 --- a/Update.json +++ b/Update.json @@ -3203,6 +3203,17 @@ } ], "Notes": "No release notes were provided for this release." + }, + "2.5.2": { + "UpdateDate": 1759845614758, + "Prerelease": true, + "UpdateContents": [ + { + "PR": 877, + "Description": "fix: problem PID 可能为 null" + } + ], + "Notes": "No release notes were provided for this release." } } } \ No newline at end of file diff --git a/XMOJ.user.js b/XMOJ.user.js index cf08940d..389809d0 100644 --- a/XMOJ.user.js +++ b/XMOJ.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name XMOJ -// @version 2.5.1 +// @version 2.5.2 // @description XMOJ增强脚本 // @author @XMOJ-Script-dev, @langningchen and the community // @namespace https://github/langningchen @@ -1645,7 +1645,28 @@ async function main() { } else if (location.pathname == "/problem.php") { await RenderMathJax(); if (SearchParams.get("cid") != null && UtilityEnabled("ProblemSwitcher")) { - document.getElementsByTagName("h2")[0].innerHTML += " (" + localStorage.getItem("UserScript-Contest-" + SearchParams.get("cid") + "-Problem-" + SearchParams.get("pid") + "-PID") + ")"; + let pid = localStorage.getItem("UserScript-Contest-" + SearchParams.get("cid") + "-Problem-" + SearchParams.get("pid") + "-PID"); + if (!pid) { + const contestReq = await fetch("https://www.xmoj.tech/contest.php?cid=" + SearchParams.get("cid")); + const res = await contestReq.text(); + if (contestReq.status === 200 && res.indexOf("比赛尚未开始或私有,不能查看题目。") === -1) { + const parser = new DOMParser(); + const dom = parser.parseFromString(res, "text/html"); + const rows = (dom.querySelector("#problemset > tbody")).rows; + for (let i = 0; i < rows.length; i++) { + let problemIdText = rows[i].children[1].innerText; // Get the text content + let match = problemIdText.match(/\d+/); // Extract the number + if (match) { + let extractedPid = match[0]; + localStorage.setItem("UserScript-Contest-" + SearchParams.get("cid") + "-Problem-" + i + "-PID", extractedPid); + } + } + pid = localStorage.getItem("UserScript-Contest-" + SearchParams.get("cid") + "-Problem-" + SearchParams.get("pid") + "-PID"); + } + } + if (pid) { + document.getElementsByTagName("h2")[0].innerHTML += " (" + pid + ")"; + } let ContestProblemList = localStorage.getItem("UserScript-Contest-" + SearchParams.get("cid") + "-ProblemList"); if (ContestProblemList == null) { const contestReq = await fetch("https://www.xmoj.tech/contest.php?cid=" + SearchParams.get("cid")); @@ -1727,8 +1748,7 @@ async function main() { // Remove the button's outer [] let str = document.querySelector('.mt-3 > center:nth-child(1)').innerHTML; let target = SubmitButton.outerHTML; - let result = str.replace(new RegExp(`(.?)${target}(.?)`, 'g'), target); - document.querySelector('.mt-3 > center:nth-child(1)').innerHTML = result; + document.querySelector('.mt-3 > center:nth-child(1)').innerHTML = str.replace(new RegExp(`(.?)${target}(.?)`, 'g'), target); document.querySelector('html body.placeholder-glow div.container div.mt-3 center button#SubmitButton.btn.btn-outline-secondary').onclick = function () { window.location.href = SubmitLink.href; console.log(SubmitLink.href); diff --git a/package.json b/package.json index 7dc97daa..b70e2ba3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xmoj-script", - "version": "2.5.1", + "version": "2.5.2", "description": "an improvement script for xmoj.tech", "main": "AddonScript.js", "scripts": {