-
Notifications
You must be signed in to change notification settings - Fork 6
fix: reinfo.php shows no test results even if test results are available #815
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
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 1.8.0 | ||||||||||||||||
| // @version 1.8.1 | ||||||||||||||||
| // @description XMOJ增强脚本 | ||||||||||||||||
| // @author @XMOJ-Script-dev, @langningchen and the community | ||||||||||||||||
| // @namespace https://github/langningchen | ||||||||||||||||
|
|
@@ -3355,9 +3355,7 @@ window.addEventListener('DOMContentLoaded', async () => { | |||||||||||||||
| } | ||||||||||||||||
| } else if (location.pathname == "/reinfo.php") { | ||||||||||||||||
| document.title = "测试点信息: " + SearchParams.get("sid"); | ||||||||||||||||
| if (document.querySelector("#results > div") == undefined) { | ||||||||||||||||
| document.querySelector("#results").parentElement.innerHTML = "没有测试点信息"; | ||||||||||||||||
| } else { | ||||||||||||||||
| if (document.querySelector("#results > div") != undefined) { | ||||||||||||||||
| for (let i = 0; i < document.querySelector("#results > div").children.length; i++) { | ||||||||||||||||
| let CurrentElement = document.querySelector("#results > div").children[i].children[0].children[0].children[0]; | ||||||||||||||||
|
Comment on lines
+3358
to
3360
|
||||||||||||||||
| if (document.querySelector("#results > div") != undefined) { | |
| for (let i = 0; i < document.querySelector("#results > div").children.length; i++) { | |
| let CurrentElement = document.querySelector("#results > div").children[i].children[0].children[0].children[0]; | |
| const resultsDiv = document.querySelector("#results > div"); | |
| if (resultsDiv != undefined) { | |
| for (let i = 0; i < resultsDiv.children.length; i++) { | |
| let CurrentElement = resultsDiv.children[i].children[0].children[0].children[0]; |
Copilot
AI
Jul 6, 2025
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.
Replacing the entire body.innerHTML can break event listeners and is fragile. Instead, target the specific <pre id="errtxt"> element (e.g., via getElementById) and update its textContent.
| document.body.innerHTML = String(document.body.innerHTML).replaceAll("<pre id=\"errtxt\" class=\"alert alert-error\">sorry , not available (,,,1)</pre>", "没有测试点信息"); | |
| let errorTextElement = document.getElementById("errtxt"); | |
| if (errorTextElement) { | |
| errorTextElement.textContent = "没有测试点信息"; | |
| } |
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.
The fallback message for when no test results are available was removed. Reintroduce an
elsebranch to display “没有测试点信息” whendocument.querySelector("#results > div")returnsundefined.