Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync: dev to extern-contrib #726

Closed
wants to merge 17 commits into from
Closed
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
68 changes: 68 additions & 0 deletions Update.json
Original file line number Diff line number Diff line change
Expand Up @@ -2475,6 +2475,74 @@
}
],
"Notes": "No release notes were provided for this release."
},
"1.2.60": {
"UpdateDate": 1725005372794,
"Prerelease": false,
"UpdateContents": [
{
"PR": 690,
"Description": "移除之前忘记操作的admin"
},
{
"PR": 694,
"Description": "更新support url"
},
{
"PR": 698,
"Description": "Set turnstile theme and language"
},
{
"PR": 704,
"Description": "登录界面优化"
},
{
"PR": 712,
"Description": "更改个人中心一栏鼠标指针样式"
},
{
"PR": 715,
"Description": "更改短消息显示"
},
{
"PR": 718,
"Description": "Prevent caching"
}
],
"Notes": "No release notes were provided for this release."
},
"1.2.61": {
"UpdateDate": 1725083743111,
"Prerelease": true,
"UpdateContents": [
{
"PR": 725,
"Description": "Add CP Editor"
}
],
"Notes": "No release notes were provided for this release."
},
"1.2.62": {
"UpdateDate": 1726406228773,
"Prerelease": true,
"UpdateContents": [
{
"PR": 729,
"Description": "add chenyiming5"
}
],
"Notes": "No release notes were provided for this release."
},
"1.2.63": {
"UpdateDate": 1727743018230,
"Prerelease": true,
"UpdateContents": [
{
"PR": 731,
"Description": "a quick fix for mathjax"
}
],
"Notes": "No release notes were provided for this release."
}
}
}
10 changes: 8 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.59
// @version 1.2.63
// @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 @@ -386,7 +386,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 389 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 @@ -462,7 +462,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 465 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 @@ -610,7 +610,7 @@
//use https
location.href = location.href.replace('http://', 'https://');
}
if (location.host != "www.xmoj.tech") {

Check warning on line 613 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 @@ -622,7 +622,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 625 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 625 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

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

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

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

Check warning on line 666 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 667 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 669 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 671 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 673 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 675 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 @@ -733,10 +733,10 @@

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

Check warning on line 736 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 739 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 @@ -745,7 +745,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 748 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 @@ -756,7 +756,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 759 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 @@ -838,17 +838,17 @@
}

if (UtilityEnabled("ReplaceYN")) {
Temp = document.getElementsByClassName("status_y");

Check notice on line 841 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Implicitly declared global JavaScript variable

Variable Temp implicitly declared
for (let i = 0; i < Temp.length; i++) {
Temp[i].innerText = "✓";
}
Temp = document.getElementsByClassName("status_n");

Check notice on line 845 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Implicitly declared global JavaScript variable

Variable Temp implicitly declared
for (let i = 0; i < Temp.length; i++) {
Temp[i].innerText = "✗";
}
}

Temp = document.getElementsByClassName("page-item");

Check notice on line 851 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Implicitly declared global JavaScript variable

Variable Temp implicitly declared
for (let i = 0; i < Temp.length; i++) {
Temp[i].children[0].className = "page-link";
}
Expand All @@ -856,7 +856,7 @@
document.getElementsByClassName("pagination")[0].classList.add("justify-content-center");
}

Temp = document.getElementsByTagName("table");

Check notice on line 859 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Implicitly declared global JavaScript variable

