Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Update.json
Original file line number Diff line number Diff line change
Expand Up @@ -2718,6 +2718,17 @@
}
],
"Notes": "If you are curious why the version number is v1.3.0, it's because we changed our versioning strategy! Click <a href=\"https://github.com/orgs/XMOJ-Script-dev/discussions/771\"> here </a> for more details."
},
"1.3.1": {
"UpdateDate": 1739060055956,
"Prerelease": true,
"UpdateContents": [
{
"PR": 774,
"Description": "Fix code scanning alert - DOM text reinterpreted as HTML"
}
],
"Notes": "No release notes were provided for this release."
}
}
}
17 changes: 15 additions & 2 deletions XMOJ.user.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ==UserScript==
// @name XMOJ
// @version 1.3.0
// @version 1.3.1
// @description XMOJ增强脚本
// @author @XMOJ-Script-dev, @langningchen and the community
// @namespace https://github/langningchen
Expand Down Expand Up @@ -41,6 +41,19 @@
const CaptchaSiteKey = "0x4AAAAAAALBT58IhyDViNmv";
const AdminUserList = ["zhuchenrui2", "shanwenxiao", "admin"];

let escapeHTML = (str) => {
return str.replace(/[&<>"']/g, function (match) {
const escape = {
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&#39;'
};
return escape[match];
});
};

