xmoj-script 2.2.1 → 2.2.2
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.
- package/.github/ISSUE_TEMPLATE/bug.yml +1 -0
- package/.github/ISSUE_TEMPLATE/docs.yml +1 -0
- package/.github/ISSUE_TEMPLATE/feature.yml +1 -0
- package/.github/workflows/UpdateToRelease.yml +3 -1
- package/.github/workflows/UpdateVersion.yml +3 -1
- package/CONTRIBUTING.md +1 -0
- package/Update/UpdateToRelease.js +9 -1
- package/Update/UpdateVersion.js +12 -1
- package/Update.json +11 -0
- package/XMOJ.user.js +6 -5
- package/package.json +1 -1
@@ -5,6 +5,7 @@ on:
|
|
5
5
|
- opened
|
6
6
|
- reopened
|
7
7
|
- synchronize
|
8
|
+
- edited
|
8
9
|
branches:
|
9
10
|
- master
|
10
11
|
jobs:
|
@@ -24,7 +25,8 @@ jobs:
|
|
24
25
|
gh pr comment ${{ github.event.pull_request.number }} --body "请向\`dev\`分支提交pull request, 本pull request将被自动关闭"
|
25
26
|
gh pr close ${{ github.event.pull_request.number }}
|
26
27
|
else
|
27
|
-
node ./Update/UpdateToRelease.js ${{ secrets.GITHUB_TOKEN }} ${{ github.event.number }}
|
28
|
+
node ./Update/UpdateToRelease.js ${{ secrets.GITHUB_TOKEN }} ${{ github.event.number }} "$PR_BODY"
|
28
29
|
fi
|
29
30
|
env:
|
30
31
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
32
|
+
PR_BODY: ${{ github.event.pull_request.body }}
|
@@ -23,4 +23,6 @@ jobs:
|
|
23
23
|
private-key: ${{ secrets.APP_PRIVATE_KEY }}
|
24
24
|
- uses: actions/checkout@v5
|
25
25
|
- name: Update version
|
26
|
-
|
26
|
+
env:
|
27
|
+
PR_BODY: ${{ github.event.pull_request.body }}
|
28
|
+
run: node ./Update/UpdateVersion.js ${{ steps.generate_token.outputs.token }} ${{ github.event.number }} "${{ github.event.pull_request.title }}" "$PR_BODY"
|
package/CONTRIBUTING.md
CHANGED
@@ -18,3 +18,4 @@ We believe that you must be excited to contribute to our repo, but first, please
|
|
18
18
|
- Be patient. We are a small team and may not be able to review your PR immediately.
|
19
19
|
- Please be considerate towards the developers and other users when raising issues or presenting pull requests.
|
20
20
|
- Respect our decision(s), and do not be upset or abusive if your submission is not used.
|
21
|
+
- For release pull requests, include an HTML comment block starting with `<!-- release-notes` and ending with `-->` in the PR description. The automation will extract that block into the release notes.
|
@@ -3,6 +3,13 @@ import {execSync} from "child_process";
|
|
3
3
|
|
4
4
|
var GithubToken = process.argv[2];
|
5
5
|
var PRNumber = process.argv[3];
|
6
|
+
function extractReleaseNotes(body) {
|
7
|
+
const match = body
|
8
|
+
.replace(/\r\n/g, "\n")
|
9
|
+
.match(/<!--\s*release[- ]notes\s*([\s\S]*?)-->/i);
|
10
|
+
return match ? match[1].trim() : "";
|
11
|
+
}
|
12
|
+
var CurrentNotes = extractReleaseNotes(String(process.argv[4] || ""));
|
6
13
|
process.env.GITHUB_TOKEN = GithubToken;
|
7
14
|
execSync("gh pr checkout " + PRNumber);
|
8
15
|
console.info("PR #" + PRNumber + " has been checked out.");
|
@@ -45,6 +52,7 @@ console.log("Last JSON version : " + LastJSONVersion);
|
|
45
52
|
console.log("Last PR : " + LastPR);
|
46
53
|
console.log("Last type : " + LastType);
|
47
54
|
console.log("npm version : " + NpmVersion);
|
55
|
+
console.log("Current notes : " + (CurrentNotes || "No release notes were provided for this release."));
|
48
56
|
|
49
57
|
if (LastJSONVersion != LastJSVersion) {
|
50
58
|
console.error("XMOJ.user.js and Update.json have different patch versions.");
|
@@ -67,7 +75,7 @@ JSONObject.UpdateHistory[CurrentVersion] = {
|
|
67
75
|
"UpdateDate": Date.now(),
|
68
76
|
"Prerelease": false,
|
69
77
|
"UpdateContents": [],
|
70
|
-
"Notes": "No release notes were provided for this release."
|
78
|
+
"Notes": CurrentNotes || "No release notes were provided for this release."
|
71
79
|
};
|
72
80
|
|
73
81
|
for (var i = Object.keys(JSONObject.UpdateHistory).length - 2; i >= 0; i--) {
|
package/Update/UpdateVersion.js
CHANGED
@@ -47,6 +47,13 @@ execSync("git config --global user.email \"github-actions[bot]@users.noreply.git
|
|
47
47
|
execSync("git config --global user.name \"github-actions[bot]\"");
|
48
48
|
var CurrentPR = Number(PRNumber);
|
49
49
|
var CurrentDescription = String(process.argv[4]);
|
50
|
+
function extractReleaseNotes(body) {
|
51
|
+
const match = body
|
52
|
+
.replace(/\r\n/g, "\n")
|
53
|
+
.match(/<!--\s*release[- ]notes\s*([\s\S]*?)-->/i);
|
54
|
+
return match ? match[1].trim() : "";
|
55
|
+
}
|
56
|
+
var CurrentNotes = extractReleaseNotes(String(process.argv[5] || ""));
|
50
57
|
if (LastJSVersion != NpmVersion) {
|
51
58
|
console.warn("Assuming you manually ran npm version.");
|
52
59
|
} else if (!(LastPR == CurrentPR && NpmVersion == LastJSVersion)) {
|
@@ -58,6 +65,7 @@ var CurrentVersion = execSync("jq -r '.version' package.json").toString().trim()
|
|
58
65
|
console.log("Current version : " + CurrentVersion);
|
59
66
|
console.log("Current PR : " + CurrentPR);
|
60
67
|
console.log("Current description: " + CurrentDescription);
|
68
|
+
console.log("Current notes : " + (CurrentNotes || "No release notes were provided for this release."));
|
61
69
|
|
62
70
|
var ChangedFileList = execSync("gh pr diff " + CurrentPR + " --name-only").toString().trim().split("\n");
|
63
71
|
console.log("Changed files : " + ChangedFileList.join(", "));
|
@@ -67,6 +75,9 @@ if (LastPR == CurrentPR && NpmVersion == LastJSVersion) {
|
|
67
75
|
console.warn("Warning: PR is the same as last version.");
|
68
76
|
JSONObject.UpdateHistory[LastJSVersion].UpdateDate = Date.now();
|
69
77
|
JSONObject.UpdateHistory[LastJSVersion].UpdateContents[0].Description = CurrentDescription;
|
78
|
+
if (CurrentNotes) {
|
79
|
+
JSONObject.UpdateHistory[LastJSVersion].Notes = CurrentNotes;
|
80
|
+
}
|
70
81
|
CommitMessage = "Update time and description of " + LastJSVersion;
|
71
82
|
} else if (ChangedFileList.indexOf("XMOJ.user.js") == -1) {
|
72
83
|
console.warn("XMOJ.user.js is not changed, so the version should not be updated.");
|
@@ -79,7 +90,7 @@ if (LastPR == CurrentPR && NpmVersion == LastJSVersion) {
|
|
79
90
|
"PR": CurrentPR,
|
80
91
|
"Description": CurrentDescription
|
81
92
|
}],
|
82
|
-
"Notes": "No release notes were provided for this release."
|
93
|
+
"Notes": CurrentNotes || "No release notes were provided for this release."
|
83
94
|
};
|
84
95
|
writeFileSync(JSFileName, JSFileContent.replace(/@version(\s+)\d+\.\d+\.\d+/, "@version$1" + CurrentVersion), "utf8");
|
85
96
|
console.warn("XMOJ.user.js has been updated.");
|
package/Update.json
CHANGED
@@ -3032,6 +3032,17 @@
|
|
3032
3032
|
}
|
3033
3033
|
],
|
3034
3034
|
"Notes": "No release notes were provided for this release."
|
3035
|
+
},
|
3036
|
+
"2.2.2": {
|
3037
|
+
"UpdateDate": 1757851046240,
|
3038
|
+
"Prerelease": true,
|
3039
|
+
"UpdateContents": [
|
3040
|
+
{
|
3041
|
+
"PR": 852,
|
3042
|
+
"Description": "Fix the submit button on some pages"
|
3043
|
+
}
|
3044
|
+
],
|
3045
|
+
"Notes": "No release notes were provided for this release."
|
3035
3046
|
}
|
3036
3047
|
}
|
3037
3048
|
}
|
package/XMOJ.user.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
// ==UserScript==
|
2
2
|
// @name XMOJ
|
3
|
-
// @version 2.2.
|
3
|
+
// @version 2.2.2
|
4
4
|
// @description XMOJ增强脚本
|
5
5
|
// @author @XMOJ-Script-dev, @langningchen and the community
|
6
6
|
// @namespace https://github/langningchen
|
@@ -444,7 +444,7 @@ let UtilityEnabled = (Name) => {
|
|
444
444
|
let storeCredential = async (username, password) => {
|
445
445
|
if ('credentials' in navigator && window.PasswordCredential) {
|
446
446
|
try {
|
447
|
-
const credential = new PasswordCredential({
|
447
|
+
const credential = new PasswordCredential({id: username, password: password});
|
448
448
|
await navigator.credentials.store(credential);
|
449
449
|
} catch (e) {
|
450
450
|
console.error(e);
|
@@ -454,7 +454,7 @@ let storeCredential = async (username, password) => {
|
|
454
454
|
let getCredential = async () => {
|
455
455
|
if ('credentials' in navigator && window.PasswordCredential) {
|
456
456
|
try {
|
457
|
-
return await navigator.credentials.get({
|
457
|
+
return await navigator.credentials.get({password: true, mediation: 'optional'});
|
458
458
|
} catch (e) {
|
459
459
|
console.error(e);
|
460
460
|
}
|
@@ -1627,8 +1627,9 @@ async function main() {
|
|
1627
1627
|
}, 1000);
|
1628
1628
|
} else {
|
1629
1629
|
let PID = localStorage.getItem("UserScript-Contest-" + SearchParams.get("cid") + "-Problem-" + SearchParams.get("pid") + "-PID");
|
1630
|
-
|
1631
|
-
|
1630
|
+
if (document.querySelector("body > div > div.mt-3 > center").lastElementChild !== null) {
|
1631
|
+
document.querySelector("body > div > div.mt-3 > center").lastElementChild.style.marginLeft = "10px";
|
1632
|
+
}
|
1632
1633
|
//修复提交按钮
|
1633
1634
|
let SubmitLink = document.querySelector('.mt-3 > center:nth-child(1) > a:nth-child(12)');
|
1634
1635
|
if (SubmitLink == null) { //a special type of problem
|