diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml index 9e03a313..bf1f6784 100644 --- a/.github/ISSUE_TEMPLATE/bug.yml +++ b/.github/ISSUE_TEMPLATE/bug.yml @@ -1,6 +1,7 @@ name: 综合 Bug 反馈 description: 有功能有问题 labels: bug, needs-triage +type: Bug # assignees: PythonSmall-Q, boomzero, shihongxi title: "[Bug]" body: diff --git a/.github/ISSUE_TEMPLATE/docs.yml b/.github/ISSUE_TEMPLATE/docs.yml index 8152f0a9..982e8c57 100644 --- a/.github/ISSUE_TEMPLATE/docs.yml +++ b/.github/ISSUE_TEMPLATE/docs.yml @@ -1,6 +1,7 @@ name: 帮助文档反馈 description: 帮助文档有问题 labels: docs, needs-triage +type: Task title: "[Docs]" body: - type: checkboxes diff --git a/.github/ISSUE_TEMPLATE/feature.yml b/.github/ISSUE_TEMPLATE/feature.yml index 9fbae4f5..90d3177d 100644 --- a/.github/ISSUE_TEMPLATE/feature.yml +++ b/.github/ISSUE_TEMPLATE/feature.yml @@ -1,6 +1,7 @@ name: 新功能提案 description: 对已有功能的大幅度修改,或添加一个新内容或选项 labels: enhancement, needs-triage +type: Feature #assignees: PythonSmall-Q, boomzero, shihongxi title: "[Feature Request]" body: diff --git a/.github/workflows/UpdateToRelease.yml b/.github/workflows/UpdateToRelease.yml index ba950e34..e401f757 100644 --- a/.github/workflows/UpdateToRelease.yml +++ b/.github/workflows/UpdateToRelease.yml @@ -5,6 +5,7 @@ on: - opened - reopened - synchronize + - edited branches: - master jobs: @@ -24,7 +25,8 @@ jobs: gh pr comment ${{ github.event.pull_request.number }} --body "请向\`dev\`分支提交pull request, 本pull request将被自动关闭" gh pr close ${{ github.event.pull_request.number }} else - node ./Update/UpdateToRelease.js ${{ secrets.GITHUB_TOKEN }} ${{ github.event.number }} + node ./Update/UpdateToRelease.js ${{ secrets.GITHUB_TOKEN }} ${{ github.event.number }} "$PR_BODY" fi env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR_BODY: ${{ github.event.pull_request.body }} diff --git a/.github/workflows/UpdateVersion.yml b/.github/workflows/UpdateVersion.yml index 8ab253d5..b71fbb1f 100644 --- a/.github/workflows/UpdateVersion.yml +++ b/.github/workflows/UpdateVersion.yml @@ -23,4 +23,6 @@ jobs: private-key: ${{ secrets.APP_PRIVATE_KEY }} - 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 }}" + env: + PR_BODY: ${{ github.event.pull_request.body }} + run: node ./Update/UpdateVersion.js ${{ steps.generate_token.outputs.token }} ${{ github.event.number }} "${{ github.event.pull_request.title }}" "$PR_BODY" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d357e825..0f5c6e14 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -18,3 +18,4 @@ We believe that you must be excited to contribute to our repo, but first, please - Be patient. We are a small team and may not be able to review your PR immediately. - Please be considerate towards the developers and other users when raising issues or presenting pull requests. - Respect our decision(s), and do not be upset or abusive if your submission is not used. +- For release pull requests, include an HTML comment block starting with `` in the PR description. The automation will extract that block into the release notes. diff --git a/Update.json b/Update.json index d5a1b36a..4953be77 100644 --- a/Update.json +++ b/Update.json @@ -3021,6 +3021,43 @@ } ], "Notes": "No release notes were provided for this release." + }, + "2.2.1": { + "UpdateDate": 1756003502262, + "Prerelease": true, + "UpdateContents": [ + { + "PR": 839, + "Description": "Fix formatting in feedback card text" + } + ], + "Notes": "No release notes were provided for this release." + }, + "2.2.2": { + "UpdateDate": 1757851046240, + "Prerelease": true, + "UpdateContents": [ + { + "PR": 852, + "Description": "Fix the submit button on some pages" + } + ], + "Notes": "No release notes were provided for this release." + }, + "2.3.0": { + "UpdateDate": 1757851277491, + "Prerelease": false, + "UpdateContents": [ + { + "PR": 839, + "Description": "Fix formatting in feedback card text" + }, + { + "PR": 852, + "Description": "Fix the submit button on some pages" + } + ], + "Notes": "随着 CI 更新, 相信以后的 release 都会有 release notes(" } } } \ No newline at end of file diff --git a/Update/UpdateToRelease.js b/Update/UpdateToRelease.js index 37256782..c675452c 100644 --- a/Update/UpdateToRelease.js +++ b/Update/UpdateToRelease.js @@ -3,6 +3,13 @@ import {execSync} from "child_process"; var GithubToken = process.argv[2]; var PRNumber = process.argv[3]; +function extractReleaseNotes(body) { + const match = body + .replace(/\r\n/g, "\n") + .match(//i); + return match ? match[1].trim() : ""; +} +var CurrentNotes = extractReleaseNotes(String(process.argv[4] || "")); process.env.GITHUB_TOKEN = GithubToken; execSync("gh pr checkout " + PRNumber); console.info("PR #" + PRNumber + " has been checked out."); @@ -45,6 +52,7 @@ console.log("Last JSON version : " + LastJSONVersion); console.log("Last PR : " + LastPR); console.log("Last type : " + LastType); console.log("npm version : " + NpmVersion); +console.log("Current notes : " + (CurrentNotes || "No release notes were provided for this release.")); if (LastJSONVersion != LastJSVersion) { console.error("XMOJ.user.js and Update.json have different patch versions."); @@ -67,7 +75,7 @@ JSONObject.UpdateHistory[CurrentVersion] = { "UpdateDate": Date.now(), "Prerelease": false, "UpdateContents": [], - "Notes": "No release notes were provided for this release." + "Notes": CurrentNotes || "No release notes were provided for this release." }; for (var i = Object.keys(JSONObject.UpdateHistory).length - 2; i >= 0; i--) { diff --git a/Update/UpdateVersion.js b/Update/UpdateVersion.js index 1fab8e5e..840ec2b8 100644 --- a/Update/UpdateVersion.js +++ b/Update/UpdateVersion.js @@ -47,6 +47,13 @@ execSync("git config --global user.email \"github-actions[bot]@users.noreply.git execSync("git config --global user.name \"github-actions[bot]\""); var CurrentPR = Number(PRNumber); var CurrentDescription = String(process.argv[4]); +function extractReleaseNotes(body) { + const match = body + .replace(/\r\n/g, "\n") + .match(//i); + return match ? match[1].trim() : ""; +} +var CurrentNotes = extractReleaseNotes(String(process.argv[5] || "")); if (LastJSVersion != NpmVersion) { console.warn("Assuming you manually ran npm version."); } else if (!(LastPR == CurrentPR && NpmVersion == LastJSVersion)) { @@ -58,6 +65,7 @@ var CurrentVersion = execSync("jq -r '.version' package.json").toString().trim() console.log("Current version : " + CurrentVersion); console.log("Current PR : " + CurrentPR); console.log("Current description: " + CurrentDescription); +console.log("Current notes : " + (CurrentNotes || "No release notes were provided for this release.")); var ChangedFileList = execSync("gh pr diff " + CurrentPR + " --name-only").toString().trim().split("\n"); console.log("Changed files : " + ChangedFileList.join(", ")); @@ -67,6 +75,9 @@ if (LastPR == CurrentPR && NpmVersion == LastJSVersion) { console.warn("Warning: PR is the same as last version."); JSONObject.UpdateHistory[LastJSVersion].UpdateDate = Date.now(); JSONObject.UpdateHistory[LastJSVersion].UpdateContents[0].Description = CurrentDescription; + if (CurrentNotes) { + JSONObject.UpdateHistory[LastJSVersion].Notes = CurrentNotes; + } CommitMessage = "Update time and description of " + LastJSVersion; } else if (ChangedFileList.indexOf("XMOJ.user.js") == -1) { console.warn("XMOJ.user.js is not changed, so the version should not be updated."); @@ -79,7 +90,7 @@ if (LastPR == CurrentPR && NpmVersion == LastJSVersion) { "PR": CurrentPR, "Description": CurrentDescription }], - "Notes": "No release notes were provided for this release." + "Notes": CurrentNotes || "No release notes were provided for this release." }; writeFileSync(JSFileName, JSFileContent.replace(/@version(\s+)\d+\.\d+\.\d+/, "@version$1" + CurrentVersion), "utf8"); console.warn("XMOJ.user.js has been updated."); diff --git a/XMOJ.user.js b/XMOJ.user.js index 6b87100c..aef69ff6 100644 --- a/XMOJ.user.js +++ b/XMOJ.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name XMOJ -// @version 2.2.0 +// @version 2.3.0 // @description XMOJ增强脚本 // @author @XMOJ-Script-dev, @langningchen and the community // @namespace https://github/langningchen @@ -444,7 +444,7 @@ let UtilityEnabled = (Name) => { let storeCredential = async (username, password) => { if ('credentials' in navigator && window.PasswordCredential) { try { - const credential = new PasswordCredential({ id: username, password: password }); + const credential = new PasswordCredential({id: username, password: password}); await navigator.credentials.store(credential); } catch (e) { console.error(e); @@ -454,7 +454,7 @@ let storeCredential = async (username, password) => { let getCredential = async () => { if ('credentials' in navigator && window.PasswordCredential) { try { - return await navigator.credentials.get({ password: true, mediation: 'optional' }); + return await navigator.credentials.get({password: true, mediation: 'optional'}); } catch (e) { console.error(e); } @@ -1513,7 +1513,7 @@ async function main() { FeedbackCardBody.className = "card-body"; let FeedbackCardText = document.createElement("p"); FeedbackCardText.className = "card-text"; - FeedbackCardText.innerText = "如果您有任何建议或者发现了bug,请前往本项目的GitHub页面并提交issue。提交issue前请先搜索是否有相同的issue,如果有请在该issue下留言。请在issue中尽可能详细地描述您的问题,并且附上您的浏览器版本、操作系统版本、脚本版本、复现步骤等信息。谢谢您支持本项目。"; + FeedbackCardText.innerText = "如果您有任何建议或者发现了 bug,请前往本项目的 GitHub 页面并提交 issue。提交 issue 前请先搜索是否有相同的 issue,如果有请在该 issue 下留言。请在 issue 中尽可能详细地描述您的问题,并且附上您的浏览器版本、操作系统版本、脚本版本、复现步骤等信息。谢谢您支持本项目。"; FeedbackCardBody.appendChild(FeedbackCardText); let FeedbackCardLink = document.createElement("a"); FeedbackCardLink.className = "card-link"; @@ -1627,8 +1627,9 @@ async function main() { }, 1000); } else { let PID = localStorage.getItem("UserScript-Contest-" + SearchParams.get("cid") + "-Problem-" + SearchParams.get("pid") + "-PID"); - - document.querySelector("body > div > div.mt-3 > center").lastChild.style.marginLeft = "10px"; + if (document.querySelector("body > div > div.mt-3 > center").lastElementChild !== null) { + document.querySelector("body > div > div.mt-3 > center").lastElementChild.style.marginLeft = "10px"; + } //修复提交按钮 let SubmitLink = document.querySelector('.mt-3 > center:nth-child(1) > a:nth-child(12)'); if (SubmitLink == null) { //a special type of problem diff --git a/package.json b/package.json index a37cf751..ce3e35b6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xmoj-script", - "version": "2.2.0", + "version": "2.3.0", "description": "an improvement script for xmoj.tech", "main": "AddonScript.js", "scripts": {