xmoj-script 1.1.1 → 1.1.3

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.
@@ -17,9 +17,17 @@ jobs:
17
17
  with:
18
18
  app-id: ${{ secrets.APP_ID }}
19
19
  private-key: ${{ secrets.APP_PRIVATE_KEY }}
20
+ - uses: actions/setup-node@v3
21
+ with:
22
+ node-version: 16
23
+ registry-url: https://registry.npmjs.org/
20
24
  - uses: actions/checkout@v4
21
25
  with:
22
26
  fetch-depth: 0
27
+ - name: Publish to npm
28
+ run: npm publish
29
+ env:
30
+ NODE_AUTH_TOKEN: ${{secrets.npm_token}}
23
31
  - name: Get version
24
32
  env:
25
33
  GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
@@ -36,8 +44,8 @@ jobs:
36
44
  prerelease: true
37
45
  files: XMOJ.user.js
38
46
  target_commitish: ${{ github.sha }}
39
- - uses: actions/configure-pages@v3
47
+ - uses: actions/configure-pages@v4
40
48
  - uses: actions/upload-pages-artifact@v2
41
49
  with:
42
50
  path: .
43
- - uses: actions/deploy-pages@v2
51
+ - uses: actions/deploy-pages@v3
@@ -16,9 +16,17 @@ jobs:
16
16
  with:
17
17
  app-id: ${{ secrets.APP_ID }}
18
18
  private-key: ${{ secrets.APP_PRIVATE_KEY }}
19
+ - uses: actions/setup-node@v3
20
+ with:
21
+ node-version: 16
22
+ registry-url: https://registry.npmjs.org/
19
23
  - uses: actions/checkout@v4
20
24
  with:
21
25
  fetch-depth: 0
26
+ - name: Publish to npm
27
+ run: npm publish
28
+ env:
29
+ NODE_AUTH_TOKEN: ${{secrets.npm_token}}
22
30
  - name: Get version
23
31
  id: get_version
24
32
  run: node ./Update/GetVersion.js
@@ -38,8 +46,8 @@ jobs:
38
46
  accountId: 89969bdf9d5ab8202f8ad8b8ae2c40b8
39
47
  projectName: xmoj-script
40
48
  directory: .
41
- - uses: actions/configure-pages@v3
49
+ - uses: actions/configure-pages@v4
42
50
  - uses: actions/upload-pages-artifact@v2
43
51
  with:
44
52
  path: .
45
- - uses: actions/deploy-pages@v2
53
+ - uses: actions/deploy-pages@v3
package/README.md CHANGED
@@ -68,18 +68,17 @@
68
68
  ### 安装
