From 778dd98a8ac279f5a906fd2c664bbfde3540b6a7 Mon Sep 17 00:00:00 2001 From: boomzero Date: Sun, 22 Feb 2026 14:07:40 +0800 Subject: [PATCH 1/3] Fix contest ranking table styling for dark mode Clear inline background/color styles from XMOJ server on header and data rows so Bootstrap dark theme applies correctly. Force black background with white text on all header cells including problem letter links. Also fix rgb -> rgba for solved cell background alpha channel, and add missing text color styling for contestrank-correct.php cells. Co-Authored-By: Claude Opus 4.6 --- XMOJ.user.js | 53 +++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 42 insertions(+), 11 deletions(-) diff --git a/XMOJ.user.js b/XMOJ.user.js index 74e4ef53..55581363 100644 --- a/XMOJ.user.js +++ b/XMOJ.user.js @@ -2994,11 +2994,21 @@ async function main() { 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排名)"; - document.querySelector("#rank > thead > tr > :nth-child(1)").innerText = "排名"; - document.querySelector("#rank > thead > tr > :nth-child(2)").innerText = "用户"; - document.querySelector("#rank > thead > tr > :nth-child(3)").innerText = "昵称"; - document.querySelector("#rank > thead > tr > :nth-child(4)").innerText = "AC数"; - document.querySelector("#rank > thead > tr > :nth-child(5)").innerText = "得分"; + let HeaderCells = document.querySelectorAll("#rank > thead > tr > *"); + HeaderCells[0].innerText = "排名"; + HeaderCells[1].innerText = "用户"; + HeaderCells[2].innerText = "昵称"; + HeaderCells[3].innerText = "AC数"; + HeaderCells[4].innerText = "得分"; + for (let j = 0; j < HeaderCells.length; j++) { + HeaderCells[j].removeAttribute("bgcolor"); + HeaderCells[j].style.setProperty("background-color", "black", "important"); + HeaderCells[j].style.setProperty("color", "white", "important"); + let Links = HeaderCells[j].querySelectorAll("a"); + for (let k = 0; k < Links.length; k++) { + Links[k].style.setProperty("color", "white", "important"); + } + } let RefreshOIRank = async () => { await fetch(location.href) .then((Response) => { @@ -3009,6 +3019,7 @@ async function main() { TidyTable(ParsedDocument.getElementById("rank")); let Temp = ParsedDocument.getElementById("rank").rows; for (var i = 1; i < Temp.length; i++) { + Temp[i].style.backgroundColor = ""; let MetalCell = Temp[i].cells[0]; let Metal = document.createElement("span"); Metal.innerText = MetalCell.innerText; @@ -3018,6 +3029,10 @@ async function main() { GetUsernameHTML(Temp[i].cells[1], Temp[i].cells[1].innerText); Temp[i].cells[2].innerHTML = Temp[i].cells[2].innerText; Temp[i].cells[3].innerHTML = Temp[i].cells[3].innerText; + for (let j = 0; j < 5 && j < Temp[i].cells.length; j++) { + Temp[i].cells[j].style.backgroundColor = ""; + Temp[i].cells[j].style.color = ""; + } for (let j = 5; j < Temp[i].cells.length; j++) { let InnerText = Temp[i].cells[j].innerText; let BackgroundColor = Temp[i].cells[j].style.backgroundColor; @@ -3038,7 +3053,7 @@ async function main() { } else if (FirstBlood) { BackgroundColor = "rgb(127, 127, 255)"; } else if (Solved) { - BackgroundColor = "rgb(0, 255, 0, " + Math.max(1 / 10 * (10 - ErrorCount), 0.2) + ")"; + BackgroundColor = "rgba(0, 255, 0, " + Math.max(1 / 10 * (10 - ErrorCount), 0.2) + ")"; if (ErrorCount != 0) { InnerText += " (" + (ErrorCount == 5 ? "4+" : ErrorCount) + ")"; } @@ -3080,11 +3095,21 @@ async function main() { 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) + "(订正排名)"; document.querySelector("body > div > div.mt-3 > center > a").remove(); } - document.querySelector("#rank > thead > tr > :nth-child(1)").innerText = "排名"; - document.querySelector("#rank > thead > tr > :nth-child(2)").innerText = "用户"; - document.querySelector("#rank > thead > tr > :nth-child(3)").innerText = "昵称"; - document.querySelector("#rank > thead > tr > :nth-child(4)").innerText = "AC数"; - document.querySelector("#rank > thead > tr > :nth-child(5)").innerText = "得分"; + let HeaderCells = document.querySelectorAll("#rank > thead > tr > *"); + HeaderCells[0].innerText = "排名"; + HeaderCells[1].innerText = "用户"; + HeaderCells[2].innerText = "昵称"; + HeaderCells[3].innerText = "AC数"; + HeaderCells[4].innerText = "得分"; + for (let j = 0; j < HeaderCells.length; j++) { + HeaderCells[j].removeAttribute("bgcolor"); + HeaderCells[j].style.setProperty("background-color", "black", "important"); + HeaderCells[j].style.setProperty("color", "white", "important"); + let Links = HeaderCells[j].querySelectorAll("a"); + for (let k = 0; k < Links.length; k++) { + Links[k].style.setProperty("color", "white", "important"); + } + } let RefreshCorrectRank = async () => { await fetch(location.href) .then((Response) => { @@ -3095,6 +3120,7 @@ async function main() { TidyTable(ParsedDocument.getElementById("rank")); let Temp = ParsedDocument.getElementById("rank").rows; for (var i = 1; i < Temp.length; i++) { + Temp[i].style.backgroundColor = ""; let MetalCell = Temp[i].cells[0]; let Metal = document.createElement("span"); Metal.innerText = MetalCell.innerText; @@ -3104,6 +3130,10 @@ async function main() { GetUsernameHTML(Temp[i].cells[1], Temp[i].cells[1].innerText); Temp[i].cells[2].innerHTML = Temp[i].cells[2].innerText; Temp[i].cells[3].innerHTML = Temp[i].cells[3].innerText; + for (let j = 0; j < 5 && j < Temp[i].cells.length; j++) { + Temp[i].cells[j].style.backgroundColor = ""; + Temp[i].cells[j].style.color = ""; + } for (let j = 5; j < Temp[i].cells.length; j++) { let InnerText = Temp[i].cells[j].innerText; let BackgroundColor = Temp[i].cells[j].style.backgroundColor; @@ -3136,6 +3166,7 @@ async function main() { } Temp[i].cells[j].innerHTML = InnerText; Temp[i].cells[j].style.backgroundColor = BackgroundColor; + Temp[i].cells[j].style.color = (UtilityEnabled("DarkMode") ? "white" : "black"); } } document.querySelector("#rank > tbody").innerHTML = ParsedDocument.querySelector("#rank > tbody").innerHTML; From ce2b7844929573a6ee001bcbb7951a3633c4acb7 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 22 Feb 2026 06:09:46 +0000 Subject: [PATCH 2/3] 3.2.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9dd923ed..33bff641 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xmoj-script", - "version": "3.2.0", + "version": "3.2.1", "description": "an improvement script for xmoj.tech", "main": "AddonScript.js", "scripts": { From ba94e6f60af850b31bfbb6dc8c9b8d4d88067565 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 22 Feb 2026 06:09:52 +0000 Subject: [PATCH 3/3] Update version info to 3.2.1 --- Update.json | 11 +++++++++++ XMOJ.user.js | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Update.json b/Update.json index 467e4c56..a732b808 100644 --- a/Update.json +++ b/Update.json @@ -3385,6 +3385,17 @@ } ], "Notes": "No release notes were provided for this release." + }, + "3.2.1": { + "UpdateDate": 1771740586846, + "Prerelease": true, + "UpdateContents": [ + { + "PR": 916, + "Description": "Fix contest ranking table styling for dark mode" + } + ], + "Notes": "Fix contest ranking table colors in dark mode (contestrank-oi.php and contestrank-correct.php)" } } } \ No newline at end of file diff --git a/XMOJ.user.js b/XMOJ.user.js index 55581363..f442f8af 100644 --- a/XMOJ.user.js +++ b/XMOJ.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name XMOJ -// @version 3.2.0 +// @version 3.2.1 // @description XMOJ增强脚本 // @author @XMOJ-Script-dev, @langningchen and the community // @namespace https://github/langningchen