Variable Temp implicitly declared
for (let i = 0; i < Temp.length; i++) {
if (Temp[i].querySelector("thead") != null) {
TidyTable(Temp[i]);
Expand All @@ -882,7 +882,7 @@
new NavbarStyler();
}
if (UtilityEnabled("ResetType")) {
if (document.querySelector("#profile") != undefined && document.querySelector("#profile").innerHTML == "登录") {

Check warning on line 885 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 885 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 @@ -894,7 +894,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 897 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 897 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 @@ -998,7 +998,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 1001 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 @@ -1030,7 +1030,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 1033 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 @@ -1087,7 +1087,7 @@
UpdateDataCardBody.appendChild(UpdateDataCardText);
UpdateDataCardText.className = "card-text";
//release notes
if (Data.Notes != undefined) {

Check warning on line 1090 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 @@ -1212,7 +1212,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 1215 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 @@ -1253,7 +1253,7 @@
dispatchEvent(new Event("focus"));


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

Check warning on line 1256 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 1256 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 @@ -1282,14 +1282,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 1285 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 1287 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 1289 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 1292 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 @@ -1298,7 +1298,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 1301 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 @@ -1318,7 +1318,7 @@
Label.innerText = Data[i].Name;
Row.appendChild(Label);
}
if (Data[i].Children != undefined) {

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\].Children != undefined may cause unexpected type coercion
Row.appendChild(CreateList(Data[i].Children));
}
List.appendChild(Row);
Expand Down Expand Up @@ -1428,7 +1428,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 1431 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 @@ -1464,7 +1464,7 @@
}
});
}
} else if (location.pathname == "/problemset.php") {

Check warning on line 1467 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 @@ -1502,7 +1502,8 @@
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 1505 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
RenderMathJax();

Check notice on line 1506 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 (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 @@ -1550,13 +1551,13 @@
window.location.href = SubmitLink.href;
console.log(SubmitLink.href);
};
Temp = document.querySelectorAll(".sampledata");

Check notice on line 1554 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Implicitly declared global JavaScript variable

Variable Temp implicitly declared
for (var i = 0; i < Temp.length; i++) {

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

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

Check warning on line 1699 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 @@ -1826,7 +1827,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 = SizeToStringSize(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 1830 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 @@ -1852,7 +1853,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 1856 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 @@ -1866,7 +1867,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 1870 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 @@ -1885,10 +1886,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 1889 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 1892 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 @@ -1899,12 +1900,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 1903 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 1906 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 1908 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 @@ -1923,12 +1924,12 @@
};
}
}
} else if (location.pathname == "/contest.php") {

Check warning on line 1927 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 1929 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 1932 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 @@ -1953,20 +1954,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 1957 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 1960 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 1961 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 1962 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 1966 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 1970 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 @@ -1998,7 +1999,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 2002 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 @@ -2012,10 +2013,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 2016 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 2019 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 @@ -2038,14 +2039,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 2042 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 2045 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 2049 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 @@ -2058,13 +2059,13 @@
}
}

Temp = document.querySelector("#problemset > tbody").rows;

Check notice on line 2062 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Implicitly declared global JavaScript variable

Variable Temp implicitly declared
for (let i = 0; i < Temp.length; i++) {
if (Temp[i].childNodes[0].children.length == 0) {

Check warning on line 2064 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison 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 2068 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 @@ -2098,14 +2099,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 2102 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 2109 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 @@ -2184,12 +2185,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 2188 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 2193 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 @@ -2214,7 +2215,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 2218 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 @@ -2223,14 +2224,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 2227 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 2227 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 2227 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 2228 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 2228 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 2228 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 2229 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 2232 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 2234 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 @@ -2238,13 +2239,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 2242 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 2243 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 2247 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 2248 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 @@ -2255,14 +2256,14 @@
document.querySelector("#rank > tbody").innerHTML = ParsedDocument.querySelector("#rank > tbody").innerHTML;
});
};
RefreshOIRank();

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

Check warning on line 2286 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 @@ -2290,7 +2291,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 2294 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 @@ -2306,7 +2307,7 @@
RankData.push(CurrentRow);
}
let CurrentProblem = CurrentRow.Problem.find((CurrentRow) => {
if (CurrentRow.Index == CurrentSubmission.num) {

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

Check warning on line 2320 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

Check warning on line 2320 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
CurrentProblem.SolveTime = parseInt(CurrentSubmission.in_date);
CurrentRow.Solved++;
CurrentRow.Penalty += parseInt(CurrentSubmission.in_date) + CurrentProblem.Attempts.length * 20 * 60;
Expand All @@ -2329,7 +2330,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 2333 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

Check warning on line 2333 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 2333 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
RankData[i].QuickSubmitCount++;
}
}
Expand All @@ -2337,9 +2338,9 @@
}

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

Check warning on line 2341 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 2343 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 @@ -2421,8 +2422,8 @@

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

Check notice on line 2425 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 2426 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 All @@ -2435,12 +2436,12 @@
NicknameCell.innerText = (RowData.Nickname.length < 16 ? RowData.Nickname : RowData.Nickname.substring(0, 15) + "...");

