Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
162d588
Merge pull request #772 from XMOJ-Script-dev/dev
boomzero Feb 8, 2025
d724438
Merge pull request #781 from XMOJ-Script-dev/dev
boomzero Feb 21, 2025
8b4a2c1
Merge pull request #786 from XMOJ-Script-dev/dev
boomzero Feb 23, 2025
e40b292
Merge pull request #800 from XMOJ-Script-dev/dev
boomzero May 4, 2025
c8ed5aa
Merge pull request #804 from XMOJ-Script-dev/dev
boomzero Jun 4, 2025
e4f659f
Merge pull request #813 from XMOJ-Script-dev/dev
boomzero Jun 22, 2025
d24fe86
Merge pull request #819 from XMOJ-Script-dev/dev
boomzero Jul 10, 2025
1a75572
Merge pull request #823 from XMOJ-Script-dev/dev
boomzero Jul 25, 2025
b789bf2
Update Update.json
boomzero Jul 25, 2025
13058b6
Merge pull request #827 from XMOJ-Script-dev/dev
boomzero Aug 9, 2025
c22fd31
Merge pull request #836 from XMOJ-Script-dev/dev
boomzero Aug 22, 2025
6adac8d
Parse release notes from comment block
boomzero Aug 24, 2025
f86a45e
Update bug.yml
boomzero Aug 24, 2025
84474cc
Merge pull request #854 from XMOJ-Script-dev/dev
boomzero Sep 14, 2025
7950ae8
Merge pull request #857 from XMOJ-Script-dev/dev
boomzero Sep 27, 2025
dfe8cf8
Merge pull request #874 from XMOJ-Script-dev/dev
boomzero Oct 4, 2025
54d39cf
Update GitHub Actions workflow to skip bot triggers
PythonSmall-Q Feb 7, 2026
462621a
Merge pull request #891 from XMOJ-Script-dev/dev
PythonSmall-Q Feb 7, 2026
27863a7
Prevent UpdateVersion from running if last commit was by github-actio…
boomzero Feb 11, 2026
280bc24
Merge branch 'master' of github.com:XMOJ-Script-dev/XMOJ-Script
boomzero Feb 11, 2026
4a671fc
Merge pull request #908 from XMOJ-Script-dev/dev
boomzero Feb 16, 2026
e3bbe9e
Merge pull request #912 from XMOJ-Script-dev/dev
boomzero Feb 19, 2026
fab6593
Allow metadata updates on edited PRs after bot version commit
boomzero Feb 23, 2026
2f7e9d6
Allow metadata updates on edited PRs after bot version commit
boomzero Feb 23, 2026
e14e33c
Merge pull request #921 from XMOJ-Script-dev/dev
boomzero Feb 27, 2026
7551f8c
Merge pull request #956 from XMOJ-Script-dev/dev
PythonSmall-Q Mar 28, 2026
d833b40
Add Google Ads script to index.html
PythonSmall-Q May 3, 2026
bdd5dc7
Remove Google Ads script from index.html
PythonSmall-Q May 3, 2026
2126971
Add Google ad publisher entry to ads.txt
PythonSmall-Q May 3, 2026
a6251c3
Merge pull request #983 from XMOJ-Script-dev/dev
PythonSmall-Q May 23, 2026
1aa1b02
Merge pull request #999 from XMOJ-Script-dev/dev
boomzero Jul 27, 2026
5fe3558
fix: 修复已结束比赛提交回退功能失效 #1017
INFP-coder Aug 23, 2026
5f70e73
Refix
INFP-coder Aug 23, 2026
d65ae84
Refix
INFP-coder Aug 23, 2026
6e587af
Merge branch 'extern-contrib' into master
INFP-coder Aug 23, 2026
238bc2c
Update?
INFP-coder Aug 23, 2026
825161e
Update?
INFP-coder Aug 23, 2026
0e0a5eb
fixed
INFP-coder Aug 23, 2026
9f07ee2
fixed?
INFP-coder Aug 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Update.json
Original file line number Diff line number Diff line change
Expand Up @@ -2937,7 +2937,7 @@
],
"Notes": "No release notes were provided for this release."
},
"1.10.0": {
"1.999990.0": {
Comment thread
zsTree0830 marked this conversation as resolved.
"UpdateDate": 1753443146018,
"Prerelease": false,
"UpdateContents": [
Expand Down Expand Up @@ -3718,4 +3718,4 @@
"Notes": "优化“获取数据”功能:页面缺少数据申请区域时会自动创建控件;默认使用 gzip + Base93 精确保留任意输入;新增约 310 MB/s 的 NSC3 高速数值模式,同时压缩 long long 数值与行结构并对混合内容原样回退;新增“保留换行”选项,默认精确保留,使用 cin >> 等空白不敏感读取时可关闭,从而避免大量随机行长占用输出;生成程序现在先向 stderr 输出并刷新数据,再通过 abort() 可靠触发 RE,同时兼容读取旧版异常包装的结果。"
}
}
}
}
217 changes: 126 additions & 91 deletions XMOJ.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -4211,98 +4211,133 @@ async function main() {
}

