xmoj-script 2.1.2 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,7 +9,7 @@ jobs:
9
9
  runs-on: ubuntu-latest
10
10
  steps:
11
11
  - name: Checkout
12
- uses: actions/checkout@v4
12
+ uses: actions/checkout@v5
13
13
  with:
14
14
  fetch-depth: 0
15
15
  - name: Generate a token
@@ -19,7 +19,7 @@ jobs:
19
19
  strategy:
20
20
  fail-fast: false
21
21
  steps:
22
- - uses: actions/checkout@v4
22
+ - uses: actions/checkout@v5
23
23
  - uses: github/codeql-action/init@v3
24
24
  with:
25
25
  languages: "javascript"
@@ -9,5 +9,5 @@ jobs:
9
9
  dependency-review:
10
10
  runs-on: ubuntu-latest
11
11
  steps:
12
- - uses: actions/checkout@v4
12
+ - uses: actions/checkout@v5
13
13
  - uses: actions/dependency-review-action@v4
@@ -21,7 +21,7 @@ jobs:
21
21
  with:
22
22
  node-version: 16
23
23
  registry-url: https://registry.npmjs.org/
24
- - uses: actions/checkout@v4
24
+ - uses: actions/checkout@v5
25
25
  with:
26
26
  fetch-depth: 0
27
27
  - name: Publish to npm
@@ -20,7 +20,7 @@ jobs:
20
20
  with:
21
21
  node-version: 16
22
22
  registry-url: https://registry.npmjs.org/
23
- - uses: actions/checkout@v4
23
+ - uses: actions/checkout@v5
24
24
  with:
25
25
  fetch-depth: 0
26
26
  - name: Get version
@@ -14,7 +14,7 @@ jobs:
14
14
  pull-requests: write
15
15
  contents: write
16
16
  steps:
17
- - uses: actions/checkout@v4
17
+ - uses: actions/checkout@v5
18
18
  with:
19
19
  fetch-depth: 0
20
20
  - name: Update to release
@@ -21,6 +21,6 @@ jobs:
21
21
  with:
22
22
  app-id: ${{ secrets.APP_ID }}
23
23
  private-key: ${{ secrets.APP_PRIVATE_KEY }}
24
- - uses: actions/checkout@v4
24
+ - uses: actions/checkout@v5
25
25
  - name: Update version
26
26
  run: node ./Update/UpdateVersion.js ${{ steps.generate_token.outputs.token }} ${{ github.event.number }} "${{ github.event.pull_request.title }}"
@@ -15,11 +15,11 @@ jobs:
15
15
  pull-requests: write
16
16
  checks: write
17
17
  steps:
18
- - uses: actions/checkout@v3
18
+ - uses: actions/checkout@v5
19
19
  with:
20
20
  ref: ${{ github.event.pull_request.head.sha }} # to check out the actual pull request commit, not the merge commit
21
21
  fetch-depth: 0 # a full history is required for pull request analysis
22
22
  - name: 'Qodana Scan'
23
- uses: JetBrains/qodana-action@v2024.3
23
+ uses: JetBrains/qodana-action@v2025.2
24
24
  env:
25
25
  QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
@@ -10,7 +10,7 @@ jobs:
10
10
  name: Syncing branches
11
11
  steps:
12
12
  - name: Checkout
13
- uses: actions/checkout@v2
13
+ uses: actions/checkout@v5
14
14
  - name: Set up Node
15
15
  uses: actions/setup-node@v4
16
16
  with:
package/Update.json CHANGED
@@ -2991,6 +2991,36 @@
2991
2991
  }
2992
2992
  ],
2993
2993
  "Notes": "No release notes were provided for this release."
2994
+ },
2995
+ "2.1.3": {
2996
+ "UpdateDate": 1755596470421,
2997
+ "Prerelease": true,
2998
+ "UpdateContents": [
2999
+ {
3000
+ "PR": 835,
3001
+ "Description": "feat: add user-selectable theme"
3002
+ }
3003
+ ],
3004
+ "Notes": "No release notes were provided for this release."
3005
+ },
3006
+ "2.2.0": {
3007
+ "UpdateDate": 1755767075588,
3008
+ "Prerelease": false,
3009
+ "UpdateContents": [
3010
+ {
3011
+ "PR": 829,
3012
+ "Description": "Update diff-match-patch library source URL"
3013
+ },
3014
+ {
3015
+ "PR": 834,
3016
+ "Description": "feat: use credential management api"
3017
+ },
3018
+ {
3019
+ "PR": 835,
3020
+ "Description": "feat: add user-selectable theme"
3021
+ }
3022
+ ],
3023
+ "Notes": "No release notes were provided for this release."
2994
3024
  }
