xmoj-script 1.1.46 → 1.1.48

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.
@@ -0,0 +1,51 @@
1
+ name: Sitemap merge
2
+ on:
3
+ push:
4
+ branches:
5
+ - create-pull-request/patch
6
+ workflow_dispatch:
7
+ jobs:
8
+ create_pull_request:
9
+ name: 'Create PR'
10
+ if: github.ref == 'refs/heads/beta'
11
+ runs-on: ubuntu-latest
12
+ permissions:
13
+ pull-requests: write
14
+ steps:
15
+ - name: 'Create PR'
16
+ uses: actions/github-script@v7
17
+ with:
18
+ script: |
19
+ const { repo, owner } = context.repo;
20
+ const pulls = await github.rest.pulls.list({
21
+ owner: owner,
22
+ repo: repo,
23
+ head: context.ref,
24
+ base: 'dev',
25
+ state: 'open',
26
+ });
27
+
28
+ if (pulls.data.length < 1) {
29
+ await github.rest.pulls.create({
30
+ title: '[Sitemap] Merge sitemap into dev',
31
+ owner: owner,
32
+ repo: repo,
33
+ head: context.ref,
34
+ base: 'dev',
35
+ body: [
36
+ 'This PR is auto-generated by',
37
+ '[actions/github-script](https://github.com/actions/github-script)',
38
+ ].join('\n'),
39
+ });
40
+ } else {
41
+ const existingPR = pulls.data[0];
42
+ await github.rest.pulls.update({
43
+ owner: owner,
44
+ repo: repo,
45
+ pull_number: existingPR.number,
46
+ body: [
47
+ existingPR.body,
48
+ `Updated by Job ${context.job}`,
49
+ ].join('\n'),
50
+ });
51
+ }
@@ -11,19 +11,6 @@ const JSONFileName = "./Update.json";
11
11
  const JSFileName = "./XMOJ.user.js";
12
12
  var JSONFileContent = readFileSync(JSONFileName, "utf8");
13
13
  var JSFileContent = readFileSync(JSFileName, "utf8");
14
- var JSONObject = JSON.parse(JSONFileContent);
15
-
16
- var LastJSONVersion = Object.keys(JSONObject.UpdateHistory)[Object.keys(JSONObject.UpdateHistory).length - 1];
17
- var LastJSVersion = JSFileContent.match(/@version\s+(\d+\.\d+\.\d+)/)[1];
18
- var NpmVersion = execSync("jq -r '.version' package.json").toString().trim();
19
- var LastVersion = LastJSVersion.split(".");
20
- var LastPR = JSONObject.UpdateHistory[LastJSONVersion].UpdateContents[0].PR;
21
- var LastType = JSONObject.UpdateHistory[LastJSONVersion].Prerelease ? "Prerelease" : "Release";
22
- console.log("Last JS version : " + LastJSVersion);
23
- console.log("Last JSON version : " + LastJSONVersion);
24
- console.log("Last PR : " + LastPR);
25
- console.log("Last type : " + LastType);
26
- console.log("npm version : " + NpmVersion);
27
14
  execSync("git config --global user.email \"github-actions[bot]@users.noreply.github.com\"");
28
15
  execSync("git config --global user.name \"github-actions[bot]\"");