PassCheck.addEventListener("click", async () => {
ErrorElement.style.display = "none";
document.querySelector("#Submit").disabled = true;
document.querySelector("#Submit").value = "正在提交...";
let o2Switch = "&enable_O2=on";
if (!document.querySelector("#enable_O2").checked) o2Switch = "";
await fetch("https://www.xmoj.tech/submit.php", {
"headers": {
"content-type": "application/x-www-form-urlencoded"
},
"referrer": location.href,
"method": "POST",
"body": (SearchParams.get("id") != null ? "id=" + SearchParams.get("id") : "cid=" + SearchParams.get("cid") + "&pid=" + SearchParams.get("pid")) + "&language=1&" + "source=" + encodeURIComponent(CodeMirrorElement.getValue()) + o2Switch
}).then(async (Response) => {
if (Response.redirected) {
location.href = Response.url;
} else {
const text = await Response.text();
if (text.indexOf("没有这个比赛!") !== -1 && new URL(location.href).searchParams.get("pid") !== null) {
// Credit: https://github.com/boomzero/quicksubmit/blob/main/index.ts
// Also licensed under GPL-3.0
const contestReq = await fetch("https://www.xmoj.tech/contest.php?cid=" + new URL(location.href).searchParams.get("cid"));
const res = await contestReq.text();
if (
contestReq.status !== 200 ||
res.indexOf("比赛尚未开始或私有,不能查看题目。") !== -1
) {
console.error(`Failed to get contest page!`);
return;
}
const parser = new DOMParser();
const dom = parser.parseFromString(res, "text/html");
const contestProblems = [];
const rows = (dom.querySelector(
"#problemset > tbody",
)).rows;
for (let i = 0; i < rows.length; i++) {
contestProblems.push(
rows[i].children[1].textContent.substring(2, 6).replaceAll(
"\t",
"",
),
);
}
rPID = contestProblems[new URL(location.href).searchParams.get("pid")];
if (UtilityEnabled("DebugMode")) {
console.log("Contest Problems:", contestProblems);
console.log("Real PID:", rPID);
}
ErrorElement.style.display = "block";
ErrorMessage.style.color = "red";
try { _xmoj_disposeErrorMessageEditors(); } catch (e) {
console.error(e);
if (UtilityEnabled("DebugMode")) {
SmartAlert("XMOJ-Script internal error!\n\n" + e + "\n\n" + "If you see this message, please report it to the developer.\nDon't forget to include console logs and a way to reproduce the error!\n\nDon't want to see this message? Disable DebugMode.");
}
}
ErrorMessage.innerText = "比赛已结束, 正在尝试向题目 " + rPID + " 提交";
console.log("比赛已结束, 正在尝试向题目 " + rPID + " 提交");
let o2Switch = "&enable_O2=on";
if (!document.querySelector("#enable_O2").checked) o2Switch = "";
await fetch("https://www.xmoj.tech/submit.php", {
"headers": {
"content-type": "application/x-www-form-urlencoded"
},
"referrer": location.href,
"method": "POST",
"body": "id=" + rPID + "&language=1&" + "source=" + encodeURIComponent(CodeMirrorElement.getValue()) + o2Switch
}).then(async (Response) => {
if (Response.redirected) {
location.href = Response.url;
}
console.log(await Response.text());
});
ErrorElement.style.display = "none";
document.querySelector("#Submit").disabled = true;
document.querySelector("#Submit").value = "正在提交...";
let o2Switch = "&enable_O2=on";
if (!document.querySelector("#enable_O2").checked) o2Switch = "";

const response = await fetch("https://www.xmoj.tech/submit.php", {
"headers": {
"content-type": "application/x-www-form-urlencoded"
},
"referrer": location.href,
"method": "POST",
"body": (SearchParams.get("id") != null ? "id=" + SearchParams.get("id") : "cid=" + SearchParams.get("cid") + "&pid=" + SearchParams.get("pid")) + "&language=1&" + "source=" + encodeURIComponent(CodeMirrorElement.getValue()) + o2Switch
});

}
if (UtilityEnabled("DebugMode")) {
console.log("Submission failed! Response:", text);
}
ErrorElement.style.display = "block";
ErrorMessage.style.color = "red";
try { _xmoj_disposeErrorMessageEditors(); } catch (e) {
console.error(e);
if (UtilityEnabled("DebugMode")) {
SmartAlert("XMOJ-Script internal error!\n\n" + e + "\n\n" + "If you see this message, please report it to the developer.\nDon't forget to include console logs and a way to reproduce the error!\n\nDon't want to see this message? Disable DebugMode.");
}
}
ErrorMessage.innerText = "提交失败!请关闭脚本后重试!";
Submit.disabled = false;
Submit.value = "提交";
}
})
});
if (response.redirected) {
location.href = response.url;
return;
}

