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 @@ -2692,6 +2692,17 @@
}
],
"Notes": "This was so hard......"
},
"1.2.75": {
"UpdateDate": 1738974525711,
"Prerelease": true,
"UpdateContents": [
{
"PR": 767,
"Description": "进入讨论后给出题目的链接 "
}
],
"Notes": "No release notes were provided for this release."
}
}
}
4 changes: 2 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.2.74
// @version 1.2.75
// @description XMOJ增强脚本
// @author @XMOJ-Script-dev, @langningchen and the community
// @namespace https://github/langningchen
Expand Down Expand Up @@ -70,7 +70,7 @@
Input = new Date(Input);
let Now = new Date().getTime();
let Delta = Now - Input.getTime();
let RelativeName = "";

Check warning on line 73 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 +140,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 143 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 +229,7 @@
let HTMLData = "";
if (!Simple) {
HTMLData += `<img src="`;
if (UserInfo.EmailHash == undefined) {

Check warning on line 232 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 +260,11 @@
if (AdminUserList.includes(Username)) {
HTMLData += `<span class="badge text-bg-danger ms-2">脚本管理员</span>`;
}
if (Username == "chenlangning") {

Check warning on line 263 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 267 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 +408,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 411 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 +487,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 490 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 +635,7 @@
//use https
location.href = location.href.replace('http://', 'https://');
}
if (location.host != "www.xmoj.tech") {

Check warning on line 638 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 +647,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 650 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 650 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

Check warning on line 650 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 650 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
localStorage.setItem("UserScript-LastPage", location.pathname + location.search);
location.href = "https://www.xmoj.tech/loginpage.php";
}
Expand Down Expand Up @@ -688,16 +688,16 @@

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

Check warning on line 691 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 692 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 694 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 696 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 698 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 700 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 +758,10 @@

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

Check warning on line 761 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 764 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 +770,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 773 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 +781,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 784 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 +914,7 @@
new NavbarStyler();
}
if (UtilityEnabled("ResetType")) {
if (document.querySelector("#profile") != undefined && document.querySelector("#profile").innerHTML == "登录") {

Check warning on line 917 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 917 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
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 +926,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 929 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 929 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 +1030,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 1033 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 +1062,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 1065 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 +1119,7 @@
UpdateDataCardBody.appendChild(UpdateDataCardText);
UpdateDataCardText.className = "card-text";
//release notes
if (Data.Notes != undefined) {

Check warning on line 1122 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 +1244,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 1247 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 +1285,7 @@
dispatchEvent(new Event("focus"));


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

Check warning on line 1288 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 1288 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 +1314,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 1317 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 1319 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 1321 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 1324 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 +1330,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 1333 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 +1350,7 @@
Label.innerText = Data[i].Name;
Row.appendChild(Label);
}
if (Data[i].Children != undefined) {

Check warning on line 1353 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 +1460,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 1463 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 +1496,7 @@
}
});
}
} else if (location.pathname == "/problemset.php") {

Check warning on line 1499 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 +1534,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 1537 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 +1584,12 @@
console.log(SubmitLink.href);
};
var Temp = document.querySelectorAll(".sampledata");
for (var i = 0; i < Temp.length; i++) {

Check warning on line 1587 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 1592 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 +1673,7 @@
"ProblemID": Number(PID)
}, (Response) => {
if (Response.Success) {
if (Response.Data.DiscussCount != 0) {

Check warning on line 1676 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 +1728,7 @@
Style.innerHTML += " background-color: var(--bs-primary);";
Style.innerHTML += " color: white;";
Style.innerHTML += "}";
} else if (location.pathname == "/status.php") {

Check warning on line 1731 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 +1859,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 1862 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 +1885,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 1888 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 +1899,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 1902 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 +1918,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 1921 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 1924 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 +1932,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 1935 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 1938 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 1940 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 +1956,12 @@
};
}
}
} else if (location.pathname == "/contest.php") {

Check warning on line 1959 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 1961 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 1964 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 +1986,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 1989 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 1992 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 1993 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 1994 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 1998 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 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 TimeStamp = String(CurrentElement[1].childNodes[0].data).substring(4);
CurrentElement[1].childNodes[0].data = " 已结束 ";
CurrentElement[1].className = "red";
Expand Down Expand Up @@ -2031,7 +2031,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 2034 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 +2045,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 2048 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 2051 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 +2071,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 2074 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 2077 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 2081 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 +2093,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 2096 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 2100 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 +2131,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 2134 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 2141 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 +2217,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 2220 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 2225 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 +2247,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 2250 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 +2256,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 2259 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

Check warning on line 2259 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 2259 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
let FirstBlood = (Red == 170 && Green == 170 && Blue == 255);

Check warning on line 2260 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 2260 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 2260 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
let Solved = (Green == 255);

Check warning on line 2261 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 2264 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 2266 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 +2271,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 2274 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 2275 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 2279 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 2280 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 +2288,14 @@
document.querySelector("#rank > tbody").innerHTML = ParsedDocument.querySelector("#rank > tbody").innerHTML;
});
};
RefreshOIRank();