let Names = {
"huangkai": "黄开",
"chenlangning": "陈朗宁",
"chensiru": "陈斯如",
"chensiqi": "陈思齐",
"chentianle": "陈天乐",
"chenxuanhe": "陈宣合",
"chenyiming5": "陈一铭",
"chenzecong": "陈泽聪",
"chenzerui": "陈泽睿",
"danwenxiao": "单文骁",
Expand All @@ -2456,6 +2457,7 @@
"heshuhan": "贺书瀚",
"hexinyi": "何昕弈",
"huheng": "胡恒",
"huangkai": "黄开",
"huangmingxuan": "黄铭宣",
"huangruina": "黄睿纳",
"huangwei": "黄唯",
Expand All @@ -2464,7 +2466,7 @@
"jingtaiyu": "荆泰宇",
"jinweizhe": "金炜喆",
"leijiahan": "雷家涵",
"leiwenda": "雷文达",

Check warning on line 2469 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Duplicate declaration

Duplicate declaration
"lidonglin": "李东霖",
"lihanzhang": "李含章",
"lijiayi": "李佳毅",
Expand Down Expand Up @@ -2504,7 +2506,7 @@
"sunyihan": "孙艺涵",
"sunyimiao": "孙义淼",
"tangchao": "唐潮",
"tangyuhan": "唐钰涵",

Check warning on line 2509 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Duplicate declaration

Duplicate declaration
"tanhaoxuan": "谭皓轩",
"taoxianyu": "陶羡榆",
"wangkangming": "王康明",
Expand All @@ -2526,8 +2528,8 @@
"xiaruicheng": "夏瑞成",
"xiaweimin": "夏蔚民",
"xiaxuran": "夏诩然",
"xiebingxiu": "谢秉修",

Check warning on line 2531 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Duplicate declaration

Duplicate declaration
"xiebingxiu": "谢秉修",

Check warning on line 2532 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Duplicate declaration

Duplicate declaration
"xieliren": "谢立仁",
"xinyihan": "辛轶涵",
"xuconghan": "徐从瀚",
Expand Down Expand Up @@ -2558,7 +2560,7 @@
"zhuruichen": "朱睿宸",
"zhuxule": "朱徐乐",
"zhuyikun": "朱奕坤",
"leiwenda": "雷文达",

Check warning on line 2563 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Duplicate declaration

Duplicate declaration
"wangyuancheng": "王源成",
"zhuyiyang": "朱奕阳",
"hanjialin": "韩佳霖",
Expand All @@ -2570,7 +2572,7 @@
"xuyan": "徐衍",
"fenghaochen": "冯皓宸",
"lutianlang": "陆天朗",
"tangyuhan": "唐钰涵",

Check warning on line 2575 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Duplicate declaration

Duplicate declaration
"jiangbowen": "姜博闻",
"shangguanbocheng": "上官伯呈",
"wangchengqi": "王呈齐",
Expand All @@ -2579,7 +2581,7 @@
"weijiefu": "韦杰夫",
"": ""
};
NameCell.innerText = (Names[RowData.Username] == undefined ? "" : Names[RowData.Username]);

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

Check warning on line 2594 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 2598 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 2600 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 @@ -2626,7 +2628,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 2631 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 @@ -2639,11 +2641,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 2644 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 2648 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 @@ -2671,7 +2673,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 2676 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 @@ -2680,14 +2682,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 2685 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 2685 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 2685 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
let FirstBlood = (Red == 170 && Green == 170 && Blue == 255);

Check warning on line 2686 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 2686 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 2686 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

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

Check warning on line 2687 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 2690 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 2692 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 @@ -2695,12 +2697,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 2700 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 2705 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 @@ -2711,13 +2713,13 @@
document.querySelector("#rank > tbody").innerHTML = ParsedDocument.querySelector("#rank > tbody").innerHTML;
});
};
RefreshCorrectRank();

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

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

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

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

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

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

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

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

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