let PurifyHTML = (Input) => {
try {
return DOMPurify.sanitize(Input, {
Expand Down Expand Up @@ -70,7 +83,7 @@
Input = new Date(Input);
let Now = new Date().getTime();
let Delta = Now - Input.getTime();
let RelativeName = "";

Check warning on line 86 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Unused assignment

Variable initializer is redundant
if (Delta < 0) {
RelativeName = "未来";
} else if (Delta <= 1000 * 60) {
Expand Down Expand Up @@ -140,7 +153,7 @@
let Email = Temp[Temp.length - 1].children[1].innerText.trim();
let EmailHash = CryptoJS.MD5(Email).toString();
localStorage.setItem("UserScript-User-" + Username + "-UserRating", Rating);
if (Email == "") {

Check warning on line 156 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Email == "" may cause unexpected type coercion
EmailHash = undefined;
} else {
localStorage.setItem("UserScript-User-" + Username + "-EmailHash", EmailHash);
Expand Down Expand Up @@ -229,7 +242,7 @@
let HTMLData = "";
if (!Simple) {
HTMLData += `<img src="`;
if (UserInfo.EmailHash == undefined) {

Check warning on line 245 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison UserInfo.EmailHash == undefined may cause unexpected type coercion
HTMLData += `https://cravatar.cn/avatar/00000000000000000000000000000000?d=mp&f=y`;
} else {
HTMLData += `https://cravatar.cn/avatar/${UserInfo.EmailHash}?d=retro`;
Expand Down Expand Up @@ -260,11 +273,11 @@
if (AdminUserList.includes(Username)) {
HTMLData += `<span class="badge text-bg-danger ms-2">脚本管理员</span>`;
}
if (Username == "chenlangning") {

Check warning on line 276 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Username == "chenlangning" may cause unexpected type coercion
HTMLData += `<span class="badge ms-2" style="background-color: #6633cc; color: #ffffff">吉祥物</span>`;
}
let BadgeInfo = await GetUserBadge(Username);
if (BadgeInfo.Content != "") {

Check warning on line 280 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison BadgeInfo.Content != "" may cause unexpected type coercion
HTMLData += `<span class="badge ms-2" style="background-color: ${BadgeInfo.BackgroundColor}; color: ${BadgeInfo.Color}">${BadgeInfo.Content}</span>`;
}
}
Expand Down Expand Up @@ -408,7 +421,7 @@
const defaultOffItems = ["DebugMode", "cdnjs", "SuperDebug", "ReplaceXM"];
localStorage.setItem("UserScript-Setting-" + Name, defaultOffItems.includes(Name) ? "false" : "true");
}
return localStorage.getItem("UserScript-Setting-" + Name) == "true";

Check warning on line 424 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison localStorage.getItem("UserScript-Setting-" + Name) == "true" may cause unexpected type coercion
} catch (e) {
console.error(e);
if (UtilityEnabled("DebugMode")) {
Expand Down Expand Up @@ -487,7 +500,7 @@
});

//otherwise CurrentUsername might be undefined
if (UtilityEnabled("AutoLogin") && document.querySelector("body > a:nth-child(1)") != null && document.querySelector("body > a:nth-child(1)").innerText == "请登录后继续操作") {

Check warning on line 503 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison document.querySelector("body \> a:nth-child(1)").innerText == "请登录后继续操作" may cause unexpected type coercion
localStorage.setItem("UserScript-LastPage", location.pathname + location.search);
location.href = "https://www.xmoj.tech/loginpage.php";
}
Expand Down Expand Up @@ -635,7 +648,7 @@
//use https
location.href = location.href.replace('http://', 'https://');
}
if (location.host != "www.xmoj.tech") {

Check warning on line 651 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison location.host != "www.xmoj.tech" may cause unexpected type coercion
location.host = "www.xmoj.tech";
} else {
if (location.href === 'https://www.xmoj.tech/open_contest_sign_up.php') {
Expand All @@ -647,7 +660,7 @@
document.querySelector("body > div > div.jumbotron").className = "mt-3";
}

if (UtilityEnabled("AutoLogin") && document.querySelector("#profile") != null && document.querySelector("#profile").innerHTML == "登录" && location.pathname != "/login.php" && location.pathname != "/loginpage.php" && location.pathname != "/lostpassword.php") {

Check warning on line 663 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison location.pathname != "/lostpassword.php" may cause unexpected type coercion

Check warning on line 663 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison document.querySelector("#profile").innerHTML == "登录" may cause unexpected type coercion

Check warning on line 663 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison location.pathname != "/login.php" may cause unexpected type coercion

Check warning on line 663 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison location.pathname != "/loginpage.php" may cause unexpected type coercion
localStorage.setItem("UserScript-LastPage", location.pathname + location.search);
location.href = "https://www.xmoj.tech/loginpage.php";
}
Expand Down Expand Up @@ -688,16 +701,16 @@

if (UtilityEnabled("NewBootstrap")) {
let Temp = document.querySelectorAll("link");
for (var i = 0; i < Temp.length; i++) {

Check warning on line 704 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Duplicate declaration

Duplicate declaration
if (Temp[i].href.indexOf("bootstrap.min.css") != -1) {

Check warning on line 705 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Temp\[i\].href.indexOf("bootstrap.min.css") != -1 may cause unexpected type coercion
Temp[i].remove();
} else if (Temp[i].href.indexOf("white.css") != -1) {

Check warning on line 707 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Temp\[i\].href.indexOf("white.css") != -1 may cause unexpected type coercion
Temp[i].remove();
} else if (Temp[i].href.indexOf("semantic.min.css") != -1) {

Check warning on line 709 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Temp\[i\].href.indexOf("semantic.min.css") != -1 may cause unexpected type coercion
Temp[i].remove();
} else if (Temp[i].href.indexOf("bootstrap-theme.min.css") != -1) {

Check warning on line 711 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Temp\[i\].href.indexOf("bootstrap-theme.min.css") != -1 may cause unexpected type coercion
Temp[i].remove();
} else if (Temp[i].href.indexOf("problem.css") != -1) {

Check warning on line 713 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Temp\[i\].href.indexOf("problem.css") != -1 may cause unexpected type coercion
Temp[i].remove();
}
}
Expand Down Expand Up @@ -758,10 +771,10 @@

await Promise.all(promises);
};
if (location.pathname == "/submitpage.php") {

Check warning on line 774 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison location.pathname == "/submitpage.php" may cause unexpected type coercion
await loadResources();
} else {
loadResources();

Check notice on line 777 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Missing await for an async function call

Missing await for an async function call
}
document.querySelector("nav").className = "navbar navbar-expand-lg bg-body-tertiary";
document.querySelector("#navbar > ul:nth-child(1)").classList = "navbar-nav me-auto mb-2 mb-lg-0";
Expand All @@ -770,7 +783,7 @@
document.querySelector("#navbar > ul.nav.navbar-nav.navbar-right > li > a").className = "nav-link dropdown-toggle";
document.querySelector("#navbar > ul.nav.navbar-nav.navbar-right > li > a > span.caret").remove();
Temp = document.querySelector("#navbar > ul:nth-child(1)").children;
for (var i = 0; i < Temp.length; i++) {

Check warning on line 786 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Duplicate declaration

Duplicate declaration
if (Temp[i].classList.contains("active")) {
Temp[i].classList.remove("active");
Temp[i].children[0].classList.add("active");
Expand All @@ -781,7 +794,7 @@
document.querySelector("#navbar > ul.nav.navbar-nav.navbar-right > li > a").setAttribute("data-bs-toggle", "dropdown");
document.querySelector("#navbar > ul.nav.navbar-nav.navbar-right > li > a").removeAttribute("data-toggle");
}
if (UtilityEnabled("RemoveUseless") && document.getElementsByTagName("marquee")[0] != undefined) {

Check warning on line 797 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison document.getElementsByTagName("marquee")\[0\] != undefined may cause unexpected type coercion
document.getElementsByTagName("marquee")[0].remove();
}
let Style = document.createElement("style");
Expand Down Expand Up @@ -914,7 +927,7 @@
new NavbarStyler();
}
if (UtilityEnabled("ResetType")) {
if (document.querySelector("#profile") != undefined && document.querySelector("#profile").innerHTML == "登录") {

Check warning on line 930 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison document.querySelector("#profile") != undefined may cause unexpected type coercion

Check warning on line 930 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison document.querySelector("#profile").innerHTML == "登录" may cause unexpected type coercion
let PopupUL = document.querySelector("#navbar > ul.nav.navbar-nav.navbar-right > li > ul");
PopupUL.innerHTML = `<li class="dropdown-item">登录</li>`;
PopupUL.children[0].addEventListener("click", () => {
Expand All @@ -926,7 +939,7 @@
hideDropdownItems();
}
});
} else if (document.querySelector("#navbar > ul.nav.navbar-nav.navbar-right > li > ul > li:nth-child(3) > a > span") != undefined && document.querySelector("#navbar > ul.nav.navbar-nav.navbar-right > li > ul > li:nth-child(3) > a > span").innerText != "个人中心") {

Check warning on line 942 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison document.querySelector("#navbar \> ul.nav.navbar-nav.navbar-right \> li \> ul \> li:nth-child(3) \> a \> s... may cause unexpected type coercion

Check warning on line 942 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison document.querySelector("#navbar \> ul.nav.navbar-nav.navbar-right \> li \> ul \> li:nth-child(3) \> a \> s... may cause unexpected type coercion
let PopupUL = document.querySelector("#navbar > ul.nav.navbar-nav.navbar-right > li > ul");
PopupUL.style.cursor = 'pointer';
PopupUL.innerHTML = `<li class="dropdown-item">修改帐号</li>
Expand Down Expand Up @@ -1030,7 +1043,7 @@
let LatestVersion;
for (let i = Object.keys(Response.UpdateHistory).length - 1; i >= 0; i--) {
let VersionInfo = Object.keys(Response.UpdateHistory)[i];
if (UtilityEnabled("DebugMode") || Response.UpdateHistory[VersionInfo].Prerelease == false) {

Check warning on line 1046 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Response.UpdateHistory\[VersionInfo\].Prerelease == false may cause unexpected type coercion
LatestVersion = VersionInfo;
break;
}
Expand Down Expand Up @@ -1062,7 +1075,7 @@
document.body.appendChild(UpdateDiv);
document.querySelector("body > div").insertBefore(UpdateDiv, document.querySelector("body > div > div.mt-3"));
}
if (localStorage.getItem("UserScript-Update-LastVersion") != GM_info.script.version) {

Check warning on line 1078 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison localStorage.getItem("UserScript-Update-LastVersion") != GM_info.script.version may cause unexpected type coercion
localStorage.setItem("UserScript-Update-LastVersion", GM_info.script.version);
let UpdateDiv = document.createElement("div");
document.querySelector("body").appendChild(UpdateDiv);
Expand Down Expand Up @@ -1119,7 +1132,7 @@
UpdateDataCardBody.appendChild(UpdateDataCardText);
UpdateDataCardText.className = "card-text";
//release notes
if (Data.Notes != undefined) {

Check warning on line 1135 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Data.Notes != undefined may cause unexpected type coercion
UpdateDataCardText.innerHTML = Data.Notes;
}
let UpdateDataCardList = document.createElement("ul");
Expand Down Expand Up @@ -1244,7 +1257,7 @@
let ToastBody = document.createElement("div");
ToastBody.classList.add("toast-body");
let ToastUser = document.createElement("span");
GetUsernameHTML(ToastUser, MentionList[i].FromUserID);

Check notice on line 1260 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Missing await for an async function call

Missing await for an async function call
ToastBody.appendChild(ToastUser);
ToastBody.innerHTML += " 给你发了一封短消息";
let ToastFooter = document.createElement("div");
Expand Down Expand Up @@ -1285,7 +1298,7 @@
dispatchEvent(new Event("focus"));


if (location.pathname == "/index.php" || location.pathname == "/") {

Check warning on line 1301 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison location.pathname == "/" may cause unexpected type coercion

Check warning on line 1301 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison location.pathname == "/index.php" may cause unexpected type coercion
if (new URL(location.href).searchParams.get("ByUserScript") != null) {
document.title = "脚本设置";
localStorage.setItem("UserScript-Opened", "true");
Expand Down Expand Up @@ -1314,14 +1327,14 @@
for (let i = 0; i < Data.length; i++) {
let Row = document.createElement("li");
Row.classList.add("list-group-item");
if (Data[i].Type == "A") {

Check warning on line 1330 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Data\[i\].Type == "A" may cause unexpected type coercion
Row.classList.add("list-group-item-success");
} else if (Data[i].Type == "F") {

Check warning on line 1332 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Data\[i\].Type == "F" may cause unexpected type coercion
Row.classList.add("list-group-item-warning");
} else if (Data[i].Type == "D") {

Check warning on line 1334 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Data\[i\].Type == "D" may cause unexpected type coercion
Row.classList.add("list-group-item-danger");
}
if (Data[i].Children == undefined) {

Check warning on line 1337 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Data\[i\].Children == undefined may cause unexpected type coercion
let CheckBox = document.createElement("input");
CheckBox.classList.add("form-check-input");
CheckBox.classList.add("me-1");
Expand All @@ -1330,7 +1343,7 @@
if (localStorage.getItem("UserScript-Setting-" + Data[i].ID) == null) {
localStorage.setItem("UserScript-Setting-" + Data[i].ID, "true");
}
if (localStorage.getItem("UserScript-Setting-" + Data[i].ID) == "false") {

Check warning on line 1346 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison localStorage.getItem("UserScript-Setting-" + Data\[i\].ID) == "false" may cause unexpected type coercion
CheckBox.checked = false;
} else {
CheckBox.checked = true;
Expand All @@ -1350,7 +1363,7 @@
Label.innerText = Data[i].Name;
Row.appendChild(Label);
}
if (Data[i].Children != undefined) {

Check warning on line 1366 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Data\[i\].Children != undefined may cause unexpected type coercion
Row.appendChild(CreateList(Data[i].Children));
}
List.appendChild(Row);
Expand Down Expand Up @@ -1460,7 +1473,7 @@
let NewsRowHead = document.createElement("div");
NewsRowHead.className = "cnt-row-head title";
NewsRowHead.innerText = NewsData[i].Title;
if (NewsData[i].Time != 0) {

Check warning on line 1476 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison NewsData\[i\].Time != 0 may cause unexpected type coercion
NewsRowHead.innerHTML += "<small class=\"ms-3\">" + NewsData[i].Time.toLocaleDateString() + "</small>";
}
NewsRow.appendChild(NewsRowHead);
Expand Down Expand Up @@ -1496,7 +1509,7 @@
}
});
}
} else if (location.pathname == "/problemset.php") {

Check warning on line 1512 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison location.pathname == "/problemset.php" may cause unexpected type coercion
if (UtilityEnabled("Translate")) {
document.querySelector("body > div > div.mt-3 > center > table:nth-child(2) > tbody > tr > td:nth-child(2) > form > input").placeholder = "题目编号";
document.querySelector("body > div > div.mt-3 > center > table:nth-child(2) > tbody > tr > td:nth-child(2) > form > button").innerText = "确认";
Expand Down Expand Up @@ -1534,7 +1547,7 @@
for (let i = 1; i < Temp.length; i++) {
localStorage.setItem("UserScript-Problem-" + Temp[i].children[1].innerText + "-Name", Temp[i].children[2].innerText);
}
} else if (location.pathname == "/problem.php") {

Check warning on line 1550 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison location.pathname == "/problem.php" may cause unexpected type coercion
await RenderMathJax();
if (SearchParams.get("cid") != null) {
document.getElementsByTagName("h2")[0].innerHTML += " (" + localStorage.getItem("UserScript-Contest-" + SearchParams.get("cid") + "-Problem-" + SearchParams.get("pid") + "-PID") + ")";
Expand Down Expand Up @@ -1584,12 +1597,12 @@
console.log(SubmitLink.href);
};
var Temp = document.querySelectorAll(".sampledata");
for (var i = 0; i < Temp.length; i++) {

Check warning on line 1600 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Duplicate declaration

Duplicate declaration
Temp[i].parentElement.className = "card";
}
if (UtilityEnabled("RemoveUseless")) {
document.querySelector("h2.lang_en").remove();
document.getElementsByTagName("center")[1].remove();

Check notice on line 1605 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Deprecated symbol used

Deprecated symbol used, consult docs for better alternative
}
if (UtilityEnabled("CopySamples")) {
$(".copy-btn").click((Event) => {
Expand Down Expand Up @@ -1673,7 +1686,7 @@
"ProblemID": Number(PID)
}, (Response) => {
if (Response.Success) {
if (Response.Data.DiscussCount != 0) {

Check warning on line 1689 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Response.Data.DiscussCount != 0 may cause unexpected type coercion
UnreadBadge.innerText = Response.Data.DiscussCount;
UnreadBadge.style.display = "";
}
Expand Down Expand Up @@ -1728,7 +1741,7 @@
Style.innerHTML += " background-color: var(--bs-primary);";
Style.innerHTML += " color: white;";
Style.innerHTML += "}";
} else if (location.pathname == "/status.php") {

Check warning on line 1744 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison location.pathname == "/status.php" may cause unexpected type coercion
if (SearchParams.get("ByUserScript") == null) {
document.title = "提交状态";
document.querySelector("body > script:nth-child(5)").remove();
Expand Down Expand Up @@ -1859,7 +1872,7 @@
Temp[i].childNodes[4].childNodes[0].innerText = TimeToStringTime(Temp[i].childNodes[4].childNodes[0].innerText);
Temp[i].childNodes[5].innerText = Temp[i].childNodes[5].childNodes[0].innerText;
Temp[i].childNodes[6].innerText = CodeSizeToStringSize(Temp[i].childNodes[6].innerText.substring(0, Temp[i].childNodes[6].innerText.length - 1));
Temp[i].childNodes[9].innerText = (Temp[i].childNodes[9].innerText == "" ? "否" : "是");

Check warning on line 1875 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Temp\[i\].childNodes\[9\].innerText == "" may cause unexpected type coercion
}
if (SearchParams.get("cid") === null) {
localStorage.setItem("UserScript-Solution-" + SID + "-Problem", Temp[i].childNodes[1].innerText);
Expand All @@ -1885,7 +1898,7 @@
for (let i = 1; i <= SolutionIDs.length; i++) {
Rows[i].cells[2].className = "td_result";
let SolutionID = SolutionIDs[i - 1];
if (Rows[i].cells[2].children.length == 2) {

Check warning on line 1901 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Rows\[i\].cells\[2\].children.length == 2 may cause unexpected type coercion
Points[SolutionID] = Rows[i].cells[2].children[1].innerText;
Rows[i].cells[2].children[1].remove();
}
Expand All @@ -1899,7 +1912,7 @@
let CurrentRow = null;
let Rows = document.getElementById("result-tab").rows;
for (let i = 0; i < SolutionIDs.length; i++) {
if (SolutionIDs[i] == SolutionID) {

Check warning on line 1915 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison SolutionIDs\[i\] == SolutionID may cause unexpected type coercion
CurrentRow = Rows[i + 1];
break;
}
Expand All @@ -1918,10 +1931,10 @@
let ResponseData = Response.split(",");
CurrentRow.cells[3].innerHTML = "<div id=\"center\" class=\"red\">" + SizeToStringSize(ResponseData[1]) + "</div>";
CurrentRow.cells[4].innerHTML = "<div id=\"center\" class=\"red\">" + TimeToStringTime(ResponseData[2]) + "</div>";
let TempHTML = "<a href=\"" + (ResponseData[0] == 11 ? "ce" : "re") + "info.php?sid=" + SolutionID + "\" class=\"" + judge_color[ResponseData[0]] + "\">";

Check warning on line 1934 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison ResponseData\[0\] == 11 may cause unexpected type coercion
TempHTML += judge_result[ResponseData[0]];
TempHTML += "</a>";
if (Points[SolutionID] != undefined) {

Check warning on line 1937 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Points\[SolutionID\] != undefined may cause unexpected type coercion
TempHTML += "<span style=\"margin-left: 5px\" class=\"badge text-bg-info\">" + Points[SolutionID] + "</span>";
if (Points[SolutionID].substring(0, Points[SolutionID].length - 1) >= 50) {
TempHTML += `<a href="https://www.xmoj.tech/showsource.php?pid=${PID}&ByUserScript=1" class="ms-1 link-secondary">查看标程</a>`;
Expand All @@ -1932,12 +1945,12 @@
RefreshResult(SolutionID)
}, 500);
TempHTML += "<img style=\"margin-left: 5px\" height=\"18\" width=\"18\" src=\"image/loader.gif\">";
} else if (ResponseData[0] == 4 && UtilityEnabled("UploadStd")) {

Check warning on line 1948 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison ResponseData\[0\] == 4 may cause unexpected type coercion
if (SearchParams.get("cid") == null) CurrentRow.cells[1].innerText;
let Std = StdList.find((Element) => {
return Element == Number(PID);

Check warning on line 1951 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Element == Number(PID) may cause unexpected type coercion
});
if (Std != undefined) {

Check warning on line 1953 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Std != undefined may cause unexpected type coercion
TempHTML += "✅";
} else {
RequestAPI("UploadStd", {
Expand All @@ -1956,12 +1969,12 @@
};
}
}
} else if (location.pathname == "/contest.php") {

Check warning on line 1972 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison location.pathname == "/contest.php" may cause unexpected type coercion
if (UtilityEnabled("AutoCountdown")) {
clock = () => {

Check notice on line 1974 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Implicitly declared global JavaScript variable

Variable clock implicitly declared
}
}
if (location.href.indexOf("?cid=") == -1) {

Check warning on line 1977 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison location.href.indexOf("?cid=") == -1 may cause unexpected type coercion
if (UtilityEnabled("ResetType")) {
document.querySelector("body > div > div.mt-3 > center").innerHTML = String(document.querySelector("body > div > div.mt-3 > center").innerHTML).replaceAll("ServerTime:", "服务器时间:");
document.querySelector("body > div > div.mt-3 > center > table").style.marginTop = "10px";
Expand All @@ -1986,20 +1999,20 @@
let Temp = document.querySelector("body > div > div.mt-3 > center > table > tbody").childNodes;
for (let i = 1; i < Temp.length; i++) {
let CurrentElement = Temp[i].childNodes[2].childNodes;
if (CurrentElement[1].childNodes[0].data.indexOf("运行中") != -1) {

Check warning on line 2002 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison CurrentElement\[1\].childNodes\[0\].data.indexOf("运行中") != -1 may cause unexpected type coercion
let Time = String(CurrentElement[1].childNodes[1].innerText).substring(4);
let Day = parseInt(Time.substring(0, Time.indexOf("天"))) || 0;
let Hour = parseInt(Time.substring((Time.indexOf("天") == -1 ? 0 : Time.indexOf("天") + 1), Time.indexOf("小时"))) || 0;

Check warning on line 2005 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Time.indexOf("天") == -1 may cause unexpected type coercion
let Minute = parseInt(Time.substring((Time.indexOf("小时") == -1 ? 0 : Time.indexOf("小时") + 2), Time.indexOf("分"))) || 0;

Check warning on line 2006 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Time.indexOf("小时") == -1 may cause unexpected type coercion
let Second = parseInt(Time.substring((Time.indexOf("分") == -1 ? 0 : Time.indexOf("分") + 1), Time.indexOf("秒"))) || 0;

Check warning on line 2007 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Time.indexOf("分") == -1 may cause unexpected type coercion
let TimeStamp = new Date().getTime() + diff + ((((isNaN(Day) ? 0 : Day) * 24 + Hour) * 60 + Minute) * 60 + Second) * 1000;
CurrentElement[1].childNodes[1].setAttribute("EndTime", TimeStamp);
CurrentElement[1].childNodes[1].classList.add("UpdateByJS");
} else if (CurrentElement[1].childNodes[0].data.indexOf("开始于") != -1) {

Check warning on line 2011 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison CurrentElement\[1\].childNodes\[0\].data.indexOf("开始于") != -1 may cause unexpected type coercion
let TimeStamp = Date.parse(String(CurrentElement[1].childNodes[0].data).substring(4)) + diff;
CurrentElement[1].setAttribute("EndTime", TimeStamp);
CurrentElement[1].classList.add("UpdateByJS");
} else if (CurrentElement[1].childNodes[0].data.indexOf("已结束") != -1) {

Check warning on line 2015 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison CurrentElement\[1\].childNodes\[0\].data.indexOf("已结束") != -1 may cause unexpected type coercion
let TimeStamp = String(CurrentElement[1].childNodes[0].data).substring(4);
CurrentElement[1].childNodes[0].data = " 已结束 ";
CurrentElement[1].className = "red";
Expand Down Expand Up @@ -2031,7 +2044,7 @@
HTMLData = HTMLData.replaceAll("\n现在时间: ", "当前时间:")
HTMLData = HTMLData.replaceAll("\n状态:", "<br>状态:")
document.querySelector("body > div > div.mt-3 > center > div").innerHTML = HTMLData;
if (UtilityEnabled("RemoveAlerts") && document.querySelector("body > div > div.mt-3 > center").innerHTML.indexOf("尚未开始比赛") != -1) {

Check warning on line 2047 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison document.querySelector("body \> div \> div.mt-3 \> center").innerHTML.indexOf("尚未开始比赛") != -1 may cause unexpected type coercion
document.querySelector("body > div > div.mt-3 > center > a").setAttribute("href", "start_contest.php?cid=" + SearchParams.get("cid"));
} else if (UtilityEnabled("AutoRefresh")) {
addEventListener("focus", async () => {
Expand All @@ -2045,10 +2058,10 @@
if (UtilityEnabled("ReplaceYN")) {
for (let i = 0; i < Temp.length; i++) {
let Status = Temp[i].children[0].innerText;
if (Status.indexOf("Y") != -1) {

Check warning on line 2061 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Status.indexOf("Y") != -1 may cause unexpected type coercion
document.querySelector("#problemset > tbody").children[i].children[0].children[0].className = "status status_y";
document.querySelector("#problemset > tbody").children[i].children[0].children[0].innerText = "✓";
} else if (Status.indexOf("N") != -1) {

Check warning on line 2064 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Status.indexOf("N") != -1 may cause unexpected type coercion
document.querySelector("#problemset > tbody").children[i].children[0].children[0].className = "status status_n";
document.querySelector("#problemset > tbody").children[i].children[0].children[0].innerText = "✗";
}
Expand All @@ -2071,14 +2084,14 @@

document.querySelector("#problemset > tbody").innerHTML = String(document.querySelector("#problemset > tbody").innerHTML).replaceAll(/\t\*([0-9]*) &nbsp;&nbsp;&nbsp;&nbsp; 问题 &nbsp;([^<]*)/g, "拓展$2. $1");

if (UtilityEnabled("MoreSTD") && document.querySelector("#problemset > thead > tr").innerHTML.indexOf("标程") != -1) {

Check warning on line 2087 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison document.querySelector("#problemset \> thead \> tr").innerHTML.indexOf("标程") != -1 may cause unexpected type coercion
let Temp = document.querySelector("#problemset > thead > tr").children;
for (let i = 0; i < Temp.length; i++) {
if (Temp[i].innerText == "标程") {

Check warning on line 2090 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Temp\[i\].innerText == "标程" may cause unexpected type coercion
Temp[i].remove();
let Temp2 = document.querySelector("#problemset > tbody").children;
for (let j = 0; j < Temp2.length; j++) {
if (Temp2[j].children[i] != undefined) {

Check warning on line 2094 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Temp2\[j\].children\[i\] != undefined may cause unexpected type coercion
Temp2[j].children[i].remove();
}
}
Expand All @@ -2093,11 +2106,11 @@

Temp = document.querySelector("#problemset > tbody").rows;
for (let i = 0; i < Temp.length; i++) {
if (Temp[i].childNodes[0].children.length == 0) {

Check warning on line 2109 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Temp\[i\].childNodes\[0\].children.length == 0 may cause unexpected type coercion
Temp[i].childNodes[0].innerHTML = "<div class=\"status\"></div>";
}
let PID = Temp[i].childNodes[1].innerHTML;
if (PID.substring(0, 2) == "拓展") {

Check warning on line 2113 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison PID.substring(0, 2) == "拓展" may cause unexpected type coercion
PID = PID.substring(2);
}
Temp[i].children[2].children[0].target = "_blank";
Expand Down Expand Up @@ -2131,14 +2144,14 @@
});
let Rows = document.querySelector("#problemset > tbody").rows;
for (let i = 0; i < Rows.length; i++) {
ContestProblems.push(Rows[i].children[1].innerText.substring(Rows[i].children[1].innerText.indexOf('.') + 2)).toFixed;

Check notice on line 2147 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Expression statement which is not assignment or call

Expression statement is not assignment or call
}
AutoCheatButton.addEventListener("click", async () => {
AutoCheatButton.disabled = true;
let Submitted = false;
for (let i = 0; i < ContestProblems.length; i++) {
let PID = ContestProblems[i];
if (ACProblems.indexOf(Number(PID)) == -1) {

Check warning on line 2154 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison ACProblems.indexOf(Number(PID)) == -1 may cause unexpected type coercion
console.log("Ignoring problem " + PID + " as it has not been solved yet.");
continue;
}
Expand Down Expand Up @@ -2217,12 +2230,12 @@
localStorage.setItem("UserScript-Contest-" + SearchParams.get("cid") + "-ProblemCount", document.querySelector("#problemset > tbody").rows.length);
}
}
} else if (location.pathname == "/contestrank-oi.php") {

Check warning on line 2233 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison location.pathname == "/contestrank-oi.php" may cause unexpected type coercion
if (document.querySelector("#rank") == null) {
document.querySelector("body > div > div.mt-3").innerHTML = "<center><h3>比赛排名</h3><a></a><table id=\"rank\"></table>";
}
if (SearchParams.get("ByUserScript") == null) {
if (document.querySelector("body > div > div.mt-3 > center > h3").innerText == "比赛排名") {

Check warning on line 2238 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison document.querySelector("body \> div \> div.mt-3 \> center \> h3").innerText == "比赛排名" may cause unexpected type coercion
document.querySelector("#rank").innerText = "比赛暂时还没有排名";
} else {
document.querySelector("body > div > div.mt-3 > center > h3").innerText = document.querySelector("body > div > div.mt-3 > center > h3").innerText.substring(document.querySelector("body > div > div.mt-3 > center > h3").innerText.indexOf(" -- ") + 4) + "(OI排名)";
Expand All @@ -2247,7 +2260,7 @@
Metal.className = "badge text-bg-primary";
MetalCell.innerText = "";
MetalCell.appendChild(Metal);
GetUsernameHTML(Temp[i].cells[1], Temp[i].cells[1].innerText);

Check notice on line 2263 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Missing await for an async function call

Missing await for an async function call
Temp[i].cells[2].innerHTML = Temp[i].cells[2].innerText;
Temp[i].cells[3].innerHTML = Temp[i].cells[3].innerText;
for (let j = 5; j < Temp[i].cells.length; j++) {
Expand All @@ -2256,14 +2269,14 @@
let Red = BackgroundColor.substring(4, BackgroundColor.indexOf(","));
let Green = BackgroundColor.substring(BackgroundColor.indexOf(",") + 2, BackgroundColor.lastIndexOf(","));
let Blue = BackgroundColor.substring(BackgroundColor.lastIndexOf(",") + 2, BackgroundColor.lastIndexOf(")"));
let NoData = (Red == 238 && Green == 238 && Blue == 238);

Check warning on line 2272 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Blue == 238 may cause unexpected type coercion

Check warning on line 2272 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Red == 238 may cause unexpected type coercion

Check warning on line 2272 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Green == 238 may cause unexpected type coercion
let FirstBlood = (Red == 170 && Green == 170 && Blue == 255);

Check warning on line 2273 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Blue == 255 may cause unexpected type coercion

Check warning on line 2273 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Green == 170 may cause unexpected type coercion

Check warning on line 2273 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Red == 170 may cause unexpected type coercion
let Solved = (Green == 255);

Check warning on line 2274 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Green == 255 may cause unexpected type coercion
let ErrorCount = "";
if (Solved) {
ErrorCount = (Blue == 170 ? 5 : (Blue - 51) / 32);

Check warning on line 2277 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Blue == 170 may cause unexpected type coercion
} else {
ErrorCount = (Blue == 22 ? 15 : (170 - Blue) / 10);

Check warning on line 2279 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Blue == 22 may cause unexpected type coercion
}
if (NoData) {
BackgroundColor = "";
Expand All @@ -2271,13 +2284,13 @@
BackgroundColor = "rgb(127, 127, 255)";
} else if (Solved) {
BackgroundColor = "rgb(0, 255, 0, " + Math.max(1 / 10 * (10 - ErrorCount), 0.2) + ")";
if (ErrorCount != 0) {

Check warning on line 2287 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison ErrorCount != 0 may cause unexpected type coercion
InnerText += " (" + (ErrorCount == 5 ? "4+" : ErrorCount) + ")";

Check warning on line 2288 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison ErrorCount == 5 may cause unexpected type coercion
}
} else {
BackgroundColor = "rgba(255, 0, 0, " + Math.min(ErrorCount / 10 + 0.2, 1) + ")";
if (ErrorCount != 0) {

Check warning on line 2292 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison ErrorCount != 0 may cause unexpected type coercion
InnerText += " (" + (ErrorCount == 15 ? "14+" : ErrorCount) + ")";

Check warning on line 2293 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison ErrorCount == 15 may cause unexpected type coercion
}
}
Temp[i].cells[j].innerHTML = InnerText;
Expand All @@ -2288,14 +2301,14 @@
document.querySelector("#rank > tbody").innerHTML = ParsedDocument.querySelector("#rank > tbody").innerHTML;
});
};
RefreshOIRank();

Check notice on line 2304 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Missing await for an async function call

Missing await for an async function call
document.title = document.querySelector("body > div.container > div > center > h3").innerText;
if (UtilityEnabled("AutoRefresh")) {
addEventListener("focus", RefreshOIRank);
}
}
} else if (UtilityEnabled("ACMRank")) {
if (document.querySelector("body > div > div.mt-3 > center > h3").innerText != "比赛排名") {

Check warning on line 2311 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison document.querySelector("body \> div \> div.mt-3 \> center \> h3").innerText != "比赛排名" may cause unexpected type coercion
document.querySelector("body > div > div.mt-3 > center > h3").innerText = document.querySelector("body > div > div.mt-3 > center > h3").innerText.substring(document.querySelector("body > div > div.mt-3 > center > h3").innerText.indexOf(" -- ") + 4) + "(ACM排名)";
}
let RankData = [];
Expand All @@ -2315,7 +2328,7 @@
Table.innerHTML = "";
let StartPosition = Response.indexOf("var solutions=") + 14;
let EndPosition = Response.indexOf("}];", StartPosition) + 2;
if (EndPosition == 1) {

Check warning on line 2331 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison EndPosition == 1 may cause unexpected type coercion
Table.innerHTML = "暂时还没有人提交呢";
} else {
let SubmitRecord = JSON.parse(Response.substring(StartPosition, EndPosition));
Expand All @@ -2323,7 +2336,7 @@
for (let i = 0; i < SubmitRecord.length; i++) {
let CurrentSubmission = SubmitRecord[i];
let CurrentRow = RankData.find((CurrentRow) => {
if (CurrentRow.Username == CurrentSubmission.user_id) {

Check warning on line 2339 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison CurrentRow.Username == CurrentSubmission.user_id may cause unexpected type coercion
return true;
}
});
Expand All @@ -2339,7 +2352,7 @@
RankData.push(CurrentRow);
}
let CurrentProblem = CurrentRow.Problem.find((CurrentRow) => {
if (CurrentRow.Index == CurrentSubmission.num) {

Check warning on line 2355 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison CurrentRow.Index == CurrentSubmission.num may cause unexpected type coercion
return true;
}
});
Expand All @@ -2349,7 +2362,7 @@
};
CurrentRow.Problem.push(CurrentProblem);
}
if (CurrentSubmission.result == 4 && CurrentProblem.SolveTime == 0) {

Check warning on line 2365 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison CurrentProblem.SolveTime == 0 may cause unexpected type coercion

Check warning on line 2365 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison CurrentSubmission.result == 4 may cause unexpected type coercion
CurrentProblem.SolveTime = parseInt(CurrentSubmission.in_date);
CurrentRow.Solved++;
CurrentRow.Penalty += parseInt(CurrentSubmission.in_date) + CurrentProblem.Attempts.length * 20 * 60;
Expand All @@ -2362,7 +2375,7 @@
for (let i = 0; i < RankData.length; i++) {
for (let j = 0; j < RankData[i].Problem.length; j++) {
for (let k = 0; k < RankData[i].Problem.length; k++) {
if (j != k && RankData[i].Problem[j].SolveTime != 0 && RankData[i].Problem[k].SolveTime != 0 && Math.abs(RankData[i].Problem[j].SolveTime - RankData[i].Problem[k].SolveTime) < 60) {

Check warning on line 2378 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison RankData\[i\].Problem\[k\].SolveTime != 0 may cause unexpected type coercion

Check warning on line 2378 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison RankData\[i\].Problem\[j\].SolveTime != 0 may cause unexpected type coercion

Check warning on line 2378 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison j != k may cause unexpected type coercion
RankData[i].QuickSubmitCount++;
}
}
Expand All @@ -2370,9 +2383,9 @@
}

RankData.sort((a, b) => {
if (a.Solved != b.Solved) {

Check warning on line 2386 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison a.Solved != b.Solved may cause unexpected type coercion
return a.Solved < b.Solved ? 1 : -1;
} else if (a.Penalty != b.Penalty) {

Check warning on line 2388 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison a.Penalty != b.Penalty may cause unexpected type coercion
return a.Penalty > b.Penalty ? 1 : -1;
}
return 0;
Expand Down Expand Up @@ -2454,8 +2467,8 @@

let UsernameSpan = document.createElement("span");
UsernameCell.appendChild(UsernameSpan);
GetUsernameHTML(UsernameSpan, RowData.Username);

Check notice on line 2470 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Missing await for an async function call

Missing await for an async function call
if (RowData.Username == CurrentUsername) {

Check warning on line 2471 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison RowData.Username == CurrentUsername may cause unexpected type coercion
Row.classList.add("table-primary");
}
if (RowData.QuickSubmitCount >= 2) {
Expand Down Expand Up @@ -2632,7 +2645,7 @@
"weijiefu": "韦杰夫",
"": ""
};
NameCell.innerText = (Names[RowData.Username] == undefined ? "" : Names[RowData.Username]);

Check warning on line 2648 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Names\[RowData.Username\] == undefined may cause unexpected type coercion

SolvedCell.innerText = RowData.Solved;

Expand All @@ -2642,13 +2655,13 @@
let Problem = document.createElement("td");
Row.appendChild(Problem);
let ProblemData = RowData.Problem.find((CurrentRow) => {
if (CurrentRow.Index == j) {

Check warning on line 2658 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison CurrentRow.Index == j may cause unexpected type coercion
return true;
}
});
if (ProblemData == undefined) {

Check warning on line 2662 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison ProblemData == undefined may cause unexpected type coercion
Problem.style.backgroundColor = "rgba(0, 0, 0, 0)";
} else if (ProblemData.SolveTime != 0) {

Check warning on line 2664 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison ProblemData.SolveTime != 0 may cause unexpected type coercion
Problem.innerText = SecondsToString(ProblemData.SolveTime) + "(" + ProblemData.Attempts.length + ")";
let Color = Math.max(1 / 10 * (10 - ProblemData.Attempts.length), 0.2);
Problem.style.backgroundColor = "rgba(0, 255, 0, " + Color + ")";
Expand Down Expand Up @@ -2679,7 +2692,7 @@
location.href = "https://www.xmoj.tech/contestrank.xls.php?cid=" + SearchParams.get("cid");
});
let ProblemCount = localStorage.getItem("UserScript-Contest-" + SearchParams.get("cid") + "-ProblemCount");
RefreshACMRank(ProblemCount);

Check notice on line 2695 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Missing await for an async function call

Missing await for an async function call
if (UtilityEnabled("AutoRefresh")) {
addEventListener("focus", () => {
RefreshACMRank(ProblemCount);
Expand All @@ -2692,11 +2705,11 @@
document.querySelector("body > div.container > div > center").style.paddingBottom = "10px";
document.querySelector("body > div.container > div > center > a").style.display = "none";
document.title = document.querySelector("body > div.container > div > center > h3").innerText;
} else if (location.pathname == "/contestrank-correct.php") {

Check warning on line 2708 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison location.pathname == "/contestrank-correct.php" may cause unexpected type coercion
if (document.querySelector("#rank") == null) {
document.querySelector("body > div > div.mt-3").innerHTML = "<center><h3>比赛排名</h3><a></a><table id=\"rank\"></table>";
}
if (document.querySelector("body > div > div.mt-3 > center > h3").innerText == "比赛排名") {

Check warning on line 2712 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison document.querySelector("body \> div \> div.mt-3 \> center \> h3").innerText == "比赛排名" may cause unexpected type coercion
document.querySelector("#rank").innerText = "比赛暂时还没有排名";
} else {
if (UtilityEnabled("ResetType")) {
Expand Down Expand Up @@ -2724,7 +2737,7 @@
Metal.className = "badge text-bg-primary";
MetalCell.innerText = "";
MetalCell.appendChild(Metal);
GetUsernameHTML(Temp[i].cells[1], Temp[i].cells[1].innerText);

Check notice on line 2740 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Missing await for an async function call

Missing await for an async function call
Temp[i].cells[2].innerHTML = Temp[i].cells[2].innerText;
Temp[i].cells[3].innerHTML = Temp[i].cells[3].innerText;
for (let j = 5; j < Temp[i].cells.length; j++) {
Expand All @@ -2733,14 +2746,14 @@
let Red = BackgroundColor.substring(4, BackgroundColor.indexOf(","));
let Green = BackgroundColor.substring(BackgroundColor.indexOf(",") + 2, BackgroundColor.lastIndexOf(","));
let Blue = BackgroundColor.substring(BackgroundColor.lastIndexOf(",") + 2, BackgroundColor.lastIndexOf(")"));
let NoData = (Red == 238 && Green == 238 && Blue == 238);

Check warning on line 2749 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Blue == 238 may cause unexpected type coercion

Check warning on line 2749 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Red == 238 may cause unexpected type coercion

Check warning on line 2749 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Green == 238 may cause unexpected type coercion
let FirstBlood = (Red == 170 && Green == 170 && Blue == 255);

Check warning on line 2750 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Red == 170 may cause unexpected type coercion

Check warning on line 2750 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Green == 170 may cause unexpected type coercion

Check warning on line 2750 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Blue == 255 may cause unexpected type coercion
let Solved = (Green == 255);

Check warning on line 2751 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Green == 255 may cause unexpected type coercion
let ErrorCount = "";
if (Solved) {
ErrorCount = (Blue == 170 ? "4+" : (Blue - 51) / 32);

Check warning on line 2754 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Blue == 170 may cause unexpected type coercion
} else {
ErrorCount = (Blue == 22 ? "14+" : (170 - Blue) / 10);

Check warning on line 2756 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Blue == 22 may cause unexpected type coercion
}
if (NoData) {
BackgroundColor = "";
Expand All @@ -2748,12 +2761,12 @@
BackgroundColor = "rgba(127, 127, 255, 0.5)";
} else if (Solved) {
BackgroundColor = "rgba(0, 255, 0, 0.5)";
if (ErrorCount != 0) {

Check warning on line 2764 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison ErrorCount != 0 may cause unexpected type coercion
InnerText += " (" + ErrorCount + ")";
}
} else {
BackgroundColor = "rgba(255, 0, 0, 0.5)";
if (ErrorCount != 0) {

Check warning on line 2769 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison ErrorCount != 0 may cause unexpected type coercion
InnerText += " (" + ErrorCount + ")";
}
}
Expand All @@ -2764,13 +2777,13 @@
document.querySelector("#rank > tbody").innerHTML = ParsedDocument.querySelector("#rank > tbody").innerHTML;
});
};
RefreshCorrectRank();

Check notice on line 2780 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Missing await for an async function call

Missing await for an async function call
document.title = document.querySelector("body > div.container > div > center > h3").innerText;
if (UtilityEnabled("AutoRefresh")) {
addEventListener("focus", RefreshCorrectRank);
}
}
} else if (location.pathname == "/submitpage.php") {

Check warning on line 2786 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison location.pathname == "/submitpage.php" may cause unexpected type coercion
document.title = "提交代码: " + (SearchParams.get("id") != null ? "题目" + Number(SearchParams.get("id")) : "比赛" + Number(SearchParams.get("cid")));
document.querySelector("body > div > div.mt-3").innerHTML = `<center class="mb-3">` + `<h3>提交代码</h3>` + (SearchParams.get("id") != null ? `题目<span class="blue">${Number(SearchParams.get("id"))}</span>` : `比赛<span class="blue">${Number(SearchParams.get("cid")) + `</span>&emsp;题目<span class="blue">` + String.fromCharCode(65 + parseInt(SearchParams.get("pid")))}</span>`) + `</center>
<textarea id="CodeInput"></textarea>
Expand Down Expand Up @@ -2798,7 +2811,7 @@
tabMode: "shift",
theme: (UtilityEnabled("DarkMode") ? "darcula" : "default"),
extraKeys: {
"Ctrl-Space": "autocomplete", "Ctrl-Enter": function (instance) {

Check warning on line 2814 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Unused local symbol

Unused parameter instance
Submit.click();
}
}
Expand Down Expand Up @@ -2861,7 +2874,7 @@
),
);
}
rPID = contestProblems[new URL(location.href).searchParams.get("pid")];

Check notice on line 2877 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Implicitly declared global JavaScript variable

Variable rPID implicitly declared
if (UtilityEnabled("DebugMode")) {
console.log("Contest Problems:", contestProblems);
console.log("Real PID:", rPID);
Expand Down Expand Up @@ -2905,7 +2918,7 @@
document.querySelector("#Submit").disabled = true;
document.querySelector("#Submit").value = "正在检查...";
let Source = CodeMirrorElement.getValue();
let PID = 0;

Check warning on line 2921 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Unused assignment

Variable initializer is redundant
let IOFilename = "";
if (SearchParams.get("cid") != null && SearchParams.get("pid") != null) {
PID = localStorage.getItem("UserScript-Contest-" + SearchParams.get("cid") + "-Problem-" + SearchParams.get("pid") + "-PID")
Expand All @@ -2914,7 +2927,7 @@
}
IOFilename = localStorage.getItem("UserScript-Problem-" + PID + "-IOFilename");
if (UtilityEnabled("IOFile") && IOFilename != null) {
if (Source.indexOf(IOFilename) == -1) {

Check warning on line 2930 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Source.indexOf(IOFilename) == -1 may cause unexpected type coercion
PassCheck.style.display = "";
ErrorElement.style.display = "block";
if (UtilityEnabled("DarkMode")) ErrorMessage.style.color = "yellow"; else ErrorMessage.style.color = "red";
Expand Down Expand Up @@ -2960,7 +2973,7 @@
return false;
}
}
if (Source == "") {

Check warning on line 2976 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Source == "" may cause unexpected type coercion
PassCheck.style.display = "";
ErrorElement.style.display = "block";
if (UtilityEnabled("DarkMode")) ErrorMessage.style.color = "yellow"; else ErrorMessage.style.color = "red";
Expand Down Expand Up @@ -2997,7 +3010,7 @@
PassCheck.click();
}
});
} else if (location.pathname == "/modifypage.php") {

Check warning on line 3013 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison location.pathname == "/modifypage.php" may cause unexpected type coercion
if (SearchParams.get("ByUserScript") != null) {
document.title = "XMOJ-Script 更新日志";
document.querySelector("body > div > div.mt-3").innerHTML = "";
Expand Down Expand Up @@ -3031,7 +3044,7 @@
UpdateDataCardBody.appendChild(UpdateDataCardText);
UpdateDataCardText.className = "card-text";
//release notes
if (Data.Notes != undefined) {

Check warning on line 3047 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Data.Notes != undefined may cause unexpected type coercion
UpdateDataCardText.innerHTML = Data.Notes;
}
let UpdateDataCardList = document.createElement("ul");
Expand Down Expand Up @@ -3218,8 +3231,8 @@
ExportACCode.innerText = "正在导出...";
let Request = new XMLHttpRequest();
Request.addEventListener("readystatechange", () => {
if (Request.readyState == 4) {

Check warning on line 3234 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Request.readyState == 4 may cause unexpected type coercion
if (Request.status == 200) {

Check warning on line 3235 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Request.status == 200 may cause unexpected type coercion
let Response = Request.responseText;
let ACCode = Response.split("------------------------------------------------------\r\n");
let ScriptElement = document.createElement("script");
Expand All @@ -3232,7 +3245,7 @@
var Zip = new JSZip();
for (let i = 0; i < ACCode.length; i++) {
let CurrentCode = ACCode[i];
if (CurrentCode != "") {

Check warning on line 3248 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison CurrentCode != "" may cause unexpected type coercion
let CurrentQuestionID = CurrentCode.substring(7, 11);
CurrentCode = CurrentCode.substring(14);
CurrentCode = CurrentCode.replaceAll("\r", "");
Expand Down Expand Up @@ -3264,7 +3277,7 @@
});
}
}
} else if (location.pathname == "/userinfo.php") {

Check warning on line 3280 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison location.pathname == "/userinfo.php" may cause unexpected type coercion
if (SearchParams.get("ByUserScript") === null) {
if (UtilityEnabled("RemoveUseless")) {
let Temp = document.getElementById("submission").childNodes;
Expand All @@ -3277,10 +3290,10 @@

let Temp = document.querySelector("#statics > tbody").children;
for (let i = 0; i < Temp.length; i++) {
if (Temp[i].children[0] != undefined) {

Check warning on line 3293 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Temp\[i\].children\[0\] != undefined may cause unexpected type coercion
if (Temp[i].children[0].innerText == "Statistics") {

Check warning on line 3294 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Temp\[i\].children\[0\].innerText == "Statistics" may cause unexpected type coercion
Temp[i].children[0].innerText = "统计";
} else if (Temp[i].children[0].innerText == "Email:") {

Check warning on line 3296 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Temp\[i\].children\[0\].innerText == "Email:" may cause unexpected type coercion
Temp[i].children[0].innerText = "电子邮箱";
}
Temp[i].children[1].removeAttribute("align");
Expand All @@ -3290,7 +3303,7 @@
Temp = document.querySelector("#statics > tbody > tr:nth-child(1) > td:nth-child(3)").childNodes;
let ACProblems = [];
for (let i = 0; i < Temp.length; i++) {
if (Temp[i].tagName == "A" && Temp[i].href.indexOf("problem.php?id=") != -1) {

Check warning on line 3306 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Temp\[i\].href.indexOf("problem.php?id=") != -1 may cause unexpected type coercion

Check warning on line 3306 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Temp\[i\].tagName == "A" may cause unexpected type coercion
ACProblems.push(Number(Temp[i].innerText.trim()));
}
}
Expand All @@ -3313,7 +3326,7 @@
AvatarContainer.classList.add("col-auto");
let AvatarElement = document.createElement("img");
let UserEmailHash = (await GetUserInfo(UserID)).EmailHash;
if (UserEmailHash == undefined) {

Check warning on line 3329 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison UserEmailHash == undefined may cause unexpected type coercion
AvatarElement.src = `https://cravatar.cn/avatar/00000000000000000000000000000000?d=mp&f=y`;
} else {
AvatarElement.src = `https://cravatar.cn/avatar/${UserEmailHash}?d=retro`;
Expand Down Expand Up @@ -3445,7 +3458,7 @@
}).then((Response) => {
let ParsedDocument = new DOMParser().parseFromString(Response, "text/html");
let ScriptData = ParsedDocument.querySelector("#statics > tbody > tr:nth-child(2) > td:nth-child(3) > script").innerText;
ScriptData = ScriptData.substr(ScriptData.indexOf("}") + 1).trim();

Check notice on line 3461 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Deprecated symbol used

Deprecated symbol used, consult docs for better alternative
ScriptData = ScriptData.split(";");
for (let i = 0; i < ScriptData.length; i++) {
ACList.push(Number(ScriptData[i].substring(2, ScriptData[i].indexOf(","))));
Expand Down Expand Up @@ -3486,7 +3499,7 @@
});
});
}
} else if (location.pathname == "/conteststatistics.php") {

Check warning on line 3502 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison location.pathname == "/conteststatistics.php" may cause unexpected type coercion
if (new URL(location.href).searchParams.get("cid") != null) {
document.title = "比赛 " + new URL(location.href).searchParams.get("cid") + " 统计";
}
Expand All @@ -3513,15 +3526,15 @@
CurrentRowChildren[11].remove();
CurrentRowChildren[11].remove();
for (let j = 0; j < CurrentRowChildren.length; j++) {
if (CurrentRowChildren[j].innerText == "") {

Check warning on line 3529 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison CurrentRowChildren\[j\].innerText == "" may cause unexpected type coercion
CurrentRowChildren[j].innerText = "0";
}
}
}
}
} else if (location.pathname == "/comparesource.php") {

Check warning on line 3535 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison location.pathname == "/comparesource.php" may cause unexpected type coercion
if (UtilityEnabled("CompareSource")) {
if (location.search == "") {

Check warning on line 3537 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison location.search == "" may cause unexpected type coercion
document.querySelector("body > div.container > div").innerHTML = "";
let LeftCodeText = document.createElement("span");
document.querySelector("body > div.container > div").appendChild(LeftCodeText);
Expand Down Expand Up @@ -3587,7 +3600,7 @@
});
}
}
} else if (location.pathname == "/loginpage.php") {

Check warning on line 3603 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison location.pathname == "/loginpage.php" may cause unexpected type coercion
if (UtilityEnabled("NewBootstrap")) {
document.querySelector("#login").innerHTML = `<form id="login" action="login.php" method="post">
<div class="row g-3 align-items-center mb-3">
Expand Down Expand Up @@ -3624,7 +3637,7 @@
LoginButton.addEventListener("click", async () => {
let Username = document.getElementsByName("user_id")[0].value;
let Password = document.getElementsByName("password")[0].value;
if (Username == "" || Password == "") {

Check warning on line 3640 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Password == "" may cause unexpected type coercion

Check warning on line 3640 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Username == "" may cause unexpected type coercion
ErrorText.innerText = "用户名或密码不能为空";
} else {
await fetch("https://www.xmoj.tech/login.php", {
Expand All @@ -3637,7 +3650,7 @@
})
.then((Response) => {
if (UtilityEnabled("LoginFailed")) {
if (Response.indexOf("history.go(-2);") != -1) {

Check warning on line 3653 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Response.indexOf("history.go(-2);") != -1 may cause unexpected type coercion
if (UtilityEnabled("SavePassword")) {
localStorage.setItem("UserScript-Username", Username);
localStorage.setItem("UserScript-Password", Password);
Expand All @@ -3654,7 +3667,7 @@
}
Response = Response.substring(Response.indexOf("alert('") + 7);
Response = Response.substring(0, Response.indexOf("');"));
if (Response == "UserName or Password Wrong!") {

Check warning on line 3670 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Response == "UserName or Password Wrong!" may cause unexpected type coercion
ErrorText.innerText = "用户名或密码错误!";
} else {
ErrorText.innerText = Response;
Expand All @@ -3671,9 +3684,9 @@
document.querySelector("#login > div:nth-child(2) > div > input").value = localStorage.getItem("UserScript-Password");
LoginButton.click();
}
} else if (location.pathname == "/contest_video.php" || location.pathname == "/problem_video.php") {

Check warning on line 3687 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison location.pathname == "/problem_video.php" may cause unexpected type coercion

Check warning on line 3687 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison location.pathname == "/contest_video.php" may cause unexpected type coercion
let ScriptData = document.querySelector("body > div > div.mt-3 > center > script").innerHTML;
if (document.getElementById("J_prismPlayer0").innerHTML != "") {

Check warning on line 3689 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison document.getElementById("J_prismPlayer0").innerHTML != "" may cause unexpected type coercion
document.getElementById("J_prismPlayer0").innerHTML = "";
if (player) {
player.dispose();
Expand All @@ -3689,9 +3702,9 @@
let RandomUUID = () => {
let t = "0123456789abcdef";
let e = [];
for (let r = 0; r < 36; r++) e[r] = t.substr(Math.floor(16 * Math.random()), 1);

Check notice on line 3705 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Deprecated symbol used

Deprecated symbol used, consult docs for better alternative
e[14] = "4";
e[19] = t.substr(3 & e[19] | 8, 1);

Check notice on line 3707 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Deprecated symbol used

Deprecated symbol used, consult docs for better alternative
e[8] = e[13] = e[18] = e[23] = "-";
return e.join("");
};
Expand Down Expand Up @@ -3726,9 +3739,9 @@
document.querySelector("body > div > div.mt-3 > center").appendChild(DownloadButton);
});
}
} else if (location.pathname == "/reinfo.php") {

Check warning on line 3742 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison location.pathname == "/reinfo.php" may cause unexpected type coercion
document.title = "测试点信息: " + SearchParams.get("sid");
if (document.querySelector("#results > div") == undefined) {

Check warning on line 3744 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison document.querySelector("#results \> div") == undefined may cause unexpected type coercion
document.querySelector("#results").parentElement.innerHTML = "没有测试点信息";
} else {
for (let i = 0; i < document.querySelector("#results > div").children.length; i++) {
Expand Down Expand Up @@ -3830,7 +3843,7 @@
}).then((Response) => {
let ParsedDocument = new DOMParser().parseFromString(Response, "text/html");
let ErrorData = ParsedDocument.getElementById("errtxt").innerText;
let MatchResult = ErrorData.match(/\what\(\): \[([A-Za-z0-9+\/=]+)\]/g);

Check warning on line 3846 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Consecutive spaces

2 consecutive spaces in RegExp
if (MatchResult === null) {
GetDataButton.innerText = "获取数据失败";
GetDataButton.disabled = false;
Expand All @@ -3857,7 +3870,7 @@
document.getElementById("apply_data").addEventListener("click", () => {
let ApplyElements = document.getElementsByClassName("data");
for (let i = 0; i < ApplyElements.length; i++) {
ApplyElements[i].style.display = (ApplyElements[i].style.display == "block" ? "" : "block");

Check warning on line 3873 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison ApplyElements\[i\].style.display == "block" may cause unexpected type coercion
}
});
}
Expand All @@ -3881,7 +3894,7 @@
});
}
}
} else if (location.pathname == "/downloads.php") {

Check warning on line 3897 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison location.pathname == "/downloads.php" may cause unexpected type coercion
let SoftwareList = document.querySelector("body > div > ul");
SoftwareList.remove();
SoftwareList = document.createElement("ul");
Expand Down Expand Up @@ -3956,7 +3969,7 @@
SoftwareList.innerHTML += "<li class=\"software_item\">" + "<a href=\"" + Softwares[i].URL + "\">" + "<div class=\"item-info\">" + "<div class=\"item-img\">" + "<img height=\"50\" src=\"" + Softwares[i].Image + "\" alt=\"点击下载\">" + "</div>" + "<div class=\"item-txt\">" + Softwares[i].Name + "</div>" + "</div>" + "</a>" + "</li>";
}
}
} else if (location.pathname == "/problemstatus.php") {

Check warning on line 3972 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison location.pathname == "/problemstatus.php" may cause unexpected type coercion
document.querySelector("body > div > div.mt-3 > center").insertBefore(document.querySelector("#statics"), document.querySelector("body > div > div.mt-3 > center > table"));
document.querySelector("body > div > div.mt-3 > center").insertBefore(document.querySelector("#problemstatus"), document.querySelector("body > div > div.mt-3 > center > table"));

Expand All @@ -3979,9 +3992,9 @@
Temp = document.querySelector("#problemstatus > tbody").children;
for (let i = 0; i < Temp.length; i++) {
if (Temp[i].children[5].children[0] != null) {
Temp[i].children[1].innerHTML = `<a href="${Temp[i].children[5].children[0].href}">${Temp[i].children[1].innerText.trim()}</a>`;
Temp[i].children[1].innerHTML = `<a href="${Temp[i].children[5].children[0].href}">${escapeHTML(Temp[i].children[1].innerText.trim())}</a>`;
}
GetUsernameHTML(Temp[i].children[2], Temp[i].children[2].innerText);

Check notice on line 3997 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Missing await for an async function call

Missing await for an async function call
Temp[i].children[3].remove();
Temp[i].children[3].remove();
Temp[i].children[3].remove();
Expand All @@ -3997,12 +4010,12 @@
Pagination += `<li class="page-item"><a href="https://www.xmoj.tech/problemstatus.php?id=${PID + `&page=0" class="page-link">&laquo;</a></li><li class="page-item"><a href="https://www.xmoj.tech/problemstatus.php?id=` + PID + `&page=` + (CurrentPage - 1) + `" class="page-link">` + (CurrentPage)}</a></li>`;
}
Pagination += `<li class="active page-item"><a href="https://www.xmoj.tech/problemstatus.php?id=${PID + `&page=` + CurrentPage + `" class="page-link">` + (CurrentPage + 1)}</a></li>`;
if (document.querySelector("#problemstatus > tbody").children != null && document.querySelector("#problemstatus > tbody").children.length == 20) {

Check warning on line 4013 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison document.querySelector("#problemstatus \> tbody").children.length == 20 may cause unexpected type coercion
Pagination += `<li class="page-item"><a href="https://www.xmoj.tech/problemstatus.php?id=${PID + `&page=` + (CurrentPage + 1) + `" class="page-link">` + (CurrentPage + 2) + `</a></li><li class="page-item"><a href="https://www.xmoj.tech/problemstatus.php?id=` + PID + `&page=` + (CurrentPage + 1)}" class="page-link">&raquo;</a></li>`;
}
Pagination += `</ul></nav>`;
document.querySelector("body > div > div.mt-3 > center").innerHTML += Pagination;
} else if (location.pathname == "/problem_solution.php") {

Check warning on line 4018 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison location.pathname == "/problem_solution.php" may cause unexpected type coercion
if (UtilityEnabled("RemoveUseless")) {
document.querySelector("h2.lang_en").remove(); //fixes #332
}
Expand Down Expand Up @@ -4040,7 +4053,7 @@
theme: (UtilityEnabled("DarkMode") ? "darcula" : "default")
}).setSize("100%", "auto");
}
} else if (location.pathname == "/open_contest.php") {

Check warning on line 4056 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison location.pathname == "/open_contest.php" may cause unexpected type coercion
let Temp = document.querySelector("body > div > div.mt-3 > div > div.col-md-8").children;
let NewsData = [];
for (let i = 0; i < Temp.length; i += 2) {
Expand All @@ -4059,7 +4072,7 @@
let NewsRowHead = document.createElement("div");
NewsRowHead.className = "cnt-row-head title";
NewsRowHead.innerText = NewsData[i].Title;
if (NewsData[i].Time.getTime() != 0) {

Check warning on line 4075 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison NewsData\[i\].Time.getTime() != 0 may cause unexpected type coercion
NewsRowHead.innerHTML += "<small class=\"ms-3\">" + NewsData[i].Time.toLocaleDateString() + "</small>";
}
NewsRow.appendChild(NewsRowHead);
Expand All @@ -4079,7 +4092,7 @@
<div class="cnt-row-head title">倒计时</div>
<div class="cnt-row-body">${CountDownData}</div>
</div>`;
} else if (location.pathname == "/showsource.php") {

Check warning on line 4095 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison location.pathname == "/showsource.php" may cause unexpected type coercion
let Code = "";
if (SearchParams.get("ByUserScript") == null) {
document.title = "查看代码: " + SearchParams.get("id");
Expand Down Expand Up @@ -4114,7 +4127,7 @@
readOnly: true,
theme: (UtilityEnabled("DarkMode") ? "darcula" : "default")
}).setSize("100%", "auto");
} else if (location.pathname == "/ceinfo.php") {

Check warning on line 4130 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison location.pathname == "/ceinfo.php" may cause unexpected type coercion
await fetch(location.href)
.then((Result) => {
return Result.text();
Expand All @@ -4132,7 +4145,7 @@
theme: (UtilityEnabled("DarkMode") ? "darcula" : "default")
}).setSize("100%", "auto");
});
} else if (location.pathname == "/problem_std.php") {

Check warning on line 4148 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison location.pathname == "/problem_std.php" may cause unexpected type coercion
await fetch("https://www.xmoj.tech/problem_std.php?cid=" + SearchParams.get("cid") + "&pid=" + SearchParams.get("pid"))
.then((Response) => {
return Response.text();
Expand All @@ -4153,7 +4166,7 @@
}).setSize("100%", "auto");
}
});
} else if (location.pathname == "/mail.php") {

Check warning on line 4169 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison location.pathname == "/mail.php" may cause unexpected type coercion
if (SearchParams.get("to_user") == null) {
document.querySelector("body > div > div.mt-3").innerHTML = `<div class="row g-2 align-items-center">
<div class="col-auto form-floating">
Expand Down Expand Up @@ -4203,8 +4216,8 @@
Row.appendChild(UsernameCell);
let UsernameSpan = document.createElement("span");
UsernameCell.appendChild(UsernameSpan);
GetUsernameHTML(UsernameSpan, Data[i].OtherUser, false, "https://www.xmoj.tech/mail.php?to_user=");

Check notice on line 4219 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Missing await for an async function call

Missing await for an async function call
if (Data[i].UnreadCount != 0) {

Check warning on line 4220 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Data\[i\].UnreadCount != 0 may cause unexpected type coercion
let UnreadCountSpan = document.createElement("span");
UsernameCell.appendChild(UnreadCountSpan);
UnreadCountSpan.className = "ms-1 badge text-bg-danger";
Expand All @@ -4228,7 +4241,7 @@
});
AddUser.addEventListener("click", () => {
let UsernameData = Username.value;
if (UsernameData == "") {

Check warning on line 4244 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison UsernameData == "" may cause unexpected type coercion
Username.classList.add("is-invalid");
return;
}
Expand Down Expand Up @@ -4278,7 +4291,7 @@
</thead>
<tbody></tbody>
</table>`;
GetUsernameHTML(ToUser, SearchParams.get("to_user"));

Check notice on line 4294 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Missing await for an async function call

Missing await for an async function call
let RefreshMessage = (Silent = true) => {
if (!Silent) {
MessageTable.children[1].innerHTML = "";
Expand All @@ -4305,12 +4318,12 @@
for (let i = 0; i < Data.length; i++) {
let Row = document.createElement("tr");
MessageTable.children[1].appendChild(Row);
if (!Data[i].IsRead && Data[i].FromUser != CurrentUsername) {

Check warning on line 4321 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Data\[i\].FromUser != CurrentUsername may cause unexpected type coercion
Row.className = "table-info";
}
let UsernameCell = document.createElement("td");
Row.appendChild(UsernameCell);
GetUsernameHTML(UsernameCell, Data[i].FromUser);

Check notice on line 4326 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Missing await for an async function call

Missing await for an async function call
let ContentCell = document.createElement("td");
let ContentDiv = document.createElement("div");
ContentDiv.style.display = "flex";
Expand Down Expand Up @@ -4347,7 +4360,7 @@
let Items = EventData.clipboardData.items;
if (Items.length !== 0) {
for (let i = 0; i < Items.length; i++) {
if (Items[i].type.indexOf("image") != -1) {

Check warning on line 4363 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Items\[i\].type.indexOf("image") != -1 may cause unexpected type coercion
let Reader = new FileReader();
Reader.readAsDataURL(Items[i].getAsFile());
Reader.onload = () => {
Expand All @@ -4373,12 +4386,12 @@
}
});
Content.addEventListener("keydown", (Event) => {
if (Event.keyCode == 13) {

Check warning on line 4389 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Event.keyCode == 13 may cause unexpected type coercion
Send.click();
}
});
Send.addEventListener("click", () => {
if (Content.value == "") {

Check warning on line 4394 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Content.value == "" may cause unexpected type coercion
Content.classList.add("is-invalid");
return;
}
Expand All @@ -4403,10 +4416,10 @@
RefreshMessage(false);
addEventListener("focus", RefreshMessage);
}
} else if (location.pathname.indexOf("/discuss3") != -1) {

Check warning on line 4419 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison location.pathname.indexOf("/discuss3") != -1 may cause unexpected type coercion
if (UtilityEnabled("Discussion")) {
Discussion.classList.add("active");

Check warning on line 4421 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Object is 'null' or 'undefined'

Discussion is possibly null
if (location.pathname == "/discuss3/discuss.php") {

Check warning on line 4422 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison location.pathname == "/discuss3/discuss.php" may cause unexpected type coercion
document.title = "讨论列表";
let ProblemID = parseInt(SearchParams.get("pid"));
let BoardID = parseInt(SearchParams.get("bid"));
Expand Down Expand Up @@ -4466,7 +4479,7 @@
"Page": Number(Page),
"BoardID": Number(SearchParams.get("bid") || -1)
}, async (ResponseData) => {
if (ResponseData.Success == true) {

Check warning on line 4482 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison ResponseData.Success == true may cause unexpected type coercion
ErrorElement.style.display = "none";
if (!Silent) {
DiscussPagination.children[0].children[0].href = "https://www.xmoj.tech/discuss3/discuss.php?" + (isNaN(ProblemID) ? "" : "pid=" + ProblemID + "&") + (isNaN(BoardID) ? "" : "bid=" + BoardID + "&") + "page=1";
Expand All @@ -4485,7 +4498,7 @@
}
let Posts = ResponseData.Data.Posts;
PostList.children[1].innerHTML = "";
if (Posts.length == 0) {

Check warning on line 4501 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Posts.length == 0 may cause unexpected type coercion
PostList.children[1].innerHTML = `<tr><td colspan="7">暂无数据</td></tr>`;
}
for (let i = 0; i < Posts.length; i++) {
Expand All @@ -4506,10 +4519,10 @@
TitleLink.innerHTML += Posts[i].Title;
let AuthorCell = document.createElement("td");
Row.appendChild(AuthorCell);
GetUsernameHTML(AuthorCell, Posts[i].UserID);

Check notice on line 4522 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Missing await for an async function call

Missing await for an async function call
let ProblemIDCell = document.createElement("td");
Row.appendChild(ProblemIDCell);
if (Posts[i].ProblemID != 0) {

Check warning on line 4525 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Posts\[i\].ProblemID != 0 may cause unexpected type coercion
let ProblemIDLink = document.createElement("a");
ProblemIDCell.appendChild(ProblemIDLink);
ProblemIDLink.href = "https://www.xmoj.tech/problem.php?id=" + Posts[i].ProblemID;
Expand Down Expand Up @@ -4549,7 +4562,7 @@
}
}
});
} else if (location.pathname == "/discuss3/newpost.php") {

Check warning on line 4565 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison location.pathname == "/discuss3/newpost.php" may cause unexpected type coercion
let ProblemID = parseInt(SearchParams.get("pid"));
document.querySelector("body > div > div").innerHTML = `<h3>发布新讨论` + (!isNaN(ProblemID) ? ` - 题目` + ProblemID : ``) + `</h3>
<div class="form-group mb-3" id="BoardSelect">
Expand Down Expand Up @@ -4587,7 +4600,7 @@
TurnstileScript.src = "https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit&onload=CaptchaLoadedCallback";
document.body.appendChild(TurnstileScript);
ContentElement.addEventListener("keydown", (Event) => {
if (Event.ctrlKey && Event.keyCode == 13) {

Check warning on line 4603 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Event.keyCode == 13 may cause unexpected type coercion
SubmitElement.click();
}
});
Expand All @@ -4603,7 +4616,7 @@
let Items = EventData.clipboardData.items;
if (Items.length !== 0) {
for (let i = 0; i < Items.length; i++) {
if (Items[i].type.indexOf("image") != -1) {

Check warning on line 4619 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Items\[i\].type.indexOf("image") != -1 may cause unexpected type coercion
let Reader = new FileReader();
Reader.readAsDataURL(Items[i].getAsFile());
Reader.onload = () => {
Expand Down Expand Up @@ -4657,7 +4670,7 @@
}, (ResponseData) => {
SubmitElement.disabled = false;
SubmitElement.children[0].style.display = "none";
if (ResponseData.Success == true) {

Check warning on line 4673 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison ResponseData.Success == true may cause unexpected type coercion
location.href = "https://www.xmoj.tech/discuss3/thread.php?tid=" + ResponseData.Data.PostID;
} else {
ErrorElement.innerText = ResponseData.Message;
Expand All @@ -4678,13 +4691,13 @@
RadioInput.id = "Board" + Data[i].BoardID;
RadioInput.value = Data[i].BoardID;
RadioElement.appendChild(RadioInput);
if (SearchParams.get("bid") !== null && SearchParams.get("bid") == Data[i].BoardID) {

Check warning on line 4694 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison SearchParams.get("bid") == Data\[i\].BoardID may cause unexpected type coercion
RadioInput.checked = true;
}
if (!isNaN(ProblemID)) {
RadioInput.disabled = true;
}
if (Data[i].BoardID == 4) {

Check warning on line 4700 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Data\[i\].BoardID == 4 may cause unexpected type coercion
if (!isNaN(ProblemID)) RadioInput.checked = true;
RadioInput.disabled = true;
}
Expand All @@ -4697,7 +4710,7 @@
}
}
});
} else if (location.pathname == "/discuss3/thread.php") {

Check warning on line 4713 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison location.pathname == "/discuss3/thread.php" may cause unexpected type coercion
if (SearchParams.get("tid") == null) {
location.href = "https://www.xmoj.tech/discuss3/discuss.php";
} else {
Expand Down Expand Up @@ -4764,7 +4777,7 @@
TurnstileScript.src = "https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit&onload=CaptchaLoadedCallback";
document.body.appendChild(TurnstileScript);
ContentElement.addEventListener("keydown", (Event) => {
if (Event.ctrlKey && Event.keyCode == 13) {

Check warning on line 4780 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Event.keyCode == 13 may cause unexpected type coercion
SubmitElement.click();
}
});
Expand All @@ -4776,7 +4789,7 @@
let Items = EventData.clipboardData.items;
if (Items.length !== 0) {
for (let i = 0; i < Items.length; i++) {
if (Items[i].type.indexOf("image") != -1) {

Check warning on line 4792 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Items\[i\].type.indexOf("image") != -1 may cause unexpected type coercion
let Reader = new FileReader();
Reader.readAsDataURL(Items[i].getAsFile());
Reader.onload = () => {
Expand Down Expand Up @@ -4826,7 +4839,7 @@
RequestAPI("GetPost", {
"PostID": Number(ThreadID), "Page": Number(Page)
}, async (ResponseData) => {
if (ResponseData.Success == true) {

Check warning on line 4842 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison ResponseData.Success == true may cause unexpected type coercion
let OldScrollTop = document.documentElement.scrollTop;
let LockButtons = !IsAdmin && ResponseData.Data.Lock.Locked;
if (!Silent) {
Expand All @@ -4843,14 +4856,14 @@
DiscussPagination.children[DiscussPagination.children.length - 1].classList.add("disabled");
DiscussPagination.children[DiscussPagination.children.length - 2].remove();
}
if (IsAdmin || ResponseData.Data.UserID == CurrentUsername) {

Check warning on line 4859 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison ResponseData.Data.UserID == CurrentUsername may cause unexpected type coercion
Delete.style.display = "";
}
}
PostTitle.innerHTML = ResponseData.Data.Title + (ResponseData.Data.ProblemID == 0 ? "" : ` - 题目` + ` <a href="https://www.xmoj.tech/problem.php?id=` + ResponseData.Data.ProblemID + `">` + ResponseData.Data.ProblemID + `</a>`);

Check warning on line 4863 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison ResponseData.Data.ProblemID == 0 may cause unexpected type coercion
document.title = "讨论" + ThreadID + ": " + ResponseData.Data.Title;
PostAuthor.innerHTML = "<span></span>";
GetUsernameHTML(PostAuthor.children[0], ResponseData.Data.UserID);

Check notice on line 4866 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Missing await for an async function call

Missing await for an async function call
PostTime.innerHTML = GetRelativeTime(ResponseData.Data.PostTime);
PostBoard.innerHTML = ResponseData.Data.BoardName;
let Replies = ResponseData.Data.Reply;
Expand All @@ -4873,7 +4886,7 @@
AuthorSpanElement.innerText = "作者:";
let AuthorUsernameElement = document.createElement("span");
AuthorElement.appendChild(AuthorUsernameElement);
GetUsernameHTML(AuthorUsernameElement, Replies[i].UserID);

Check notice on line 4889 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Missing await for an async function call

Missing await for an async function call
let SendTimeElement = document.createElement("span");
CardBodyRowElement.appendChild(SendTimeElement);
SendTimeElement.className = "col-4 text-muted";
Expand Down Expand Up @@ -4914,14 +4927,14 @@
DeleteButton.type = "button";
DeleteButton.className = "btn btn-sm btn-danger ms-1";
DeleteButton.innerText = "删除";
DeleteButton.style.display = (IsAdmin || Replies[i].UserID == CurrentUsername ? "" : "none");

Check warning on line 4930 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Replies\[i\].UserID == CurrentUsername may cause unexpected type coercion
DeleteButton.addEventListener("click", () => {
DeleteButton.disabled = true;
DeleteButton.lastChild.style.display = "";
RequestAPI("DeleteReply", {
"ReplyID": Number(Replies[i].ReplyID)
}, (ResponseData) => {
if (ResponseData.Success == true) {

Check warning on line 4937 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison ResponseData.Success == true may cause unexpected type coercion
RefreshReply();
} else {
DeleteButton.disabled = false;
Expand Down Expand Up @@ -4954,7 +4967,7 @@
ReplyID: Number(Replies[i].ReplyID),
Content: String(ContentEditor.value)
}, (ResponseData) => {
if (ResponseData.Success == true) {

Check warning on line 4970 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison ResponseData.Success == true may cause unexpected type coercion
RefreshReply();
} else {
OKButton.disabled = false;
Expand Down Expand Up @@ -4982,7 +4995,7 @@
EditButton.type = "button";
EditButton.className = "btn btn-sm btn-warning ms-1";
EditButton.innerText = "编辑";
EditButton.style.display = (IsAdmin || Replies[i].UserID == CurrentUsername ? "" : "none");

Check warning on line 4998 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Replies\[i\].UserID == CurrentUsername may cause unexpected type coercion
EditButton.addEventListener("click", () => {
CardBodyElement.children[2].style.display = "none";
CardBodyElement.children[3].style.display = "";
Expand All @@ -4999,7 +5012,7 @@
CardBodyElement.appendChild(ReplyContentElement);
ReplyContentElement.innerHTML = PurifyHTML(marked.parse(Replies[i].Content)).replaceAll(/@([a-zA-Z0-9]+)/g, `<b>@</b><span class="ms-1 Usernames">$1</span>`);
if (Replies[i].EditTime != null) {
if (Replies[i].EditPerson == Replies[i].UserID) {

Check warning on line 5015 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Replies\[i\].EditPerson == Replies\[i\].UserID may cause unexpected type coercion
ReplyContentElement.innerHTML += `<span class="text-muted" style="font-size: 12px">最后编辑于${GetRelativeTime(Replies[i].EditTime)}</span>`;
} else {
ReplyContentElement.innerHTML += `<span class="text-muted" style="font-size: 12px">最后被<span class="Usernames">${Replies[i].EditPerson}</span>编辑于${GetRelativeTime(Replies[i].EditTime)}</span>`;
Expand All @@ -5014,11 +5027,11 @@
ContentEditor.className = "form-control col-6";
ContentEditor.rows = 3;
ContentEditor.value = Replies[i].Content;
if (ContentEditor.value.indexOf("<br>") != -1) {

Check warning on line 5030 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison ContentEditor.value.indexOf(" ") != -1 may cause unexpected type coercion
ContentEditor.value = ContentEditor.value.substring(0, ContentEditor.value.indexOf("<br>"));
}
ContentEditor.addEventListener("keydown", (Event) => {
if (Event.ctrlKey && Event.keyCode == 13) {

Check notice on line 5034 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Deprecated symbol used

Deprecated symbol used, consult docs for better alternative

Check warning on line 5034 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Event.keyCode == 13 may cause unexpected type coercion
OKButton.click();
}
});
Expand All @@ -5034,7 +5047,7 @@
let Items = EventData.clipboardData.items;
if (Items.length !== 0) {
for (let i = 0; i < Items.length; i++) {
if (Items[i].type.indexOf("image") != -1) {

Check warning on line 5050 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison Items\[i\].type.indexOf("image") != -1 may cause unexpected type coercion
let Reader = new FileReader();
Reader.readAsDataURL(Items[i].getAsFile());
Reader.onload = () => {
Expand Down Expand Up @@ -5063,15 +5076,15 @@

let UsernameElements = document.getElementsByClassName("Usernames");
for (let i = 0; i < UsernameElements.length; i++) {
GetUsernameHTML(UsernameElements[i], UsernameElements[i].innerText, true);

Check notice on line 5079 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Missing await for an async function call

Missing await for an async function call
}

let CodeElements = document.querySelectorAll("#PostReplies > div > div > div:nth-child(3) > pre > code");
for (let i = 0; i < CodeElements.length; i++) {
let ModeName = "text/x-c++src";
if (CodeElements[i].className == "language-c") {

Check warning on line 5085 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison CodeElements\[i\].className == "language-c" may cause unexpected type coercion
ModeName = "text/x-csrc";
} else if (CodeElements[i].className == "language-cpp") {

Check warning on line 5087 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison CodeElements\[i\].className == "language-cpp" may cause unexpected type coercion
ModeName = "text/x-c++src";
}
CodeMirror(CodeElements[i].parentElement, {
Expand All @@ -5086,10 +5099,10 @@

if (LockButtons) {
let LockElement = ContentElement.parentElement.parentElement;
LockElement.innerHTML = "讨论已于 " + await GetRelativeTime(ResponseData.Data.Lock.LockTime) + " 被 ";

Check notice on line 5102 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Redundant 'await' expression

Redundant 'await' for a non-promise type
let LockUsernameSpan = document.createElement("span");
LockElement.appendChild(LockUsernameSpan);
GetUsernameHTML(LockUsernameSpan, ResponseData.Data.Lock.LockPerson);

Check notice on line 5105 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Missing await for an async function call

Missing await for an async function call
LockElement.innerHTML += " 锁定";
LockElement.classList.add("mb-5");
}
Expand Down Expand Up @@ -5119,7 +5132,7 @@
Style.innerHTML += " width: 50%;";
Style.innerHTML += "}";

RenderMathJax();

Check notice on line 5135 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Missing await for an async function call

Missing await for an async function call

if (Silent) {
scrollTo({
Expand All @@ -5139,7 +5152,7 @@
}, (ResponseData) => {
Delete.disabled = false;
Delete.children[0].style.display = "none";
if (ResponseData.Success == true) {

Check warning on line 5155 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison ResponseData.Success == true may cause unexpected type coercion
location.href = "https://www.xmoj.tech/discuss3/discuss.php";
} else {
ErrorElement.innerText = ResponseData.Message;
Expand All @@ -5158,11 +5171,11 @@
}, async (ResponseData) => {
SubmitElement.disabled = false;
SubmitElement.children[0].style.display = "none";
if (ResponseData.Success == true) {

Check warning on line 5174 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison ResponseData.Success == true may cause unexpected type coercion
RefreshReply();
ContentElement.value = "";
PreviewTab.innerHTML = "";
while (PostReplies.innerHTML.indexOf("placeholder") != -1) {

Check warning on line 5178 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison PostReplies.innerHTML.indexOf("placeholder") != -1 may cause unexpected type coercion
await new Promise((resolve) => {
setTimeout(resolve, 100);
});
Expand Down Expand Up @@ -5192,6 +5205,6 @@
}
}

main().then(r => {

Check warning on line 5208 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Unused local symbol

Unused parameter r
console.log("XMOJ-Script loaded successfully!");
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "xmoj-script",
"version": "1.3.0",
"version": "1.3.1",
"description": "an improvement script for xmoj.tech",
"main": "AddonScript.js",
"scripts": {
Expand Down
Loading