-
Notifications
You must be signed in to change notification settings - Fork 6
Fix problem switcher not update #931
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
162d588
d724438
8b4a2c1
e40b292
c8ed5aa
e4f659f
d24fe86
1a75572
b789bf2
13058b6
c22fd31
6adac8d
f86a45e
84474cc
7950ae8
dfe8cf8
54d39cf
462621a
27863a7
280bc24
4a671fc
e3bbe9e
fab6593
2f7e9d6
e14e33c
a5182a6
f908046
9ae2c90
18fded0
226b059
c30762b
63af153
df63a95
4b00024
cb97653
9e6161a
9c5a57d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -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); | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: Await the async Prompt for AI agents
Suggested change
|
||||||
| 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 += `<a href="javascript:void(0)" onclick="GetContestProblemList(true)" title="刷新列表" class="mb-2" style="text-align: center;" active>刷新</a>`; | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. security (javascript.browser.security.insecure-document-method): User controlled data in methods like Source: opengrep There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. security (javascript.browser.security.insecure-innerhtml): User controlled data in a Source: opengrep |
||||||
| 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!"); | ||||||
| }); | ||||||
| }); | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Emm, ?