Check warning on line 3184 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 @@ -3211,7 +3213,7 @@
});
}
}
} else if (location.pathname == "/userinfo.php") {

Check warning on line 3216 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 @@ -3224,10 +3226,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 3229 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 3230 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 3232 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 @@ -3237,7 +3239,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 3242 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 3242 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 @@ -3260,7 +3262,7 @@
AvatarContainer.classList.add("col-auto");
let AvatarElement = document.createElement("img");
let UserEmailHash = (await GetUserInfo(UserID)).EmailHash;
if (UserEmailHash == undefined) {

Check warning on line 3265 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 @@ -3392,7 +3394,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 3397 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 @@ -3433,7 +3435,7 @@
});
});
}
} else if (location.pathname == "/conteststatistics.php") {

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

Check warning on line 3465 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 3471 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 3473 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 @@ -3534,7 +3536,7 @@
});
}
}
} else if (location.pathname == "/loginpage.php") {

Check warning on line 3539 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 @@ -3571,7 +3573,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 3576 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 3576 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 @@ -3584,7 +3586,7 @@
})
.then((Response) => {
if (UtilityEnabled("LoginFailed")) {
if (Response.indexOf("history.go(-2);") != -1) {

Check warning on line 3589 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 @@ -3601,7 +3603,7 @@
}
Response = Response.substring(Response.indexOf("alert('") + 7);
Response = Response.substring(0, Response.indexOf("');"));
if (Response == "UserName or Password Wrong!") {

Check warning on line 3606 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 @@ -3618,9 +3620,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 3623 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

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

Check warning on line 3623 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

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

Check warning on line 3625 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 @@ -3636,9 +3638,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 3641 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 3643 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 @@ -3673,9 +3675,9 @@
document.querySelector("body > div > div.mt-3 > center").appendChild(DownloadButton);
});
}
} else if (location.pathname == "/reinfo.php") {

Check warning on line 3678 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 3680 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 @@ -3777,7 +3779,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 3782 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 @@ -3804,7 +3806,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 3809 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 @@ -3828,7 +3830,7 @@
});
}
}
} else if (location.pathname == "/downloads.php") {

Check warning on line 3833 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 @@ -3858,6 +3860,10 @@
"Name": "RedPanda C++",
"Image": "https://a.fsdn.com/allura/p/redpanda-cpp/icon",
"URL": "https://sourceforge.net/projects/redpanda-cpp/"
}, {
"Name": "CP Editor",
"Image": "https://a.fsdn.com/allura/mirror/cp-editor/icon?c35437565079e4135a985ba557ef2fdbe97de6bafb27aceafd76bc54490c26e3?&w=90",
"URL": "https://cpeditor.org/zh/download/"
}, {
"Name": "CLion",
"Image": "https://resources.jetbrains.com/storage/products/company/brand/logos/CLion_icon.png",
Expand Down Expand Up @@ -3899,7 +3905,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 3908 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 @@ -3924,7 +3930,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 3933 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 @@ -3940,12 +3946,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 3949 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 3954 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 @@ -3983,7 +3989,7 @@
theme: (UtilityEnabled("DarkMode") ? "darcula" : "default")
}).setSize("100%", "auto");
}
} else if (location.pathname == "/open_contest.php") {

Check warning on line 3992 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 @@ -4002,7 +4008,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 4011 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 @@ -4022,7 +4028,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 4031 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 @@ -4057,7 +4063,7 @@
readOnly: true,
theme: (UtilityEnabled("DarkMode") ? "darcula" : "default")
}).setSize("100%", "auto");
} else if (location.pathname == "/ceinfo.php") {

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

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

Check warning on line 4105 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 @@ -4146,8 +4152,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 4155 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 4156 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 @@ -4171,7 +4177,7 @@
});
AddUser.addEventListener("click", () => {
let UsernameData = Username.value;
if (UsernameData == "") {

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

Check notice on line 4230 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 @@ -4248,12 +4254,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 4257 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 4262 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 @@ -4290,7 +4296,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 4299 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 @@ -4316,12 +4322,12 @@
}
});
Content.addEventListener("keydown", (Event) => {
if (Event.keyCode == 13) {

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

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

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

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

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

Check warning on line 4501 in XMOJ.user.js

View workflow job for this annotation

GitHub Actions / Qodana for JS

Equality operator may cause type coercion

Comparison 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 @@ -4530,7 +4536,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 4539 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 @@ -4546,7 +4552,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 4555 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 @@ -4600,7 +4606,7 @@
}, (ResponseData) => {
SubmitElement.disabled = false;
SubmitElement.children[0].style.display = "none";
if (ResponseData.Success == true) {

Check warning on line 4609 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 @@ -4621,13 +4627,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 4630 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 4636 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 @@ -4640,7 +4646,7 @@
}
}
});
} else if (location.pathname == "/discuss3/thread.php") {

Check warning on line 4649 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 @@ -4707,7 +4713,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 4716 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 @@ -4719,7 +4725,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 4728 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 @@ -4769,7 +4775,7 @@
RequestAPI("GetPost", {
"PostID": Number(ThreadID), "Page": Number(Page)
}, async (ResponseData) => {
if (ResponseData.Success == true) {

Check warning on line 4778 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 @@ -4786,14 +4792,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 4795 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);

Check warning on line 4799 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 4802 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 @@ -4816,7 +4822,7 @@
AuthorSpanElement.innerText = "作者:";
let AuthorUsernameElement = document.createElement("span");
AuthorElement.appendChild(AuthorUsernameElement);
GetUsernameHTML(AuthorUsernameElement, Replies[i].UserID);

Check notice on line 4825 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 @@ -4857,14 +4863,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 4866 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 4873 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 @@ -4897,7 +4903,7 @@
ReplyID: Number(Replies[i].ReplyID),
Content: String(ContentEditor.value)
}, (ResponseData) => {
if (ResponseData.Success == true) {

Check warning on line 4906 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 @@ -4925,7 +4931,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 4934 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 @@ -4942,7 +4948,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 4951 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 @@ -4957,11 +4963,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 4966 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 4970 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 4970 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 @@ -4977,7 +4983,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 4986 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 @@ -5006,15 +5012,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 5015 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 5021 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 5023 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 @@ -5029,10 +5035,10 @@

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

Check notice on line 5038 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 5041 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 @@ -5062,7 +5068,7 @@
Style.innerHTML += " width: 50%;";
Style.innerHTML += "}";

RenderMathJax();

Check notice on line 5071 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

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

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

Check warning on line 5110 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 5114 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 @@ -5135,6 +5141,6 @@
}
}

main().then(r => {

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