Skip to content

Commit 7119f81

Browse files
def-WA2025boomzeroPythonSmall-Qclaudegithub-actions[bot]
authored
Fix problem switcher not update (#933)
* Update Update.json Signed-off-by: Zhu Chenrui <boomzero_zcr@outlook.com> * Parse release notes from comment block (cherry picked from commit c7137ff) * Update bug.yml Signed-off-by: Zhu Chenrui <boomzero_zcr@outlook.com> (cherry picked from commit 07d7590) Update feature.yml Signed-off-by: Zhu Chenrui <boomzero_zcr@outlook.com> (cherry picked from commit 1a99430) Update docs.yml Signed-off-by: Zhu Chenrui <boomzero_zcr@outlook.com> (cherry picked from commit 6017bcf) * Update GitHub Actions workflow to skip bot triggers Signed-off-by: Shan Wenxiao <seanoj_noreply@yeah.net> * Prevent UpdateVersion from running if last commit was by github-actions[bot] This prevents infinite loops where the bot commits version updates, which triggers the workflow again, causing another commit. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * Allow metadata updates on edited PRs after bot version commit The last-commit-author guard now only exits for non-edited events, so PR title/body changes still update Update.json metadata even when the branch tip is a github-actions[bot] commit. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Allow metadata updates on edited PRs after bot version commit Exclude all bot actors (not just github-actions[bot]) from triggering the UpdateVersion workflow, preventing loops from AI code review bots. Allow edited events through the script-level guard so PR title/body changes still update Update.json metadata. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Fix Problem Switcher Not Update * Fix Problem Switcher Not Update * 3.3.2 * Update version info to 3.3.2 * Fix Version List (1.999999.0 -> 1.10.0) Signed-off-by: zsTree <wa2025666@gmail.com> * Update time and description of 3.3.2 * Fix Problem Switcher Null Problem Signed-off-by: zsTree <wa2025666@gmail.com> * Update time and description of 3.3.2 * Fix XSS bug Signed-off-by: zsTree <wa2025666@gmail.com> * Update time and description of 3.3.2 --------- Signed-off-by: Zhu Chenrui <boomzero_zcr@outlook.com> Signed-off-by: Shan Wenxiao <seanoj_noreply@yeah.net> Signed-off-by: zsTree <wa2025666@gmail.com> Co-authored-by: Zhu Chenrui <boomzero_zcr@outlook.com> Co-authored-by: Shan Wenxiao <seanoj_noreply@yeah.net> Co-authored-by: boomzero <thomas_rainbowfish@icloud.com> Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 1069143 commit 7119f81

File tree

3 files changed

+48
-19
lines changed

3 files changed

+48
-19
lines changed

Update.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3433,6 +3433,17 @@
34333433
}
34343434
],
34353435
"Notes": "No release notes were provided for this release."
3436+
},
3437+
"3.3.2": {
3438+
"UpdateDate": 1773495619873,
3439+
"Prerelease": true,
3440+
"UpdateContents": [
3441+
{
3442+
"PR": 933,
3443+
"Description": "Fix problem switcher not update"
3444+
}
3445+
],
3446+
"Notes": "Fix ProblemSwitcher Not Update"
34363447
}
34373448
}
34383449
}

XMOJ.user.js

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// ==UserScript==
22
// @name XMOJ
3-
// @version 3.3.1
3+
// @version 3.3.2
44
// @description XMOJ增强脚本
55
// @author @XMOJ-Script-dev, @langningchen and the community
66
// @namespace https://github/langningchen
@@ -533,6 +533,29 @@ let RequestAPI = (Action, Data, CallBack) => {
533533
}
534534
};
535535

