xmoj-script 2.5.1 → 2.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Update.json +11 -0
- package/XMOJ.user.js +24 -4
- package/package.json +1 -1
package/Update.json
CHANGED
@@ -3203,6 +3203,17 @@
|
|
3203
3203
|
}
|
3204
3204
|
],
|
3205
3205
|
"Notes": "No release notes were provided for this release."
|
3206
|
+
},
|
3207
|
+
"2.5.2": {
|
3208
|
+
"UpdateDate": 1759845614758,
|
3209
|
+
"Prerelease": true,
|
3210
|
+
"UpdateContents": [
|
3211
|
+
{
|
3212
|
+
"PR": 877,
|
3213
|
+
"Description": "fix: problem PID 可能为 null"
|
3214
|
+
}
|
3215
|
+
],
|
3216
|
+
"Notes": "No release notes were provided for this release."
|
3206
3217
|
}
|
3207
3218
|
}
|
3208
3219
|
}
|
package/XMOJ.user.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
// ==UserScript==
|
2
2
|
// @name XMOJ
|
3
|
-
// @version 2.5.
|
3
|
+
// @version 2.5.2
|
4
4
|
// @description XMOJ增强脚本
|
5
5
|
// @author @XMOJ-Script-dev, @langningchen and the community
|
6
6
|
// @namespace https://github/langningchen
|
@@ -1645,7 +1645,28 @@ async function main() {
|
|
1645
1645
|
} else if (location.pathname == "/problem.php") {
|
1646
1646
|
await RenderMathJax();
|
1647
1647
|
if (SearchParams.get("cid") != null && UtilityEnabled("ProblemSwitcher")) {
|
1648
|
-
|
1648
|
+
let pid = localStorage.getItem("UserScript-Contest-" + SearchParams.get("cid") + "-Problem-" + SearchParams.get("pid") + "-PID");
|
1649
|
+
if (!pid) {
|
1650
|
+
const contestReq = await fetch("https://www.xmoj.tech/contest.php?cid=" + SearchParams.get("cid"));
|
1651
|
+
const res = await contestReq.text();
|
1652
|
+
if (contestReq.status === 200 && res.indexOf("比赛尚未开始或私有,不能查看题目。") === -1) {
|
1653
|
+
const parser = new DOMParser();
|
1654
|
+
const dom = parser.parseFromString(res, "text/html");
|
1655
|
+
const rows = (dom.querySelector("#problemset > tbody")).rows;
|
1656
|
+
for (let i = 0; i < rows.length; i++) {
|
1657
|
+
let problemIdText = rows[i].children[1].innerText; // Get the text content
|
1658
|
+
let match = problemIdText.match(/\d+/); // Extract the number
|
1659
|
+
if (match) {
|
1660
|
+
let extractedPid = match[0];
|
1661
|
+
localStorage.setItem("UserScript-Contest-" + SearchParams.get("cid") + "-Problem-" + i + "-PID", extractedPid);
|
1662
|
+
}
|
1663
|
+
}
|
1664
|
+
pid = localStorage.getItem("UserScript-Contest-" + SearchParams.get("cid") + "-Problem-" + SearchParams.get("pid") + "-PID");
|
1665
|
+
}
|
1666
|
+
}
|
1667
|
+
if (pid) {
|
1668
|
+
document.getElementsByTagName("h2")[0].innerHTML += " (" + pid + ")";
|
1669
|
+
}
|
1649
1670
|
let ContestProblemList = localStorage.getItem("UserScript-Contest-" + SearchParams.get("cid") + "-ProblemList");
|
1650
1671
|
if (ContestProblemList == null) {
|
1651
1672
|
const contestReq = await fetch("https://www.xmoj.tech/contest.php?cid=" + SearchParams.get("cid"));
|
@@ -1727,8 +1748,7 @@ async function main() {
|
|
1727
1748
|
// Remove the button's outer []
|
1728
1749
|
let str = document.querySelector('.mt-3 > center:nth-child(1)').innerHTML;
|
1729
1750
|
let target = SubmitButton.outerHTML;
|
1730
|
-
|
1731
|
-
document.querySelector('.mt-3 > center:nth-child(1)').innerHTML = result;
|
1751
|
+
document.querySelector('.mt-3 > center:nth-child(1)').innerHTML = str.replace(new RegExp(`(.?)${target}(.?)`, 'g'), target);
|
1732
1752
|
document.querySelector('html body.placeholder-glow div.container div.mt-3 center button#SubmitButton.btn.btn-outline-secondary').onclick = function () {
|
1733
1753
|
window.location.href = SubmitLink.href;
|
1734
1754
|
console.log(SubmitLink.href);
|