diff --git a/Update.json b/Update.json
index e12d6229..b6341a37 100644
--- a/Update.json
+++ b/Update.json
@@ -3423,16 +3423,16 @@
],
"Notes": "Bug 修复
\n- 修复了暗色模式下比赛排名表(contestrank-oi.php 和 contestrank-correct.php)颜色显示异常的问题(#916)
\n- 修复了 WebSocket 弹窗通知未遵循各功能独立弹窗开关(BBSPopup/MessagePopup)的问题(#919)"
},
- "3.3.1": {
- "UpdateDate": 1772981411290,
+ "3.4.0": {
+ "UpdateDate": 1773332303425,
"Prerelease": true,
"UpdateContents": [
{
- "PR": 924,
- "Description": "Add ImageEnlarger feature with modal viewer"
+ "PR": 931,
+ "Description": "Fix problem switcher not update"
}
],
- "Notes": "No release notes were provided for this release."
+ "Notes": "Fix ProblemSwitcher Not Update"
}
}
}
\ No newline at end of file
diff --git a/XMOJ.user.js b/XMOJ.user.js
index 49538eed..e4fddd5e 100644
--- a/XMOJ.user.js
+++ b/XMOJ.user.js
@@ -1,6 +1,6 @@
// ==UserScript==
// @name XMOJ
-// @version 3.3.1
+// @version 3.4.0
// @description XMOJ增强脚本
// @author @XMOJ-Script-dev, @langningchen and the community
// @namespace https://github/langningchen
@@ -533,6 +533,29 @@ let RequestAPI = (Action, Data, CallBack) => {
}
};
+unsafeWindow.GetContestProblemList = async function(RefreshList) {
+ try {
+ 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;
+ let problemList = [];
+ for (let i = 0; i < rows.length; i++) {
+ problemList.push({
+ "title": rows[i].children[2].innerText,
+ "url": rows[i].children[2].children[0].href
+ });
+ }
+ localStorage.setItem("UserScript-Contest-" + SearchParams.get("cid") + "-ProblemList", JSON.stringify(problemList));
+ if (RefreshList) location.reload();
+ }
+ } catch (e) {
+ console.error(e);
+ }
+}
+
// WebSocket Notification System
let NotificationSocket = null;
let NotificationSocketReconnectAttempts = 0;
@@ -2272,22 +2295,8 @@ async function main() {
}
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"));
- 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;
- let problemList = [];
- for (let i = 0; i < rows.length; i++) {
- problemList.push({
- "title": rows[i].children[2].innerText,
- "url": rows[i].children[2].children[0].href
- });
- }
- localStorage.setItem("UserScript-Contest-" + SearchParams.get("cid") + "-ProblemList", JSON.stringify(problemList));
- ContestProblemList = JSON.stringify(problemList);
- }
+ unsafeWindow.GetContestProblemList(false);
+ ContestProblemList = localStorage.getItem("UserScript-Contest-" + SearchParams.get("cid") + "-ProblemList");
}
let problemSwitcher = document.createElement("div");
@@ -2310,6 +2319,7 @@ async function main() {
problemSwitcher.style.flexDirection = "column";
let problemList = JSON.parse(ContestProblemList);
+ problemSwitcher.innerHTML += `刷新`;
for (let i = 0; i < problemList.length; i++) {
let buttonText = "";
if (i < 26) {
@@ -6069,4 +6079,4 @@ int main()
main().then(r => {
console.log("XMOJ-Script loaded successfully!");
-});
\ No newline at end of file
+});
diff --git a/package.json b/package.json
index 9ffb1aa4..86a7ba56 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "xmoj-script",
- "version": "3.3.1",
+ "version": "3.4.0",
"description": "an improvement script for xmoj.tech",
"main": "AddonScript.js",
"scripts": {