Check notice on line 2291 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 2298 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 +2315,7 @@
Table.innerHTML = "";
let StartPosition = Response.indexOf("var solutions=") + 14;
let EndPosition = Response.indexOf("}];", StartPosition) + 2;
if (EndPosition == 1) {

Check warning on line 2318 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 +2323,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 2326 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 +2339,7 @@
RankData.push(CurrentRow);
}
let CurrentProblem = CurrentRow.Problem.find((CurrentRow) => {
if (CurrentRow.Index == CurrentSubmission.num) {

Check warning on line 2342 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 +2349,7 @@
};
CurrentRow.Problem.push(CurrentProblem);
}
if (CurrentSubmission.result == 4 && CurrentProblem.SolveTime == 0) {

Check warning on line 2352 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 2352 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 +2362,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 2365 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 2365 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 2365 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 +2370,9 @@
}

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

Check warning on line 2373 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 2375 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 +2454,8 @@

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

Check notice on line 2457 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 2458 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 +2632,7 @@
"weijiefu": "韦杰夫",
"": ""
};
NameCell.innerText = (Names[RowData.Username] == undefined ? "" : Names[RowData.Username]);

Check warning on line 2635 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 +2642,13 @@
let Problem = document.createElement("td");
Row.appendChild(Problem);
let ProblemData = RowData.Problem.find((CurrentRow) => {
if (CurrentRow.Index == j) {

Check warning on line 2645 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 2649 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 2651 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 +2679,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 2682 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 +2692,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 2695 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 2699 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 +2724,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 2727 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 +2733,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 2736 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 2736 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 2736 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 2737 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 2737 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 2737 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 2738 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 2741 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 2743 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 +2748,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 2751 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 2756 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 +2764,13 @@
document.querySelector("#rank > tbody").innerHTML = ParsedDocument.querySelector("#rank > tbody").innerHTML;
});
};
RefreshCorrectRank();

Check notice on line 2767 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 2773 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 +2798,7 @@
tabMode: "shift",
theme: (UtilityEnabled("DarkMode") ? "darcula" : "default"),
extraKeys: {
"Ctrl-Space": "autocomplete", "Ctrl-Enter": function (instance) {

Check warning on line 2801 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 +2861,7 @@
),
);
}
rPID = contestProblems[new URL(location.href).searchParams.get("pid")];

Check notice on line 2864 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 +2905,7 @@
document.querySelector("#Submit").disabled = true;
document.querySelector("#Submit").value = "正在检查...";
let Source = CodeMirrorElement.getValue();
let PID = 0;