536+
unsafeWindow.GetContestProblemList = async function(RefreshList) {
537+
try {
538+
const contestReq = await fetch("https://www.xmoj.tech/contest.php?cid=" + SearchParams.get("cid"));
539+
const res = await contestReq.text();
540+
if (contestReq.status === 200 && res.indexOf("比赛尚未开始或私有,不能查看题目。") === -1) {
541+
const parser = new DOMParser();
542+
const dom = parser.parseFromString(res, "text/html");
543+
const rows = (dom.querySelector("#problemset > tbody")).rows;
544+
let problemList = [];
545+
for (let i = 0; i < rows.length; i++) {
546+
problemList.push({
547+
"title": rows[i].children[2].innerText,
548+
"url": rows[i].children[2].children[0].href
549+
});
550+
}
551+
localStorage.setItem("UserScript-Contest-" + SearchParams.get("cid") + "-ProblemList", JSON.stringify(problemList));
552+
if (RefreshList) location.reload();
553+
}
554+
} catch (e) {
555+
console.error(e);
556+
}
557+
}
558+
536559
// WebSocket Notification System
537560
let NotificationSocket = null;
538561
let NotificationSocketReconnectAttempts = 0;
@@ -1551,6 +1574,9 @@ async function main() {
15511574
display: none !important;
15521575
}
15531576
}
1577+
.refreshList {
1578+
cursor: pointer;
1579+
}
15541580
15551581
/* Contain images */
15561582
img {
@@ -1616,6 +1642,11 @@ async function main() {
16161642
border: 1px solid var(--bs-secondary-bg);
16171643
border-top: none;
16181644
border-radius: 0 0 0.3rem 0.3rem;
1645+
}
1646+
.refreshList {
1647+
cursor: pointer;
1648+
color: #6c757d;
1649+
text-decoration: none;
16191650
}`;
16201651
}
16211652
if (UtilityEnabled("AddAnimation")) {
@@ -2272,22 +2303,8 @@ async function main() {
22722303
}
22732304
let ContestProblemList = localStorage.getItem("UserScript-Contest-" + SearchParams.get("cid") + "-ProblemList");
22742305
if (ContestProblemList == null) {
2275-
const contestReq = await fetch("https://www.xmoj.tech/contest.php?cid=" + SearchParams.get("cid"));
2276-
const res = await contestReq.text();
2277-
if (contestReq.status === 200 && res.indexOf("比赛尚未开始或私有,不能查看题目。") === -1) {
2278-
const parser = new DOMParser();
2279-
const dom = parser.parseFromString(res, "text/html");
2280-
const rows = (dom.querySelector("#problemset > tbody")).rows;
2281-
let problemList = [];
2282-
for (let i = 0; i < rows.length; i++) {
2283-
problemList.push({
2284-
"title": rows[i].children[2].innerText,
2285-
"url": rows[i].children[2].children[0].href
2286-
});
2287-
}
2288-
localStorage.setItem("UserScript-Contest-" + SearchParams.get("cid") + "-ProblemList", JSON.stringify(problemList));
2289-
ContestProblemList = JSON.stringify(problemList);
2290-
}
2306+
await unsafeWindow.GetContestProblemList(false);
2307+
ContestProblemList = localStorage.getItem("UserScript-Contest-" + SearchParams.get("cid") + "-ProblemList");
22912308
}
22922309

22932310
let problemSwitcher = document.createElement("div");
@@ -2310,6 +2327,7 @@ async function main() {
23102327
problemSwitcher.style.flexDirection = "column";
23112328

23122329
let problemList = JSON.parse(ContestProblemList);
2330+
problemSwitcher.innerHTML += `<a onclick="GetContestProblemList(true)" title="刷新列表" class="refreshList mb-2" style="text-align: center;" active>刷新</a>`;
23132331
for (let i = 0; i < problemList.length; i++) {
23142332
let buttonText = "";
23152333
if (i < 26) {
@@ -6069,4 +6087,4 @@ int main()
60696087

60706088
main().then(r => {
60716089
console.log("XMOJ-Script loaded successfully!");
6072-
});
6090+
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "xmoj-script",
3-
"version": "3.3.1",
3+
"version": "3.3.2",
44
"description": "an improvement script for xmoj.tech",
55
"main": "AddonScript.js",
66
"scripts": {

0 commit comments

Comments
 (0)