29
16
  if (JSONFileContent.includes('//!ci-no-touch')) {
@@ -45,15 +32,27 @@ if (JSONFileContent.includes('//!ci-no-touch')) {
45
32
  console.log('I won\'t touch this. Exiting process.');
46
33
  process.exit(0);
47
34
  }
35
+ var JSONObject = JSON.parse(JSONFileContent);
36
+
37
+ var LastJSONVersion = Object.keys(JSONObject.UpdateHistory)[Object.keys(JSONObject.UpdateHistory).length - 1];
38
+ var LastJSVersion = JSFileContent.match(/@version\s+(\d+\.\d+\.\d+)/)[1];
39
+ var NpmVersion = execSync("jq -r '.version' package.json").toString().trim();
40
+ var LastVersion = LastJSVersion.split(".");
41
+ var LastPR = JSONObject.UpdateHistory[LastJSONVersion].UpdateContents[0].PR;
42
+ var LastType = JSONObject.UpdateHistory[LastJSONVersion].Prerelease ? "Prerelease" : "Release";
43
+ console.log("Last JS version : " + LastJSVersion);
44
+ console.log("Last JSON version : " + LastJSONVersion);
45
+ console.log("Last PR : " + LastPR);
46
+ console.log("Last type : " + LastType);
47
+ console.log("npm version : " + NpmVersion);
48
+
48
49
  if (LastJSONVersion != LastJSVersion) {
49
50
  console.error("XMOJ.user.js and Update.json have different patch versions.");
50
51
  process.exit(1);
51
52
  }
52
53
  if (LastType == "Release") {
53
54
  console.error("Last release is not a prerelease.");
54
- execSync("gh pr comment " + PRNumber + " --body \"请重新提交PR, 谢谢");
55
- execSync("gh pr close " + PRNumber);
56
- process.exit(1);
55
+ process.exit(0);
57
56
  }
58
57
 
59
58
  if (LastJSVersion != NpmVersion) {
@@ -11,6 +11,19 @@ const JSONFileName = "./Update.json";
11
11
  const JSFileName = "./XMOJ.user.js";
12
12
  var JSONFileContent = readFileSync(JSONFileName, "utf8");
13
13
  var JSFileContent = readFileSync(JSFileName, "utf8");
14
+ execSync("git config --global user.email \"github-actions[bot]@users.noreply.github.com\"");
15
+ execSync("git config --global user.name \"github-actions[bot]\"");
16
+ if (JSONFileContent.includes('//!ci-no-touch')) {
17
+ var updatedContent = JSONFileContent.replace('//!ci-no-touch', '');
18
+ writeFileSync(JSONFileName, updatedContent, "utf8");
19
+ execSync("git config pull.rebase false");
20
+ execSync("git pull");
21
+ execSync("git commit -a -m \"" + "remove //!ci-no-touch" + "\"");
22
+ execSync("git push -f");
23
+ console.log("Pushed to GitHub.");
24
+ console.log('I won\'t touch this. Exiting process.');
25
+ process.exit(0);
26
+ }
14
27
  var JSONObject = JSON.parse(JSONFileContent);
15
28
 
16
29
  var LastJSONVersion = Object.keys(JSONObject.UpdateHistory)[Object.keys(JSONObject.UpdateHistory).length - 1];
@@ -26,19 +39,6 @@ console.log("Last PR : " + LastPR);
26
39
  console.log("Last description : " + LastDescription);
27
40
  console.log("Last release online: " + LastReleaseVersionOnline);
28
41
  console.log("npm version : " + NpmVersion);
29
- execSync("git config --global user.email \"github-actions[bot]@users.noreply.github.com\"");
30
- execSync("git config --global user.name \"github-actions[bot]\"");
31
- if (JSONFileContent.includes('//!ci-no-touch')) {
32
- var updatedContent = JSONFileContent.replace('//!ci-no-touch', '');
33
- writeFileSync(JSONFileName, updatedContent, "utf8");
34
- execSync("git config pull.rebase false");
35
- execSync("git pull");
36
- execSync("git commit -a -m \"" + "remove //!ci-no-touch" + "\"");
37
- execSync("git push -f");
38
- console.log("Pushed to GitHub.");
39
- console.log('I won\'t touch this. Exiting process.');
40
- process.exit(0);
41
- }
42
42
  if (LastJSONVersion != LastJSVersion) {
43
43
  console.error("XMOJ.user.js and Update.json have different patch versions.");
44
44
  process.exit(1);
package/Update.json CHANGED
@@ -1331,6 +1331,17 @@
1331
1331
  "Description": "fix #400 + //ci-no-touch"
1332
1332
  }
1333
1333
  ],
1334
+ "Notes": "A lot of QoL improvements!"
1335
+ },
1336
+ "1.1.48": {
1337
+ "UpdateDate": 1709370871510,
1338
+ "Prerelease": true,
1339
+ "UpdateContents": [
1340
+ {
1341
+ "PR": 485,
1342
+ "Description": "and I am so frustrated I actually make another code contribution"
1343
+ }
1344
+ ],
1334
1345
  "Notes": "No release notes were provided for this release."
1335
1346
  }
1336
1347
  }
package/XMOJ.png CHANGED
Binary file
package/XMOJ.user.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // ==UserScript==
2
2
  // @name XMOJ
3
- // @version 1.1.46
3
+ // @version 1.1.48
4
4
  // @description XMOJ增强脚本
5
5
  // @author @XMOJ-Script-dev, @langningchen and the community
6
6
  // @namespace https://github/langningchen
@@ -1865,6 +1865,7 @@ async function main() {
1865
1865
  let ParsedDocument = new DOMParser().parseFromString(Result, "text/html");
1866
1866
  SID = ParsedDocument.querySelector("#result-tab > tbody > tr:nth-child(1) > td:nth-child(2)").innerText;
1867
1867
  });
1868
+ await new Promise(r => setTimeout(r, 500));
1868
1869
  let Code = "";
1869
1870
  await fetch("https://www.xmoj.tech/getsource.php?id=" + SID)
1870
1871
  .then((Response) => {
@@ -1872,6 +1873,7 @@ async function main() {
1872
1873
  }).then((Response) => {
1873
1874
  Code = Response.substring(0, Response.indexOf("/**************************************************************")).trim();
1874
1875
  });
1876
+ await new Promise(r => setTimeout(r, 500));
1875
1877
  await fetch("https://www.xmoj.tech/submit.php", {
1876
1878
  "headers": {
1877
1879
  "content-type": "application/x-www-form-urlencoded"
@@ -1880,7 +1882,6 @@ async function main() {
1880
1882
  "method": "POST",
1881
1883
  "body": "cid=" + CID + "&pid=" + i + "&" + "language=1&" + "source=" + encodeURIComponent(Code) + "&" + "enable_O2=on"
1882
1884
  });
1883
- //sleep for one second
1884
1885
  await new Promise(r => setTimeout(r, 500));
1885
1886
  }
1886
1887
  if (!Submitted) {
@@ -3565,8 +3566,6 @@ int main()
3565
3566
  await fetch("https://www.xmoj.tech/getsource.php?id=" + SearchParams.get("id"))
3566
3567
  .then((Response) => {
3567
3568
  return Response.text();
3568
- }).then((Response) => {
3569
- Code = Response.substring(0, Response.indexOf("/**************************************************************")).trim();
3570
3569
  });
3571
3570
  } else {
3572
3571
  if (localStorage.getItem("UserScript-LastUploadedStdTime") === undefined || new Date().getTime() - localStorage.getItem("UserScript-LastUploadedStdTime") > 1000 * 60 * 60 * 24 * 30) {
package/favicon.ico CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xmoj-script",
3
- "version": "1.1.46",
3
+ "version": "1.1.48",
4
4
  "description": "an improvement script for xmoj.tech",
5
5
  "main": "AddonScript.js",
6
6
  "scripts": {