Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: 综合 Bug 反馈
description: 有功能有问题
labels: bug, needs-triage
type: Bug
# assignees: PythonSmall-Q, boomzero, shihongxi
title: "[Bug]"
body:
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/docs.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: 帮助文档反馈
description: 帮助文档有问题
labels: docs, needs-triage
type: Task
title: "[Docs]"
body:
- type: checkboxes
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/feature.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: 新功能提案
description: 对已有功能的大幅度修改,或添加一个新内容或选项
labels: enhancement, needs-triage
type: Feature
#assignees: PythonSmall-Q, boomzero, shihongxi
title: "[Feature Request]"
body:
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/UpdateToRelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
- opened
- reopened
- synchronize
- edited
branches:
- master
jobs:
Expand All @@ -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 }}
4 changes: 3 additions & 1 deletion .github/workflows/UpdateVersion.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<!-- release-notes` and ending with `-->` in the PR description. The automation will extract that block into the release notes.
37 changes: 37 additions & 0 deletions Update.json
Original file line number Diff line number Diff line change
Expand Up @@ -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("
}
}
}
10 changes: 9 additions & 1 deletion Update/UpdateToRelease.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(/<!--\s*release[- ]notes\s*([\s\S]*?)-->/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.");
Expand Down Expand Up @@ -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.");
Expand All @@ -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--) {
Expand Down
13 changes: 12 additions & 1 deletion Update/UpdateVersion.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(/<!--\s*release[- ]notes\s*([\s\S]*?)-->/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)) {
Expand All @@ -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(", "));
Expand All @@ -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.");
Expand All @@ -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.");
Expand Down
13 changes: 7 additions & 6 deletions XMOJ.user.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -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);
}
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
Loading