69
69
  请参考 [官网介绍](https://www.xmoj-bbs.tech) 。
70
70
 
71
- ### 加入我们
71
+ ### 贡献
72
72
  您想为我们的脚本添砖加瓦吗?快加入我们,为小明的OJ用户创造更美好的环境!(具体要求参见Code Of Conduct)
73
73
 
74
74
  小明的OJ增强脚本开发期待以您的邂逅!
75
75
 
76
- ### 贡献
77
- 请注意, 外部开发者应向`extern-contrib`提交 pull requests。
76
+ > [!IMPORTANT]
77
+ > 请注意, 外部开发者应向`extern-contrib`提交 pull requests。
78
78
 
79
79
  ### How to set up a development server
80
- In the 'Server/Sources' folder input your GitHub PAT and Cloudflare Turnstile Site key in 'Secrets.ts', and run:
81
80
  ```bash
82
- cd Server
81
+ cd backend
83
82
  npm install
84
83
  npx wrangler d1 execute DB --file ./Source/Initial.sql --local
85
84
  npx wrangler dev
package/SECURITY.md CHANGED
@@ -4,9 +4,10 @@
4
4
 
5
5
  | 版本 | 是否支持 | 预计结束支持时间 | 停止支持原因 |
6
6
  | ------- | ------------------ | --------- | -------- |
7
- | 1.0.x | :white_check_mark: | 支持 | |
7
+ | > 1.0.251 | :white_check_mark: | 支持 | |
8
+ | 1.0.x (x < 251) | :x: | 已停止支持 | 后台 api 变动 |
8
9
  | 0.3.x | :x: | 已停止支持 | 开发组人员变动 |
9
10
  | 0.2.x | :x: | 已停止支持 | 讨论功能重大更新 |
10
- | 0.1.x | :x: | 已停止支持 | 重大安全隐患 + 依赖问题(ansi_up) |
11
+ | 0.1.x | :x: | 已停止支持 | 重大安全隐患 + 依赖问题 (ansi_up) |
11
12
 
12
13
  注意:在开发过程中,服务器和用户脚本可能在任何时候发生重大变动,造成非最新版本结束支持。在这种情况下,我们会尽快更新用户脚本!感谢您的谅解。
@@ -5,15 +5,17 @@ const JSONFileName = "./Update.json";
5
5
  const JSFileName = "./XMOJ.user.js";
6
6
  var JSONFileContent = readFileSync(JSONFileName, "utf8");
7
7
  var JSFileContent = readFileSync(JSFileName, "utf8");
8
+ var NpmVersion = execSync("jq -r '.version' package.json").toString().trim();
8
9
 
9
10
  var JSONObject = JSON.parse(JSONFileContent);
10
11
 
11
12
  var LastJSONVersion = Object.keys(JSONObject.UpdateHistory)[Object.keys(JSONObject.UpdateHistory).length - 1];
12
13
  var LastJSVersion = JSFileContent.match(/@version\s+(\d+\.\d+\.\d+)/)[1];
13
- if (LastJSONVersion != LastJSVersion) {
14
- console.log("Error: XMOJ.user.js and Update.json have different versions.");
14
+ if (LastJSONVersion != LastJSVersion || LastJSONVersion != NpmVersion || LastJSVersion != NpmVersion) {
15
+ console.log("Error: XMOJ.user.js and Update.json and npm have different versions.");
15
16
  console.log("XMOJ.user.js: " + LastJSVersion);
16
17
  console.log("Update.json: " + LastJSONVersion);
18
+ console.log("npm: " + NpmVersion);
17
19
  process.exit(1);
18
20
  }
19
21
  console.log("Latest version: " + LastJSONVersion);
@@ -15,6 +15,7 @@ var JSONObject = JSON.parse(JSONFileContent);
15
15
 
16
16
  var LastJSONVersion = Object.keys(JSONObject.UpdateHistory)[Object.keys(JSONObject.UpdateHistory).length - 1];
17
17
  var LastJSVersion = JSFileContent.match(/@version\s+(\d+\.\d+\.\d+)/)[1];
18
+ var NpmVersion = execSync("jq -r '.version' package.json").toString().trim();
18
19
  var LastVersion = LastJSVersion.split(".");
19
20
  var LastPR = JSONObject.UpdateHistory[LastJSONVersion].UpdateContents[0].PR;
20
21
  var LastType = JSONObject.UpdateHistory[LastJSONVersion].Prerelease ? "Prerelease" : "Release";
@@ -22,15 +23,21 @@ console.log("Last JS version : " + LastJSVersion);
22
23
  console.log("Last JSON version : " + LastJSONVersion);
23
24
  console.log("Last PR : " + LastPR);
24
25
  console.log("Last type : " + LastType);
25
- if (LastJSONVersion.split(".")[2] != LastJSVersion.split(".")[2]) {
26
+ console.log("npm version : " + NpmVersion);
27
+ if (LastJSONVersion != LastJSVersion) {
26
28
  console.error("XMOJ.user.js and Update.json have different patch versions.");
27
29
  process.exit(1);
28
30
  }
29
31
 
30
- var CurrentVersion = LastVersion[0] + "." + LastVersion[1] + "." + (parseInt(LastVersion[2]) + 1);
31
- if (LastType == "Release") {
32
- CurrentVersion = LastJSONVersion;
32
+ execSync("git config --global user.email \"github-actions[bot]@users.noreply.github.com\"");
33
+ execSync("git config --global user.name \"github-actions[bot]\"");
34
+
35
+ if (LastJSVersion != NpmVersion) {
36
+ console.warn("Assuming you manually ran npm version.");
37
+ } else {
38
+ execSync("npm version patch");
33
39
  }
40
+ var CurrentVersion = execSync("jq -r '.version' package.json").toString().trim();
34
41
  console.log("Current version : " + CurrentVersion);
35
42
 
36
43
  JSONObject.UpdateHistory[CurrentVersion] = {
@@ -57,8 +64,6 @@ var NewJSFileContent = JSFileContent.replace(/@version(\s+)\d+\.\d+\.\d+/, "@ver
57
64
  writeFileSync(JSFileName, NewJSFileContent, "utf8");
58
65
  console.warn("XMOJ.user.js has been updated.");
59
66
 
60
- execSync("git config --global user.email \"github-actions[bot]@users.noreply.github.com\"");
61
- execSync("git config --global user.name \"github-actions[bot]\"");
62
67
  execSync("git pull");
63
68
  execSync("git push origin --delete actions/temp || true");
64
69
  execSync("git checkout -b actions/temp");
@@ -19,23 +19,30 @@ var LastVersion = LastJSVersion.split(".");
19
19
  var LastPR = JSONObject.UpdateHistory[LastJSONVersion].UpdateContents[0].PR;
20
20
  var LastDescription = JSONObject.UpdateHistory[LastJSONVersion].UpdateContents[0].Description;
21
21
  var LastReleaseVersionOnline = execSync("gh release list --exclude-pre-releases --limit 1").toString().trim().split("\t")[2];
22
+ var NpmVersion = execSync("jq -r '.version' package.json").toString().trim();
22
23
  console.log("Last JS version : " + LastJSVersion);
23
24
  console.log("Last JSON version : " + LastJSONVersion);
24
25
  console.log("Last PR : " + LastPR);
25
26
  console.log("Last description : " + LastDescription);
26
27
  console.log("Last release online: " + LastReleaseVersionOnline);
28
+ console.log("npm version : " + NpmVersion);
27
29
  if (LastJSONVersion != LastJSVersion) {
28
30
  console.error("XMOJ.user.js and Update.json have different patch versions.");
29
31
  process.exit(1);
30
32
  }
31
33
 
32
- var CurrentVersion = LastVersion[0] + "." + LastVersion[1] + "." + (parseInt(LastVersion[2]) + 1);
34
+ execSync("git config --global user.email \"github-actions[bot]@users.noreply.github.com\"");
35
+ execSync("git config --global user.name \"github-actions[bot]\"");
33
36
  var CurrentPR = Number(PRNumber);
34
37
  var CurrentDescription = String(process.argv[4]);
35
- if (LastPR == CurrentPR || JSONObject.UpdateHistory[LastJSONVersion].Prerelease == false && LastReleaseVersionOnline != LastJSONVersion) {
36
- CurrentVersion = LastJSONVersion;
38
+ if (LastJSVersion != NpmVersion) {
39
+ console.warn("Assuming you manually ran npm version.");
40
+ } else if(!(LastPR == CurrentPR && NpmVersion == LastJSVersion)) {
41
+ execSync("npm version patch");
37
42
  }
38
43
 
44
+ var CurrentVersion = execSync("jq -r '.version' package.json").toString().trim();
45
+
39
46
  console.log("Current version : " + CurrentVersion);
40
47
  console.log("Current PR : " + CurrentPR);
41
48
  console.log("Current description: " + CurrentDescription);
@@ -44,11 +51,11 @@ var ChangedFileList = execSync("gh pr diff " + CurrentPR + " --name-only").toStr
44
51
  console.log("Changed files : " + ChangedFileList.join(", "));
45
52
 
46
53
  let CommitMessage = "";
47
- if (LastPR == CurrentPR) {
54
+ if (LastPR == CurrentPR && NpmVersion == LastJSVersion) {
48
55
  console.warn("Warning: PR is the same as last version.");
49
- JSONObject.UpdateHistory[CurrentVersion].UpdateDate = Date.now();
50
- JSONObject.UpdateHistory[CurrentVersion].UpdateContents[0].Description = CurrentDescription;
51
- CommitMessage = "Update time and description of " + CurrentVersion;
56
+ JSONObject.UpdateHistory[LastJSVersion].UpdateDate = Date.now();
57
+ JSONObject.UpdateHistory[LastJSVersion].UpdateContents[0].Description = CurrentDescription;
58
+ CommitMessage = "Update time and description of " + LastJSVersion;
52
59
  }
53
60
  else if (ChangedFileList.indexOf("XMOJ.user.js") == -1) {
54
61
  console.warn("XMOJ.user.js is not changed, so the version should not be updated.");
@@ -72,8 +79,6 @@ writeFileSync(JSONFileName, JSON.stringify(JSONObject, null, 4), "utf8");
72
79
 
73
80
  console.warn("Update.json has been updated.");
74
81
 
75
- execSync("git config --global user.email \"github-actions[bot]@users.noreply.github.com\"");
76
- execSync("git config --global user.name \"github-actions[bot]\"");
77
82
  execSync("git pull");
78
83
  execSync("git commit -a -m \"" + CommitMessage + "\"");
79
84
  execSync("git push -f");
package/Update.json CHANGED
@@ -689,7 +689,7 @@
689
689
  ]
690
690
  },
691
691
  "1.1.1": {
692
- "UpdateDate": 1702641659793,
692
+ "UpdateDate": 1702641844861,
693
693
  "Prerelease": true,
694
694
  "UpdateContents": [
695
695
  {
@@ -697,6 +697,26 @@
697
697
  "Description": "Add Docs"
698
698
  }
699
699
  ]
700
+ },
701
+ "1.1.2": {
702
+ "UpdateDate": 1702687185849,
703
+ "Prerelease": true,
704
+ "UpdateContents": [
705
+ {
706
+ "PR": 301,
707
+ "Description": "改变更新架构"
708
+ }
709
+ ]
710
+ },
711
+ "1.1.3": {
712
+ "UpdateDate": 1702821395564,
713
+ "Prerelease": true,
714
+ "UpdateContents": [
715
+ {
716
+ "PR": 302,
717
+ "Description": "Update allowed tags in PurifyHTML function to allow the tag"
718
+ }
719
+ ]
700
720
  }
701
721
  }
702
722
  }
package/XMOJ.user.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // ==UserScript==
2
2
  // @name XMOJ
3
- // @version 1.1.1
3
+ // @version 1.1.3
4
4
  // @description XMOJ增强脚本
5
5
  // @author @XMOJ-Script-dev, @langningchen and the community
6
6
  // @namespace https://github/langningchen
@@ -37,10 +37,15 @@ const AdminUserList = ["zhuchenrui2", "shanwenxiao", "admin", "shihongxi"];
37
37
 
38
38
  let PurifyHTML = (Input) => {
39
39
  return DOMPurify.sanitize(Input, {
40
- "ALLOWED_TAGS": ["a", "b", "blockquote", "br", "code", "dd", "del", "div", "dl", "dt", "em", "h1", "h2", "h3", "h4", "h5", "h6", "h7", "h8", "hr", "i", "img", "ins", "kbd", "li", "ol", "p", "pre", "q", "rp", "rt", "ruby", "s", "samp", "strike", "strong", "sub", "sup", "table", "tbody", "td", "tfoot", "th", "thead", "tr", "tt", "ul", "var"],
40
+ "ALLOWED_TAGS": ["a", "b", "big", "blockquote", "br", "code", "dd", "del", "div", "dl", "dt", "em", "h1", "h2", "h3", "h4", "h5", "h6", "h7", "h8", "hr", "i", "img", "ins", "kbd", "li", "ol", "p", "pre", "q", "rp", "rt", "ruby", "s", "samp", "strike", "strong", "sub", "sup", "table", "tbody", "td", "tfoot", "th", "thead", "tr", "tt", "ul", "var"],
41
41
  "ALLOWED_ATTR": ["abbr", "accept", "accept-charset", "accesskey", "action", "align", "alt", "axis", "border", "cellpadding", "cellspacing", "char", "charoff", "charset", "checked", "cite", "clear", "color", "cols", "colspan", "compact", "coords", "datetime", "dir", "disabled", "enctype", "for", "frame", "headers", "height", "href", "hreflang", "hspace", "ismap", "itemprop", "label", "lang", "longdesc", "maxlength", "media", "method", "multiple", "name", "nohref", "noshade", "nowrap", "prompt", "readonly", "rel", "rev", "rows", "rowspan", "rules", "scope", "selected", "shape", "size", "span", "src", "start", "summary", "tabindex", "target", "title", "type", "usemap", "valign", "value", "vspace", "width"]
42
42
  });
43
43
  }
44
+ /**
45
+ * Calculates the relative time based on the input date.
46
+ * @param {string|Date} Input - The input date.
47
+ * @returns {string} The relative time in a formatted string.
48
+ */
44
49
  let GetRelativeTime = (Input) => {
45
50
  Input = new Date(Input);
46
51
  let Now = new Date().getTime();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xmoj-script",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "description": "an improvement script for xmoj.tech",
5
5
  "main": "AddonScript.js",
6
6
  "scripts": {
@@ -1,21 +0,0 @@
1
- # Configuration for welcome - https://github.com/XMOJ-Script-dev
2
-
3
- # Configuration for new-issue-welcome - https://github.com/XMOJ-Script-dev
4
-
5
- # Comment to be posted to on first time issues
6
- newIssueWelcomeComment: >
7
- Thanks for opening your first issue here! 欢迎你第一次来到这里开Issue!
8
-
9
- # Configuration for new-pr-welcome - https://github.com/behaviorbot/new-pr-welcome
10
-
11
- # Comment to be posted to on PRs from first time contributors in your repository
12
- newPRWelcomeComment: >
13
- Thanks for opening this pull request! Please check out our contributing guidelines. 欢迎你像我们做出贡献!
14
-
15
- # Configuration for first-pr-merge - https://github.com/behaviorbot/first-pr-merge
16
-
17
- # Comment to be posted to on pull requests merged by a first time user
18
- firstPRMergeComment: >
19
- Congrats on merging your first pull request! We here at behaviorbot are proud of you! 哇!你的PR审核通过了!祝贺你!
20
-
21
- # It is recommended to include as many gifs and emojis as possible!
@@ -1,30 +0,0 @@
1
- name: 综合 Bug 反馈
2
- description: 有功能有问题
3
- labels: bug, needs-triage
4
- assignees: PythonSmall-Q, boomzero, shihongxi
5
- title: "[Bug]"
6
- body:
7
- - type: checkboxes
8
- attributes:
9
- label: 检查项
10
- description: 请逐个检查下列项目,并勾选确认。
11
- options:
12
- - label: 我已确认了XMOJ增强脚本已为最新版,且最新版未修复这个 Bug 。
13
- required: true
14
- - label: 我已在 [Issues 页面](https://github.com/XMOJ-Script-dev/XMOJ-Script/issues) 中搜索,确认了这一 Bug 未被提交过。
15
- required: true
16
- - type: textarea
17
- attributes:
18
- label: 描述
19
- description: 详细描述该 Bug 的具体表现。
20
- validations:
21
- required: true
22
- - type: textarea
23
- attributes:
24
- label: 重现步骤
25
- description: 详细描述要怎么操作才能再次触发这个 Bug 。
26
- - type: textarea
27
- attributes:
28
- label: 控制台错误信息
29
- description: 粘贴控制台错误信息,如果没有错误请忽略
30
- placeholder: 请按F12并选择控制台/Console,并将其中的错误信息粘贴至此处
@@ -1,5 +0,0 @@
1
- blank_issues_enabled: false
2
- contact_links:
3
- - name: 提问
4
- url: https://github.com/XMOJ-Script-dev/XMOJ-Script/discussions/categories/q-a
5
- about: 我不想提交反馈,只是想问一些问题
@@ -1,25 +0,0 @@
1
- name: 新功能提案
2
- description: 对已有功能的大幅度修改,或添加一个新内容或选项
3
- labels: enhancement, needs-triage
4
- assignees: PythonSmall-Q, boomzero, shihongxi
5
- title: "[Feature Request]"
6
- body:
7
- - type: checkboxes
8
- attributes:
9
- label: 检查项
10
- description: 请逐个检查下列项目,并勾选确认。
11
- options:
12
- - label: 我已确认了XMOJ增强脚本已为最新版,且最新版未实现这一功能。
13
- required: true
14
- - label: 我已在 [Issues 页面](https://github.com/XMOJ-Script-dev/XMOJ-Script/issues) 中搜索,确认了这一提案未被提交过。
15
- required: true
16
- - type: textarea
17
- attributes:
18
- label: 描述
19
- description: 详细描述你想添加的功能具体是怎样的。
20
- validations:
21
- required: true
22
- - type: textarea
23
- attributes:
24
- label: 原因
25
- description: 详细描述你为什么需要这项功能。
@@ -1,12 +0,0 @@
1
- version: 2
2
- updates:
3
- - package-ecosystem: "npm"
4
- directory: "/Server"
5
- target-branch: "dev"
6
- schedule:
7
- interval: "weekly"
8
- - package-ecosystem: "github-actions"
9
- directory: "/"
10
- target-branch: "dev"
11
- schedule:
12
- interval: "weekly"
@@ -1,14 +0,0 @@
1
- user-script:
2
- - XMOJ.user.js
3
- website:
4
- - index.html
5
- - robots.txt
6
- - '*.html'
7
- update-script:
8
- - Update/**
9
- server:
10
- - Server/**
11
- GitHub-related:
12
- - '.github/**'
13
- addon-script:
14
- - AddonScript.js