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 9382516b..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 @@ -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'; 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": {