xmoj-script 1.2.47 → 1.2.49
Sign up to get free protection for your applications and to get access to all the features.
- package/Update.json +22 -0
- package/XMOJ.user.js +54 -3
- package/package.json +1 -1
package/Update.json
CHANGED
@@ -2307,6 +2307,28 @@
|
|
2307
2307
|
}
|
2308
2308
|
],
|
2309
2309
|
"Notes": "No release notes were provided for this release."
|
2310
|
+
},
|
2311
|
+
"1.2.48": {
|
2312
|
+
"UpdateDate": 1723183783191,
|
2313
|
+
"Prerelease": true,
|
2314
|
+
"UpdateContents": [
|
2315
|
+
{
|
2316
|
+
"PR": 671,
|
2317
|
+
"Description": "允许在已结束的比赛下提交 #287"
|
2318
|
+
}
|
2319
|
+
],
|
2320
|
+
"Notes": "No release notes were provided for this release."
|
2321
|
+
},
|
2322
|
+
"1.2.49": {
|
2323
|
+
"UpdateDate": 1723184271477,
|
2324
|
+
"Prerelease": true,
|
2325
|
+
"UpdateContents": [
|
2326
|
+
{
|
2327
|
+
"PR": 673,
|
2328
|
+
"Description": "Remove headers"
|
2329
|
+
}
|
2330
|
+
],
|
2331
|
+
"Notes": "No release notes were provided for this release."
|
2310
2332
|
}
|
2311
2333
|
}
|
2312
2334
|
}
|
package/XMOJ.user.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
// ==UserScript==
|
2
2
|
// @name XMOJ
|
3
|
-
// @version 1.2.
|
3
|
+
// @version 1.2.49
|
4
4
|
// @description XMOJ增强脚本
|
5
5
|
// @author @XMOJ-Script-dev, @langningchen and the community
|
6
6
|
// @namespace https://github/langningchen
|
@@ -2764,12 +2764,63 @@ async function main() {
|
|
2764
2764
|
"referrer": location.href,
|
2765
2765
|
"method": "POST",
|
2766
2766
|
"body": (SearchParams.get("id") != null ? "id=" + SearchParams.get("id") : "cid=" + SearchParams.get("cid") + "&pid=" + SearchParams.get("pid")) + "&language=1&" + "source=" + encodeURIComponent(CodeMirrorElement.getValue()) + "&" + "enable_O2=on"
|
2767
|
-
}).then((Response) => {
|
2767
|
+
}).then(async (Response) => {
|
2768
2768
|
if (Response.redirected) {
|
2769
2769
|
location.href = Response.url;
|
2770
2770
|
} else {
|
2771
|
+
const text = await Response.text();
|
2772
|
+
if (text.indexOf("没有这个比赛!") !== -1 && new URL(location.href).searchParams.get("pid") !== null) {
|
2773
|
+
// Credit: https://github.com/boomzero/quicksubmit/blob/main/index.ts
|
2774
|
+
// Also licensed under GPL-3.0
|
2775
|
+
const contestReq = await fetch("https://www.xmoj.tech/contest.php?cid=" + new URL(location.href).searchParams.get("cid"));
|
2776
|
+
const res = await contestReq.text();
|
2777
|
+
if (
|
2778
|
+
contestReq.status !== 200 ||
|
2779
|
+
res.indexOf("比赛尚未开始或私有,不能查看题目。") !== -1
|
2780
|
+
) {
|
2781
|
+
console.error(`Failed to get contest page!`);
|
2782
|
+
return;
|
2783
|
+
}
|
2784
|
+
const parser = new DOMParser();
|
2785
|
+
const dom = parser.parseFromString(res, "text/html");
|
2786
|
+
const contestProblems = [];
|
2787
|
+
const rows = (dom.querySelector(
|
2788
|
+
"#problemset > tbody",
|
2789
|
+
)).rows;
|
2790
|
+
for (let i = 0; i < rows.length; i++) {
|
2791
|
+
contestProblems.push(
|
2792
|
+
rows[i].children[1].textContent.substring(2, 6).replaceAll(
|
2793
|
+
"\t",
|
2794
|
+
"",
|
2795
|
+
),
|
2796
|
+
);
|
2797
|
+
}
|
2798
|
+
rPID = contestProblems[new URL(location.href).searchParams.get("pid")];
|
2799
|
+
if (UtilityEnabled("DebugMode")) {
|
2800
|
+
console.log("Contest Problems:", contestProblems);
|
2801
|
+
console.log("Real PID:", rPID);
|
2802
|
+
}
|
2803
|
+
ErrorElement.style.display = "block";
|
2804
|
+
ErrorMessage.style.color = "red";
|
2805
|
+
ErrorMessage.innerText = "比赛已结束, 正在尝试像题目 " + rPID + " 提交";
|
2806
|
+
console.log("比赛已结束, 正在尝试像题目 " + rPID + " 提交");
|
2807
|
+
await fetch("https://www.xmoj.tech/submit.php", {
|
2808
|
+
"headers": {
|
2809
|
+
"content-type": "application/x-www-form-urlencoded"
|
2810
|
+
},
|
2811
|
+
"referrer": location.href,
|
2812
|
+
"method": "POST",
|
2813
|
+
"body": "id=" + rPID + "&language=1&" + "source=" + encodeURIComponent(CodeMirrorElement.getValue()) + "&" + "enable_O2=on"
|
2814
|
+
}).then(async (Response) => {
|
2815
|
+
if (Response.redirected) {
|
2816
|
+
location.href = Response.url;
|
2817
|
+
}
|
2818
|
+
console.log(await Response.text());
|
2819
|
+
});
|
2820
|
+
|
2821
|
+
}
|
2771
2822
|
if (UtilityEnabled("DebugMode")) {
|
2772
|
-
console.log("Submission failed! Response:",
|
2823
|
+
console.log("Submission failed! Response:", text);
|
2773
2824
|
}
|
2774
2825
|
ErrorElement.style.display = "block";
|
2775
2826
|
ErrorMessage.style.color = "red";
|