-
Notifications
You must be signed in to change notification settings - Fork 6
Fix problem switcher not update #933
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
ba48f22
9baa291
478101d
4f5c2e0
7710089
62b1755
33535ec
a8bf01b
c34f666
c87d08f
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.3.2 | ||
| // @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; | ||
|
|
@@ -1551,6 +1574,9 @@ async function main() { | |
| display: none !important; | ||
| } | ||
| } | ||
| .refreshList { | ||
| cursor: pointer; | ||
| } | ||
|
|
||
| /* Contain images */ | ||
| img { | ||
|
|
@@ -1616,6 +1642,11 @@ async function main() { | |
| border: 1px solid var(--bs-secondary-bg); | ||
| border-top: none; | ||
| border-radius: 0 0 0.3rem 0.3rem; | ||
| } | ||
| .refreshList { | ||
| cursor: pointer; | ||
| color: #6c757d; | ||
| text-decoration: none; | ||
| }`; | ||
| } | ||
| if (UtilityEnabled("AddAnimation")) { | ||
|
|
@@ -2272,22 +2303,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); | ||
| } | ||
| await unsafeWindow.GetContestProblemList(false); | ||
| ContestProblemList = localStorage.getItem("UserScript-Contest-" + SearchParams.get("cid") + "-ProblemList"); | ||
| } | ||
|
|
||
| let problemSwitcher = document.createElement("div"); | ||
|
|
@@ -2310,6 +2327,7 @@ async function main() { | |
| problemSwitcher.style.flexDirection = "column"; | ||
|
|
||
| let problemList = JSON.parse(ContestProblemList); | ||
| problemSwitcher.innerHTML += `<a onclick="GetContestProblemList(true)" title="刷新列表" class="refreshList 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 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 +6087,4 @@ int main() | |
|
|
||
| main().then(r => { | ||
| console.log("XMOJ-Script loaded successfully!"); | ||
| }); | ||
| }); | ||
Uh oh!
There was an error while loading. Please reload this page.