From f95463a63ee6f4fd1d8647588a093963cf0888a4 Mon Sep 17 00:00:00 2001 From: boomzero Date: Mon, 11 Aug 2025 19:24:42 +0800 Subject: [PATCH 01/13] Update diff-match-patch library source URL --- XMOJ.user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/XMOJ.user.js b/XMOJ.user.js index 4f044118..40df88f8 100644 --- a/XMOJ.user.js +++ b/XMOJ.user.js @@ -10,7 +10,7 @@ // @require https://cdnjs.cloudflare.com/ajax/libs/codemirror/6.65.7/codemirror.min.js // @require https://cdnjs.cloudflare.com/ajax/libs/codemirror/6.65.7/mode/clike/clike.min.js // @require https://cdnjs.cloudflare.com/ajax/libs/codemirror/6.65.7/addon/merge/merge.min.js -// @require https://cdn.jsdelivr.net/gh/google/diff-match-patch@master/javascript/diff_match_patch_uncompressed.js +// @require https://gitee.com/mirrors_google/diff-match-patch/raw/master/javascript/diff_match_patch_uncompressed.js // @require https://cdnjs.cloudflare.com/ajax/libs/dompurify/3.0.2/purify.min.js // @require https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/2.0.5/FileSaver.min.js // @require https://cdnjs.cloudflare.com/ajax/libs/marked/4.3.0/marked.min.js From 9573baba3181d01a17f6e684863a3b4c41dc8279 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 11 Aug 2025 11:25:41 +0000 Subject: [PATCH 02/13] 2.1.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d753282c..9e30be84 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xmoj-script", - "version": "2.1.0", + "version": "2.1.1", "description": "an improvement script for xmoj.tech", "main": "AddonScript.js", "scripts": { From 0176b584f01a17384729630439ca86f440e805a8 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 11 Aug 2025 11:25:42 +0000 Subject: [PATCH 03/13] Update version info to 2.1.1 --- Update.json | 11 +++++++++++ XMOJ.user.js | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Update.json b/Update.json index 09973f9b..c999738d 100644 --- a/Update.json +++ b/Update.json @@ -2969,6 +2969,17 @@ } ], "Notes": "No release notes were provided for this release." + }, + "2.1.1": { + "UpdateDate": 1754911541732, + "Prerelease": true, + "UpdateContents": [ + { + "PR": 829, + "Description": "Update diff-match-patch library source URL" + } + ], + "Notes": "No release notes were provided for this release." } } } \ No newline at end of file diff --git a/XMOJ.user.js b/XMOJ.user.js index 2e94b153..7b47f15e 100644 --- a/XMOJ.user.js +++ b/XMOJ.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name XMOJ -// @version 2.1.0 +// @version 2.1.1 // @description XMOJ增强脚本 // @author @XMOJ-Script-dev, @langningchen and the community // @namespace https://github/langningchen From a0cdcf7fba1a63299578031a1018c057459ba8a5 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 11 Aug 2025 11:25:55 +0000 Subject: [PATCH 04/13] Update time and description of 2.1.1 --- Update.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Update.json b/Update.json index c999738d..5a0f68a6 100644 --- a/Update.json +++ b/Update.json @@ -2971,7 +2971,7 @@ "Notes": "No release notes were provided for this release." }, "2.1.1": { - "UpdateDate": 1754911541732, + "UpdateDate": 1754911555185, "Prerelease": true, "UpdateContents": [ { From 8db0106c941a34f8669855cf8b400c8d9a552a98 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Aug 2025 01:45:12 +0000 Subject: [PATCH 05/13] Bump JetBrains/qodana-action from 2024.3 to 2025.2 Bumps [JetBrains/qodana-action](https://github.com/jetbrains/qodana-action) from 2024.3 to 2025.2. - [Release notes](https://github.com/jetbrains/qodana-action/releases) - [Commits](https://github.com/jetbrains/qodana-action/compare/v2024.3...v2025.2) --- updated-dependencies: - dependency-name: JetBrains/qodana-action dependency-version: '2025.2' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e16f678d..1dff64fd 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -20,6 +20,6 @@ jobs: ref: ${{ github.event.pull_request.head.sha }} # to check out the actual pull request commit, not the merge commit fetch-depth: 0 # a full history is required for pull request analysis - name: 'Qodana Scan' - uses: JetBrains/qodana-action@v2024.3 + uses: JetBrains/qodana-action@v2025.2 env: QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }} From 8bcdcc115051a2483727c454a6720679ffdf2e2e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Aug 2025 01:45:19 +0000 Subject: [PATCH 06/13] Bump actions/checkout from 2 to 5 Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 5. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v2...v5) --- updated-dependencies: - dependency-name: actions/checkout dependency-version: '5' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/AutoLabelIssue.yml | 2 +- .github/workflows/CodeQL.yml | 2 +- .github/workflows/DependencyScan.yml | 2 +- .github/workflows/Prerelease.yml | 2 +- .github/workflows/Release.yml | 2 +- .github/workflows/UpdateToRelease.yml | 2 +- .github/workflows/UpdateVersion.yml | 2 +- .github/workflows/main.yml | 2 +- .github/workflows/sync-to-extern-contrib.yml | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/AutoLabelIssue.yml b/.github/workflows/AutoLabelIssue.yml index 5258387f..7a11f586 100644 --- a/.github/workflows/AutoLabelIssue.yml +++ b/.github/workflows/AutoLabelIssue.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: fetch-depth: 0 - name: Generate a token diff --git a/.github/workflows/CodeQL.yml b/.github/workflows/CodeQL.yml index d0fd37cb..425a2cfc 100644 --- a/.github/workflows/CodeQL.yml +++ b/.github/workflows/CodeQL.yml @@ -19,7 +19,7 @@ jobs: strategy: fail-fast: false steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - uses: github/codeql-action/init@v3 with: languages: "javascript" diff --git a/.github/workflows/DependencyScan.yml b/.github/workflows/DependencyScan.yml index d5cb28dd..73b3298d 100644 --- a/.github/workflows/DependencyScan.yml +++ b/.github/workflows/DependencyScan.yml @@ -9,5 +9,5 @@ jobs: dependency-review: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - uses: actions/dependency-review-action@v4 diff --git a/.github/workflows/Prerelease.yml b/.github/workflows/Prerelease.yml index 799f4f7d..fc97e2da 100644 --- a/.github/workflows/Prerelease.yml +++ b/.github/workflows/Prerelease.yml @@ -21,7 +21,7 @@ jobs: with: node-version: 16 registry-url: https://registry.npmjs.org/ - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: fetch-depth: 0 - name: Publish to npm diff --git a/.github/workflows/Release.yml b/.github/workflows/Release.yml index b2daa4bc..548b0e02 100644 --- a/.github/workflows/Release.yml +++ b/.github/workflows/Release.yml @@ -20,7 +20,7 @@ jobs: with: node-version: 16 registry-url: https://registry.npmjs.org/ - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: fetch-depth: 0 - name: Get version diff --git a/.github/workflows/UpdateToRelease.yml b/.github/workflows/UpdateToRelease.yml index 5a26a01e..ba950e34 100644 --- a/.github/workflows/UpdateToRelease.yml +++ b/.github/workflows/UpdateToRelease.yml @@ -14,7 +14,7 @@ jobs: pull-requests: write contents: write steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: fetch-depth: 0 - name: Update to release diff --git a/.github/workflows/UpdateVersion.yml b/.github/workflows/UpdateVersion.yml index c13c0017..8ab253d5 100644 --- a/.github/workflows/UpdateVersion.yml +++ b/.github/workflows/UpdateVersion.yml @@ -21,6 +21,6 @@ jobs: with: app-id: ${{ secrets.APP_ID }} private-key: ${{ secrets.APP_PRIVATE_KEY }} - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Update version run: node ./Update/UpdateVersion.js ${{ steps.generate_token.outputs.token }} ${{ github.event.number }} "${{ github.event.pull_request.title }}" diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e16f678d..d8e593f5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,7 +15,7 @@ jobs: pull-requests: write checks: write steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v5 with: ref: ${{ github.event.pull_request.head.sha }} # to check out the actual pull request commit, not the merge commit fetch-depth: 0 # a full history is required for pull request analysis diff --git a/.github/workflows/sync-to-extern-contrib.yml b/.github/workflows/sync-to-extern-contrib.yml index ff125466..d9a0da5b 100644 --- a/.github/workflows/sync-to-extern-contrib.yml +++ b/.github/workflows/sync-to-extern-contrib.yml @@ -10,7 +10,7 @@ jobs: name: Syncing branches steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v5 - name: Set up Node uses: actions/setup-node@v4 with: From a7106e7b178440faeda842833b824270181f10fd Mon Sep 17 00:00:00 2001 From: Zhu Chenrui Date: Tue, 19 Aug 2025 15:37:18 +0800 Subject: [PATCH 07/13] fix: avoid top-level await in credential helpers --- XMOJ.user.js | 55 ++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 43 insertions(+), 12 deletions(-) diff --git a/XMOJ.user.js b/XMOJ.user.js index 7b47f15e..f190186b 100644 --- a/XMOJ.user.js +++ b/XMOJ.user.js @@ -441,6 +441,35 @@ let UtilityEnabled = (Name) => { } } }; +let storeCredential = async (username, password) => { + if ('credentials' in navigator && window.PasswordCredential) { + try { + const credential = new PasswordCredential({ id: username, password: password }); + await navigator.credentials.store(credential); + } catch (e) { + console.error(e); + } + } +}; +let getCredential = async () => { + if ('credentials' in navigator && window.PasswordCredential) { + try { + return await navigator.credentials.get({ password: true, mediation: 'optional' }); + } catch (e) { + console.error(e); + } + } + return null; +}; +let clearCredential = async () => { + if ('credentials' in navigator && window.PasswordCredential) { + try { + await navigator.credentials.preventSilentAccess(); + } catch (e) { + console.error(e); + } + } +}; let RequestAPI = (Action, Data, CallBack) => { try { let Session = ""; @@ -962,8 +991,7 @@ async function main() { location.href = "https://www.xmoj.tech/modifypage.php?ByUserScript=1"; }); PopupUL.children[5].addEventListener("click", () => { - localStorage.removeItem("UserScript-Username"); - localStorage.removeItem("UserScript-Password"); + clearCredential(); document.cookie = "PHPSESSID=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/"; //This is how you remove a cookie? location.href = "https://www.xmoj.tech/logout.php"; }); @@ -3213,12 +3241,11 @@ async function main() { .then((Response) => { return Response.text(); }) - .then((Response) => { + .then(async (Response) => { if (UtilityEnabled("LoginFailed")) { if (Response.indexOf("history.go(-2);") != -1) { if (UtilityEnabled("SavePassword")) { - localStorage.setItem("UserScript-Username", Username); - localStorage.setItem("UserScript-Password", Password); + await storeCredential(Username, Password); } let NewPage = localStorage.getItem("UserScript-LastPage"); if (NewPage == null) { @@ -3227,8 +3254,7 @@ async function main() { location.href = NewPage; } else { if (UtilityEnabled("SavePassword")) { - localStorage.removeItem("UserScript-Username"); - localStorage.removeItem("UserScript-Password"); + clearCredential(); } Response = Response.substring(Response.indexOf("alert('") + 7); Response = Response.substring(0, Response.indexOf("');")); @@ -3244,10 +3270,15 @@ async function main() { }); } }); - if (UtilityEnabled("SavePassword") && localStorage.getItem("UserScript-Username") != null && localStorage.getItem("UserScript-Password") != null) { - document.querySelector("#login > div:nth-child(1) > div > input").value = localStorage.getItem("UserScript-Username"); - document.querySelector("#login > div:nth-child(2) > div > input").value = localStorage.getItem("UserScript-Password"); - LoginButton.click(); + if (UtilityEnabled("SavePassword")) { + (async () => { + let Credential = await getCredential(); + if (Credential) { + document.querySelector("#login > div:nth-child(1) > div > input").value = Credential.id; + document.querySelector("#login > div:nth-child(2) > div > input").value = Credential.password; + LoginButton.click(); + } + })(); } } else if (location.pathname == "/contest_video.php" || location.pathname == "/problem_video.php") { let ScriptData = document.querySelector("body > div > div.mt-3 > center > script").innerHTML; @@ -3814,7 +3845,7 @@ int main() AddUser.disabled = true; RequestAPI("SendMail", { "ToUser": String(UsernameData), - "Content": String("您好,我是" + localStorage.getItem("UserScript-Username")) + "Content": String("您好,我是" + CurrentUsername) }, (ResponseData) => { AddUser.children[0].style.display = "none"; AddUser.disabled = false; From 33a44f8d39dc10607ad8f896b5128f56890eec2e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 19 Aug 2025 07:37:42 +0000 Subject: [PATCH 08/13] 2.1.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9e30be84..98b80f3f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xmoj-script", - "version": "2.1.1", + "version": "2.1.2", "description": "an improvement script for xmoj.tech", "main": "AddonScript.js", "scripts": { From 76260d17aa49e4b03dd926a0143d82556e9613da Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 19 Aug 2025 07:37:48 +0000 Subject: [PATCH 09/13] Update version info to 2.1.2 --- Update.json | 11 +++++++++++ XMOJ.user.js | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Update.json b/Update.json index 5a0f68a6..b484fad7 100644 --- a/Update.json +++ b/Update.json @@ -2980,6 +2980,17 @@ } ], "Notes": "No release notes were provided for this release." + }, + "2.1.2": { + "UpdateDate": 1755589063111, + "Prerelease": true, + "UpdateContents": [ + { + "PR": 834, + "Description": "feat: use credential management api" + } + ], + "Notes": "No release notes were provided for this release." } } } \ No newline at end of file diff --git a/XMOJ.user.js b/XMOJ.user.js index f190186b..f373f997 100644 --- a/XMOJ.user.js +++ b/XMOJ.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name XMOJ -// @version 2.1.1 +// @version 2.1.2 // @description XMOJ增强脚本 // @author @XMOJ-Script-dev, @langningchen and the community // @namespace https://github/langningchen From 764be5c286d824fb5138eacf64ef205ebf201514 Mon Sep 17 00:00:00 2001 From: Zhu Chenrui Date: Tue, 19 Aug 2025 17:40:26 +0800 Subject: [PATCH 10/13] feat: configure theme from settings --- XMOJ.user.js | 47 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/XMOJ.user.js b/XMOJ.user.js index f373f997..9a75066f 100644 --- a/XMOJ.user.js +++ b/XMOJ.user.js @@ -552,6 +552,24 @@ let CurrentUsername = document.querySelector("#profile").innerText; CurrentUsername = CurrentUsername.replaceAll(/[^a-zA-Z0-9]/g, ""); let IsAdmin = AdminUserList.indexOf(CurrentUsername) !== -1; +const prefersDark = window.matchMedia("(prefers-color-scheme: dark)"); +const applyTheme = (theme) => { + document.querySelector("html").setAttribute("data-bs-theme", theme); + localStorage.setItem("UserScript-Setting-DarkMode", theme === "dark" ? "true" : "false"); +}; +const applySystemTheme = (e) => applyTheme(e.matches ? "dark" : "light"); +let initTheme = () => { + const saved = localStorage.getItem("UserScript-Setting-Theme") || "auto"; + if (saved === "auto") { + applyTheme(prefersDark.matches ? "dark" : "light"); + prefersDark.addEventListener("change", applySystemTheme); + } else { + applyTheme(saved); + prefersDark.removeEventListener("change", applySystemTheme); + } +}; +initTheme(); + class NavbarStyler { constructor() { @@ -1359,7 +1377,32 @@ async function main() { } else if (Data[i].Type == "D") { Row.classList.add("list-group-item-danger"); } - if (Data[i].Children == undefined) { + if (Data[i].ID == "Theme") { + let Label = document.createElement("label"); + Label.classList.add("me-2"); + Label.htmlFor = "UserScript-Setting-Theme"; + Label.innerText = Data[i].Name; + Row.appendChild(Label); + let Select = document.createElement("select"); + Select.classList.add("form-select", "form-select-sm", "w-auto", "d-inline"); + Select.id = "UserScript-Setting-Theme"; + [ + ["light", "亮色"], + ["dark", "暗色"], + ["auto", "跟随系统"] + ].forEach(opt => { + let option = document.createElement("option"); + option.value = opt[0]; + option.innerText = opt[1]; + Select.appendChild(option); + }); + Select.value = localStorage.getItem("UserScript-Setting-Theme") || "auto"; + Select.addEventListener("change", () => { + localStorage.setItem("UserScript-Setting-Theme", Select.value); + initTheme(); + }); + Row.appendChild(Select); + } else if (Data[i].Children == undefined) { let CheckBox = document.createElement("input"); CheckBox.classList.add("form-check-input"); CheckBox.classList.add("me-1"); @@ -1417,7 +1460,7 @@ async function main() { }, {"ID": "ResetType", "Type": "F", "Name": "重新排版*"}, { "ID": "AddColorText", "Type": "A", "Name": "增加彩色文字" }, {"ID": "AddUnits", "Type": "A", "Name": "状态界面内存与耗时添加单位"}, { - "ID": "DarkMode", "Type": "A", "Name": "使用暗色模式" + "ID": "Theme", "Type": "A", "Name": "界面主题" }, {"ID": "AddAnimation", "Type": "A", "Name": "增加动画"}, { "ID": "ReplaceYN", "Type": "F", "Name": "题目前状态提示替换为好看的图标" }, {"ID": "RemoveAlerts", "Type": "D", "Name": "去除多余反复的提示"}, { From b8fb960235dfc3efd6f080bfa1f3e268783326bd Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 19 Aug 2025 09:40:46 +0000 Subject: [PATCH 11/13] 2.1.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 98b80f3f..9ab577ca 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xmoj-script", - "version": "2.1.2", + "version": "2.1.3", "description": "an improvement script for xmoj.tech", "main": "AddonScript.js", "scripts": { From 1bb406569cb39f296f0a5a06629541900960ef56 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 19 Aug 2025 09:40:51 +0000 Subject: [PATCH 12/13] Update version info to 2.1.3 --- Update.json | 11 +++++++++++ XMOJ.user.js | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Update.json b/Update.json index b484fad7..2d072724 100644 --- a/Update.json +++ b/Update.json @@ -2991,6 +2991,17 @@ } ], "Notes": "No release notes were provided for this release." + }, + "2.1.3": { + "UpdateDate": 1755596446424, + "Prerelease": true, + "UpdateContents": [ + { + "PR": 835, + "Description": "feat: add user-selectable theme" + } + ], + "Notes": "No release notes were provided for this release." } } } \ No newline at end of file diff --git a/XMOJ.user.js b/XMOJ.user.js index 9a75066f..7ed7ad1c 100644 --- a/XMOJ.user.js +++ b/XMOJ.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name XMOJ -// @version 2.1.2 +// @version 2.1.3 // @description XMOJ增强脚本 // @author @XMOJ-Script-dev, @langningchen and the community // @namespace https://github/langningchen From 8539b7f43a2398d84c7ec8c4212806826e75f472 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 19 Aug 2025 09:41:15 +0000 Subject: [PATCH 13/13] Update time and description of 2.1.3 --- Update.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Update.json b/Update.json index 2d072724..9e0319ba 100644 --- a/Update.json +++ b/Update.json @@ -2993,7 +2993,7 @@ "Notes": "No release notes were provided for this release." }, "2.1.3": { - "UpdateDate": 1755596446424, + "UpdateDate": 1755596470421, "Prerelease": true, "UpdateContents": [ {