xmoj-script 2.4.7 → 2.5.2
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.
- package/Update.json +57 -0
- package/XMOJ.user.js +26 -23
- package/package.json +1 -1
package/Update.json
CHANGED
@@ -3157,6 +3157,63 @@
|
|
3157
3157
|
}
|
3158
3158
|
],
|
3159
3159
|
"Notes": "funny"
|
3160
|
+
},
|
3161
|
+
"2.5.0": {
|
3162
|
+
"UpdateDate": 1759568103629,
|
3163
|
+
"Prerelease": false,
|
3164
|
+
"UpdateContents": [
|
3165
|
+
{
|
3166
|
+
"PR": 861,
|
3167
|
+
"Description": "Update CSS selector"
|
3168
|
+
},
|
3169
|
+
{
|
3170
|
+
"PR": 863,
|
3171
|
+
"Description": "修复“NaN年前“"
|
3172
|
+
},
|
3173
|
+
{
|
3174
|
+
"PR": 865,
|
3175
|
+
"Description": "删除获取数据功能"
|
3176
|
+
},
|
3177
|
+
{
|
3178
|
+
"PR": 866,
|
3179
|
+
"Description": "比赛题目页面里左侧栏加入题目序号列表"
|
3180
|
+
},
|
3181
|
+
{
|
3182
|
+
"PR": 869,
|
3183
|
+
"Description": "Update CSS selector (again...)"
|
3184
|
+
},
|
3185
|
+
{
|
3186
|
+
"PR": 871,
|
3187
|
+
"Description": "Add tooltip for ProblemSwitcher"
|
3188
|
+
},
|
3189
|
+
{
|
3190
|
+
"PR": 872,
|
3191
|
+
"Description": "修复获取数据"
|
3192
|
+
}
|
3193
|
+
],
|
3194
|
+
"Notes": "XMOJ-Script 2.5.0 新增了比赛题目切换器,方便您在题目之间快速切换。此功能默认启用,您也可以在设置中禁用它。本版本还修复了一个导致时间显示为“NaN年前”的错误, 更新了一些 CSS selector,以适应 XMOJ 网站的最新变化."
|
3195
|
+
},
|
3196
|
+
"2.5.1": {
|
3197
|
+
"UpdateDate": 1759830659949,
|
3198
|
+
"Prerelease": true,
|
3199
|
+
"UpdateContents": [
|
3200
|
+
{
|
3201
|
+
"PR": 876,
|
3202
|
+
"Description": "refactor: simplify SubmitLink selection by querying all anchors and finding by text"
|
3203
|
+
}
|
3204
|
+
],
|
3205
|
+
"Notes": "No release notes were provided for this release."
|
3206
|
+
},
|
3207
|
+
"2.5.2": {
|
3208
|
+
"UpdateDate": 1759845614758,
|
3209
|
+
"Prerelease": true,
|
3210
|
+
"UpdateContents": [
|
3211
|
+
{
|
3212
|
+
"PR": 877,
|
3213
|
+
"Description": "fix: problem PID 可能为 null"
|
3214
|
+
}
|
3215
|
+
],
|
3216
|
+
"Notes": "No release notes were provided for this release."
|
3160
3217
|
}
|
3161
3218
|
}
|
3162
3219
|
}
|
package/XMOJ.user.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
// ==UserScript==
|
2
2
|
// @name XMOJ
|
3
|
-
// @version 2.
|
3
|
+
// @version 2.5.2
|
4
4
|
// @description XMOJ增强脚本
|
5
5
|
// @author @XMOJ-Script-dev, @langningchen and the community
|
6
6
|
// @namespace https://github/langningchen
|
@@ -1645,7 +1645,28 @@ async function main() {
|
|
1645
1645
|
} else if (location.pathname == "/problem.php") {
|
1646
1646
|
await RenderMathJax();
|
1647
1647
|
if (SearchParams.get("cid") != null && UtilityEnabled("ProblemSwitcher")) {
|
1648
|
-
|
1648
|
+
let pid = localStorage.getItem("UserScript-Contest-" + SearchParams.get("cid") + "-Problem-" + SearchParams.get("pid") + "-PID");
|
1649
|
+
if (!pid) {
|
1650
|
+
const contestReq = await fetch("https://www.xmoj.tech/contest.php?cid=" + SearchParams.get("cid"));
|
1651
|
+
const res = await contestReq.text();
|
1652
|
+
if (contestReq.status === 200 && res.indexOf("比赛尚未开始或私有,不能查看题目。") === -1) {
|
1653
|
+
const parser = new DOMParser();
|
1654
|
+
const dom = parser.parseFromString(res, "text/html");
|
1655
|
+
const rows = (dom.querySelector("#problemset > tbody")).rows;
|
1656
|
+
for (let i = 0; i < rows.length; i++) {
|
1657
|
+
let problemIdText = rows[i].children[1].innerText; // Get the text content
|
1658
|
+
let match = problemIdText.match(/\d+/); // Extract the number
|
1659
|
+
if (match) {
|
1660
|
+
let extractedPid = match[0];
|
1661
|
+
localStorage.setItem("UserScript-Contest-" + SearchParams.get("cid") + "-Problem-" + i + "-PID", extractedPid);
|
1662
|
+
}
|
1663
|
+
}
|
1664
|
+
pid = localStorage.getItem("UserScript-Contest-" + SearchParams.get("cid") + "-Problem-" + SearchParams.get("pid") + "-PID");
|
1665
|
+
}
|
1666
|
+
}
|
1667
|
+
if (pid) {
|
1668
|
+
document.getElementsByTagName("h2")[0].innerHTML += " (" + pid + ")";
|
1669
|
+
}
|
1649
1670
|
let ContestProblemList = localStorage.getItem("UserScript-Contest-" + SearchParams.get("cid") + "-ProblemList");
|
1650
1671
|
if (ContestProblemList == null) {
|
1651
1672
|
const contestReq = await fetch("https://www.xmoj.tech/contest.php?cid=" + SearchParams.get("cid"));
|
@@ -1710,25 +1731,8 @@ async function main() {
|
|
1710
1731
|
document.querySelector("body > div > div.mt-3 > center").lastElementChild.style.marginLeft = "10px";
|
1711
1732
|
}
|
1712
1733
|
//修复提交按钮
|
1713
|
-
|
1714
|
-
|
1715
|
-
SubmitLink = document.querySelector('.mt-3 > center:nth-child(1) > a:nth-child(10)');
|
1716
|
-
}
|
1717
|
-
if (SubmitLink == null) {
|
1718
|
-
SubmitLink = document.querySelector('.mt-3 > center:nth-child(1) > a:nth-child(11)');
|
1719
|
-
}
|
1720
|
-
if (SubmitLink == null) {
|
1721
|
-
SubmitLink = document.querySelector('.mt-3 > center:nth-child(1) > a:nth-child(13)');
|
1722
|
-
}
|
1723
|
-
if (SubmitLink == null) {
|
1724
|
-
SubmitLink = document.querySelector('.mt-3 > center:nth-child(1) > a:nth-child(9)');
|
1725
|
-
}
|
1726
|
-
if (SubmitLink == null) { //为什么这个破东西老是换位置
|
1727
|
-
SubmitLink = document.querySelector('.mt-3 > center:nth-child(1) > a:nth-child(7)');
|
1728
|
-
}
|
1729
|
-
if (SubmitLink == null) { //tmd又换位置
|
1730
|
-
SubmitLink = document.querySelector('.mt-3 > center:nth-child(1) > a:nth-child(8)');
|
1731
|
-
}
|
1734
|
+
const links = document.querySelectorAll('.mt-3 > center:nth-child(1) > a');
|
1735
|
+
const SubmitLink = Array.from(links).find(a => a.textContent.trim() === '提交');
|
1732
1736
|
let SubmitButton = document.createElement('button');
|
1733
1737
|
SubmitButton.id = 'SubmitButton';
|
1734
1738
|
SubmitButton.className = 'btn btn-outline-secondary';
|
@@ -1744,8 +1748,7 @@ async function main() {
|
|
1744
1748
|
// Remove the button's outer []
|
1745
1749
|
let str = document.querySelector('.mt-3 > center:nth-child(1)').innerHTML;
|
1746
1750
|
let target = SubmitButton.outerHTML;
|
1747
|
-
|
1748
|
-
document.querySelector('.mt-3 > center:nth-child(1)').innerHTML = result;
|
1751
|
+
document.querySelector('.mt-3 > center:nth-child(1)').innerHTML = str.replace(new RegExp(`(.?)${target}(.?)`, 'g'), target);
|
1749
1752
|
document.querySelector('html body.placeholder-glow div.container div.mt-3 center button#SubmitButton.btn.btn-outline-secondary').onclick = function () {
|
1750
1753
|
window.location.href = SubmitLink.href;
|
1751
1754
|
console.log(SubmitLink.href);
|