2995
3025
  }
2996
3026
  }
package/XMOJ.user.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // ==UserScript==
2
2
  // @name XMOJ
3
- // @version 2.1.2
3
+ // @version 2.2.0
4
4
  // @description XMOJ增强脚本
5
5
  // @author @XMOJ-Script-dev, @langningchen and the community
6
6
  // @namespace https://github/langningchen
@@ -552,6 +552,24 @@ let CurrentUsername = document.querySelector("#profile").innerText;
552
552
  CurrentUsername = CurrentUsername.replaceAll(/[^a-zA-Z0-9]/g, "");
553
553
  let IsAdmin = AdminUserList.indexOf(CurrentUsername) !== -1;
554
554
 
555
+ const prefersDark = window.matchMedia("(prefers-color-scheme: dark)");
556
+ const applyTheme = (theme) => {
557
+ document.querySelector("html").setAttribute("data-bs-theme", theme);
558
+ localStorage.setItem("UserScript-Setting-DarkMode", theme === "dark" ? "true" : "false");
559
+ };
560
+ const applySystemTheme = (e) => applyTheme(e.matches ? "dark" : "light");
561
+ let initTheme = () => {
562
+ const saved = localStorage.getItem("UserScript-Setting-Theme") || "auto";
563
+ if (saved === "auto") {
564
+ applyTheme(prefersDark.matches ? "dark" : "light");
565
+ prefersDark.addEventListener("change", applySystemTheme);
566
+ } else {
567
+ applyTheme(saved);
568
+ prefersDark.removeEventListener("change", applySystemTheme);
569
+ }
570
+ };
571
+ initTheme();
572
+
555
573
 
556
574
  class NavbarStyler {
557
575
  constructor() {
@@ -1359,7 +1377,32 @@ async function main() {
1359
1377
  } else if (Data[i].Type == "D") {
1360
1378
  Row.classList.add("list-group-item-danger");
1361
1379
  }
1362
- if (Data[i].Children == undefined) {
1380
+ if (Data[i].ID == "Theme") {
1381
+ let Label = document.createElement("label");
1382
+ Label.classList.add("me-2");
1383
+ Label.htmlFor = "UserScript-Setting-Theme";
1384
+ Label.innerText = Data[i].Name;
1385
+ Row.appendChild(Label);
1386
+ let Select = document.createElement("select");
1387
+ Select.classList.add("form-select", "form-select-sm", "w-auto", "d-inline");
1388
+ Select.id = "UserScript-Setting-Theme";
1389
+ [
1390
+ ["light", "亮色"],
1391
+ ["dark", "暗色"],
1392
+ ["auto", "跟随系统"]
1393
+ ].forEach(opt => {
1394
+ let option = document.createElement("option");
1395
+ option.value = opt[0];
1396
+ option.innerText = opt[1];
1397
+ Select.appendChild(option);
1398
+ });
1399
+ Select.value = localStorage.getItem("UserScript-Setting-Theme") || "auto";
1400
+ Select.addEventListener("change", () => {
1401
+ localStorage.setItem("UserScript-Setting-Theme", Select.value);
1402
+ initTheme();
1403
+ });
1404
+ Row.appendChild(Select);
1405
+ } else if (Data[i].Children == undefined) {
1363
1406
  let CheckBox = document.createElement("input");
1364
1407
  CheckBox.classList.add("form-check-input");
1365
1408
  CheckBox.classList.add("me-1");
@@ -1417,7 +1460,7 @@ async function main() {
1417
1460
  }, {"ID": "ResetType", "Type": "F", "Name": "重新排版*"}, {
1418
1461
  "ID": "AddColorText", "Type": "A", "Name": "增加彩色文字"
1419
1462
  }, {"ID": "AddUnits", "Type": "A", "Name": "状态界面内存与耗时添加单位"}, {
1420
- "ID": "DarkMode", "Type": "A", "Name": "使用暗色模式"
1463
+ "ID": "Theme", "Type": "A", "Name": "界面主题"
1421
1464
  }, {"ID": "AddAnimation", "Type": "A", "Name": "增加动画"}, {
1422
1465
  "ID": "ReplaceYN", "Type": "F", "Name": "题目前状态提示替换为好看的图标"
1423
1466
  }, {"ID": "RemoveAlerts", "Type": "D", "Name": "去除多余反复的提示"}, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xmoj-script",
3
- "version": "2.1.2",
3
+ "version": "2.2.0",
4
4
  "description": "an improvement script for xmoj.tech",
5
5
  "main": "AddonScript.js",
6
6
  "scripts": {