Check warning on line 2908 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 +2914,7 @@
}
IOFilename = localStorage.getItem("UserScript-Problem-" + PID + "-IOFilename");
if (UtilityEnabled("IOFile") && IOFilename != null) {
if (Source.indexOf(IOFilename) == -1) {

Check warning on line 2917 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 +2960,7 @@
return false;
}
}
if (Source == "") {

Check warning on line 2963 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 +2997,7 @@
PassCheck.click();
}
});
} else if (location.pathname == "/modifypage.php") {

Check warning on line 3000 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 +3031,7 @@
UpdateDataCardBody.appendChild(UpdateDataCardText);
UpdateDataCardText.className = "card-text";
//release notes
if (Data.Notes != undefined) {

Check warning on line 3034 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 +3218,8 @@
ExportACCode.innerText = "正在导出...";
let Request = new XMLHttpRequest();
Request.addEventListener("readystatechange", () => {
if (Request.readyState == 4) {

Check warning on line 3221 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 3222 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 +3232,7 @@
var Zip = new JSZip();
for (let i = 0; i < ACCode.length; i++) {
let CurrentCode = ACCode[i];
if (CurrentCode != "") {

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 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 +3264,7 @@
});
}
}
} else if (location.pathname == "/userinfo.php") {

Check warning on line 3267 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 +3277,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 3280 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 3281 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 3283 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 +3290,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 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\].tagName == "A" may cause unexpected type coercion

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\].href.indexOf("problem.php?id=") != -1 may cause unexpected type coercion
ACProblems.push(Number(Temp[i].innerText.trim()));
}
}
Expand All @@ -3313,7 +3313,7 @@
AvatarContainer.classList.add("col-auto");
let AvatarElement = document.createElement("img");
let UserEmailHash = (await GetUserInfo(UserID)).EmailHash;
if (UserEmailHash == undefined) {

Check warning on line 3316 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 +3445,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 3448 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 +3486,7 @@
});
});
}
} else if (location.pathname == "/conteststatistics.php") {

Check warning on line 3489 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 +3513,15 @@
CurrentRowChildren[11].remove();
CurrentRowChildren[11].remove();
for (let j = 0; j < CurrentRowChildren.length; j++) {
if (CurrentRowChildren[j].innerText == "") {

Check warning on line 3516 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 3522 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 3524 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 +3587,7 @@
});
}
}
} else if (location.pathname == "/loginpage.php") {

Check warning on line 3590 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 +3624,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 3627 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

Check warning on line 3627 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
ErrorText.innerText = "用户名或密码不能为空";
} else {
await fetch("https://www.xmoj.tech/login.php", {
Expand All @@ -3637,7 +3637,7 @@
})
.then((Response) => {
if (UtilityEnabled("LoginFailed")) {
if (Response.indexOf("history.go(-2);") != -1) {

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 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 +3654,7 @@
}
Response = Response.substring(Response.indexOf("alert('") + 7);
Response = Response.substring(0, Response.indexOf("');"));
if (Response == "UserName or Password Wrong!") {

Check warning on line 3657 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 +3671,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 3674 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

Check warning on line 3674 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
let ScriptData = document.querySelector("body > div > div.mt-3 > center > script").innerHTML;
if (document.getElementById("J_prismPlayer0").innerHTML != "") {

Check warning on line 3676 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 +3689,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 3692 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 3694 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 +3726,9 @@
document.querySelector("body > div > div.mt-3 > center").appendChild(DownloadButton);
});
}
} else if (location.pathname == "/reinfo.php") {

Check warning on line 3729 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 3731 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 +3830,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 3833 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 +3857,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 3860 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 +3881,7 @@
});
}
}
} else if (location.pathname == "/downloads.php") {

Check warning on line 3884 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 +3956,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 3959 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 @@ -3981,7 +3981,7 @@
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>`;
}
GetUsernameHTML(Temp[i].children[2], Temp[i].children[2].innerText);

Check notice on line 3984 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 +3997,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 4000 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 4005 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 +4040,7 @@
theme: (UtilityEnabled("DarkMode") ? "darcula" : "default")
}).setSize("100%", "auto");
}
} else if (location.pathname == "/open_contest.php") {

Check warning on line 4043 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 +4059,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 4062 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 +4079,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 4082 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 +4114,7 @@
readOnly: true,
theme: (UtilityEnabled("DarkMode") ? "darcula" : "default")
}).setSize("100%", "auto");
} else if (location.pathname == "/ceinfo.php") {

Check warning on line 4117 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 +4132,7 @@
theme: (UtilityEnabled("DarkMode") ? "darcula" : "default")
}).setSize("100%", "auto");
});
} else if (location.pathname == "/problem_std.php") {

Check warning on line 4135 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 +4153,7 @@
}).setSize("100%", "auto");
}
});
} else if (location.pathname == "/mail.php") {

Check warning on line 4156 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 +4203,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 4206 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 4207 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 +4228,7 @@
});
AddUser.addEventListener("click", () => {
let UsernameData = Username.value;
if (UsernameData == "") {

Check warning on line 4231 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 +4278,7 @@
</thead>
<tbody></tbody>
</table>`;
GetUsernameHTML(ToUser, SearchParams.get("to_user"));

Check notice on line 4281 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 +4305,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 4308 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 4313 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 +4347,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 4350 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 +4373,12 @@
}
});
Content.addEventListener("keydown", (Event) => {
if (Event.keyCode == 13) {

Check warning on line 4376 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 4381 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 +4403,10 @@
RefreshMessage(false);
addEventListener("focus", RefreshMessage);
}
} else if (location.pathname.indexOf("/discuss3") != -1) {

Check warning on line 4406 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 4408 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 4409 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 +4466,7 @@
"Page": Number(Page),
"BoardID": Number(SearchParams.get("bid") || -1)
}, async (ResponseData) => {
if (ResponseData.Success == true) {

Check warning on line 4469 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 +4485,7 @@
}
let Posts = ResponseData.Data.Posts;
PostList.children[1].innerHTML = "";
if (Posts.length == 0) {

Check warning on line 4488 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 +4506,10 @@
TitleLink.innerHTML += Posts[i].Title;
let AuthorCell = document.createElement("td");
Row.appendChild(AuthorCell);
GetUsernameHTML(AuthorCell, Posts[i].UserID);

Check notice on line 4509 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 4512 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 +4549,7 @@
}
}
});
} else if (location.pathname == "/discuss3/newpost.php") {

Check warning on line 4552 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 +4587,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 4590 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 +4603,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 4606 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 +4657,7 @@
}, (ResponseData) => {
SubmitElement.disabled = false;
SubmitElement.children[0].style.display = "none";
if (ResponseData.Success == true) {

Check warning on line 4660 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 +4678,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 4681 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 4687 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 +4697,7 @@
}
}
});
} else if (location.pathname == "/discuss3/thread.php") {

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 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 +4764,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 4767 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 +4776,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 4779 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 +4826,7 @@
RequestAPI("GetPost", {
"PostID": Number(ThreadID), "Page": Number(Page)
}, async (ResponseData) => {
if (ResponseData.Success == true) {

Check warning on line 4829 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 +4843,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 4846 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.innerText = ResponseData.Data.Title + (ResponseData.Data.ProblemID == 0 ? "" : ` - 题目` + ResponseData.Data.ProblemID);
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 4850 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 4853 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 +4873,7 @@
AuthorSpanElement.innerText = "作者:";
let AuthorUsernameElement = document.createElement("span");
AuthorElement.appendChild(AuthorUsernameElement);
GetUsernameHTML(AuthorUsernameElement, Replies[i].UserID);

Check notice on line 4876 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 +4914,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 4917 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 4924 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 +4954,7 @@
ReplyID: Number(Replies[i].ReplyID),
Content: String(ContentEditor.value)
}, (ResponseData) => {
if (ResponseData.Success == true) {

Check warning on line 4957 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 +4982,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 4985 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 +4999,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 5002 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 +5014,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 5017 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 5021 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 5021 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 +5034,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 5037 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 +5063,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 5066 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 5072 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 5074 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 +5086,10 @@

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

Check notice on line 5089 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 5092 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 +5119,7 @@
Style.innerHTML += " width: 50%;";
Style.innerHTML += "}";

RenderMathJax();

Check notice on line 5122 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 +5139,7 @@
}, (ResponseData) => {
Delete.disabled = false;
Delete.children[0].style.display = "none";
if (ResponseData.Success == true) {

Check warning on line 5142 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 +5158,11 @@
}, async (ResponseData) => {
SubmitElement.disabled = false;
SubmitElement.children[0].style.display = "none";
if (ResponseData.Success == true) {

Check warning on line 5161 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 5165 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 +5192,6 @@
}
}

main().then(r => {

Check warning on line 5195 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.2.74",
"version": "1.2.75",
"description": "an improvement script for xmoj.tech",
"main": "AddonScript.js",
"scripts": {
Expand Down
Loading