const text = await response.text();

// 回退处理:比赛已结束或不存在,尝试直接提交到真实题目
if ((text.indexOf("没有这个比赛!") !== -1 || text.indexOf("比赛已结束") !== -1) && new URL(location.href).searchParams.get("pid") !== null) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: The entire new block is indented at 4 spaces while the surrounding code of the PassCheck click handler is nested at 24 spaces. This drops the added code out of the visual nesting level, making the handler body read as if it were separate top-level code and hurting maintainability. The repo convention is to preserve original formatting (CLAUDE.md: "Do NOT run code formatters - maintain original formatting"). Re-indent the block to match the surrounding level.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At XMOJ.user.js, line 4237:

<comment>The entire new block is indented at 4 spaces while the surrounding code of the PassCheck `click` handler is nested at 24 spaces. This drops the added code out of the visual nesting level, making the handler body read as if it were separate top-level code and hurting maintainability. The repo convention is to preserve original formatting (CLAUDE.md: "Do NOT run code formatters - maintain original formatting"). Re-indent the block to match the surrounding level.</comment>

<file context>
@@ -4211,98 +4211,143 @@ async function main() {
+    const text = await response.text();
+
+    // 回退处理:比赛已结束或不存在,尝试直接提交到真实题目
+if ((text.indexOf("没有这个比赛!") !== -1 || text.indexOf("比赛已结束") !== -1) && new URL(location.href).searchParams.get("pid") !== null) {
+    // Credit: https://github.com/boomzero/quicksubmit/blob/main/index.ts (GPL-3.0)
+    const cid = new URL(location.href).searchParams.get("cid");
</file context>

// Credit: https://github.com/boomzero/quicksubmit/blob/main/index.ts (GPL-3.0)
const cid = new URL(location.href).searchParams.get("cid");
const pidIndex = new URL(location.href).searchParams.get("pid");

const contestReq = await fetch("https://www.xmoj.tech/contest.php?cid=" + cid);
const res = await contestReq.text();

if (contestReq.status !== 200 || res.indexOf("比赛尚未开始或私有,不能查看题目。") !== -1) {
console.error("Failed to get contest page!");
_xmoj_disposeErrorMessageEditors();
ErrorElement.style.display = "block";
ErrorMessage.style.color = "red";
ErrorMessage.innerText = "无法获取比赛信息,请手动提交。";
Submit.disabled = false;
Submit.value = "提交";
return;
}

const parser = new DOMParser();
const dom = parser.parseFromString(res, "text/html");
const rows = dom.querySelector("#problemset > tbody").rows;
const contestProblems = [];

for (let i = 0; i < rows.length; i++) {
const cell = rows[i].children[1];
const textContent = cell.textContent.trim();
const match = textContent.match(/\d+/);
contestProblems.push(match ? match[0] : null);
}

const rPID = contestProblems[parseInt(pidIndex)];
if (!rPID) {
_xmoj_disposeErrorMessageEditors();
ErrorElement.style.display = "block";
ErrorMessage.style.color = "red";
ErrorMessage.innerText = "无法解析真实题目 ID,请手动提交。";
Submit.disabled = false;
Submit.value = "提交";
return;
}

_xmoj_disposeErrorMessageEditors();
ErrorElement.style.display = "block";
ErrorMessage.style.color = "orange";
ErrorMessage.innerText = "比赛已结束,正在尝试向题目 " + rPID + " 提交…";
console.log("比赛已结束,正在尝试向题目 " + rPID + " 提交");

let o2Switch2 = "&enable_O2=on";
if (!document.querySelector("#enable_O2").checked) o2Switch2 = "";

const retryResp = await fetch("https://www.xmoj.tech/submit.php", {
"headers": {
"content-type": "application/x-www-form-urlencoded"
},
"referrer": location.href,
"method": "POST",
"body": "id=" + rPID + "&language=1&source=" + encodeURIComponent(CodeMirrorElement.getValue()) + o2Switch2
});

// 检查是否提交成功(重定向 或 响应含成功标记)
// 检查是否提交成功(重定向 或 响应含成功标记)
if (retryResp.redirected) {
location.href = retryResp.url;
return;
} else {
const retryText = await retryResp.text();
// ❌ 删除这里的成功关键词判断 —— 进入 else 就是失败

// ✅ 直接从响应中提取错误信息
let errorMsg = "提交失败,请重试。";
try {
const dom2 = new DOMParser().parseFromString(retryText, "text/html");
const jumbotron = dom2.querySelector(".jumbotron");
if (jumbotron) {
errorMsg = jumbotron.textContent.trim();
} else {
const textOnly = retryText.replace(/<[^>]*>/g, "").trim();
errorMsg = textOnly.substring(0, 100) || errorMsg;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P0: The extra closing brace makes XMOJ.user.js syntactically invalid, so the userscript cannot load at all. Remove the obsolete brace left behind by deleting the nested success check.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At XMOJ.user.js, line 4316:

<comment>The extra closing brace makes `XMOJ.user.js` syntactically invalid, so the userscript cannot load at all. Remove the obsolete brace left behind by deleting the nested success check.</comment>

<file context>
@@ -4295,45 +4295,35 @@ if ((text.indexOf("没有这个比赛!") !== -1 || text.indexOf("比赛已结
-            return;
+            const textOnly = retryText.replace(/<[^>]*>/g, "").trim();
+            errorMsg = textOnly.substring(0, 100) || errorMsg;
+        }
+    } catch (_) {
+        // 解析失败则使用默认信息
</file context>

} catch (_) {
// 解析失败则使用默认信息
}
_xmoj_disposeErrorMessageEditors();
ErrorElement.style.display = "block";
ErrorMessage.style.color = "red";
ErrorMessage.innerText = "❌ 回退提交失败:" + errorMsg;
Submit.disabled = false;
Submit.value = "提交";
return;
}
}
}

// 如果未进入回退分支,显示通用错误
if (UtilityEnabled("DebugMode")) {
console.log("Submission failed! Response:", text);
}
ErrorElement.style.display = "block";
ErrorMessage.style.color = "red";
ErrorMessage.innerText = "提交失败!请关闭脚本后重试!";
Submit.disabled = false;
Submit.value = "提交";
}); // ← 这是唯一正确的结束

Submit.addEventListener("click", async () => {
PassCheck.style.display = "none";
Expand Down
1 change: 1 addition & 0 deletions ads.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
google.com, pub-6214673028530012, DIRECT, f08c47fec0942fa0
1 change: 0 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<!DOCTYPE html>
<html>
<link rel="icon" href="favicon.ico">

<head>
<script type="text/javascript">
(function(c,l,a,r,i,t,y){
Expand Down
Loading