From aaca082e5294e9368ef1fed0ea9f707478f251f0 Mon Sep 17 00:00:00 2001 From: boomzero Date: Tue, 7 Oct 2025 17:47:01 +0800 Subject: [PATCH 1/3] refactor: simplify SubmitLink selection by querying all anchors and finding by text MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 一下子解决所有问题... --- XMOJ.user.js | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/XMOJ.user.js b/XMOJ.user.js index 9382516b..4922a41a 100644 --- a/XMOJ.user.js +++ b/XMOJ.user.js @@ -1710,25 +1710,8 @@ async function main() { 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 - SubmitLink = document.querySelector('.mt-3 > center:nth-child(1) > a:nth-child(10)'); - } - if (SubmitLink == null) { - SubmitLink = document.querySelector('.mt-3 > center:nth-child(1) > a:nth-child(11)'); - } - if (SubmitLink == null) { - SubmitLink = document.querySelector('.mt-3 > center:nth-child(1) > a:nth-child(13)'); - } - if (SubmitLink == null) { - SubmitLink = document.querySelector('.mt-3 > center:nth-child(1) > a:nth-child(9)'); - } - if (SubmitLink == null) { //为什么这个破东西老是换位置 - SubmitLink = document.querySelector('.mt-3 > center:nth-child(1) > a:nth-child(7)'); - } - if (SubmitLink == null) { //tmd又换位置 - SubmitLink = document.querySelector('.mt-3 > center:nth-child(1) > a:nth-child(8)'); - } + const links = document.querySelectorAll('.mt-3 > center:nth-child(1) > a'); + const SubmitLink = Array.from(links).find(a => a.textContent.trim() === '提交'); let SubmitButton = document.createElement('button'); SubmitButton.id = 'SubmitButton'; SubmitButton.className = 'btn btn-outline-secondary'; From 68ce710d66c065d447e5abc42dcbaaa2db45669e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 7 Oct 2025 09:50:59 +0000 Subject: [PATCH 2/3] 2.5.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b0598518..7dc97daa 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xmoj-script", - "version": "2.5.0", + "version": "2.5.1", "description": "an improvement script for xmoj.tech", "main": "AddonScript.js", "scripts": { From 0ca934fc4dbda92370eca3043a47b64def8787ce Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 7 Oct 2025 09:51:05 +0000 Subject: [PATCH 3/3] Update version info to 2.5.1 --- Update.json | 11 +++++++++++ XMOJ.user.js | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Update.json b/Update.json index 7c45a663..127f787f 100644 --- a/Update.json +++ b/Update.json @@ -3192,6 +3192,17 @@ } ], "Notes": "XMOJ-Script 2.5.0 新增了比赛题目切换器,方便您在题目之间快速切换。此功能默认启用,您也可以在设置中禁用它。本版本还修复了一个导致时间显示为“NaN年前”的错误, 更新了一些 CSS selector,以适应 XMOJ 网站的最新变化." + }, + "2.5.1": { + "UpdateDate": 1759830659949, + "Prerelease": true, + "UpdateContents": [ + { + "PR": 876, + "Description": "refactor: simplify SubmitLink selection by querying all anchors and finding by text" + } + ], + "Notes": "No release notes were provided for this release." } } } \ No newline at end of file diff --git a/XMOJ.user.js b/XMOJ.user.js index 4922a41a..cf08940d 100644 --- a/XMOJ.user.js +++ b/XMOJ.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name XMOJ -// @version 2.5.0 +// @version 2.5.1 // @description XMOJ增强脚本 // @author @XMOJ-Script-dev, @langningchen and the community // @namespace https://github/langningchen