xmoj-script 2.4.3 → 2.4.5

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 CHANGED
@@ -3113,6 +3113,28 @@
3113
3113
  }
3114
3114
  ],
3115
3115
  "Notes": "因为它利用的bug被修复了"
3116
+ },
3117
+ "2.4.4": {
3118
+ "UpdateDate": 1759417362937,
3119
+ "Prerelease": true,
3120
+ "UpdateContents": [
3121
+ {
3122
+ "PR": 866,
3123
+ "Description": "比赛题目页面里左侧栏加入题目序号列表"
3124
+ }
3125
+ ],
3126
+ "Notes": "#860 ..."
3127
+ },
3128
+ "2.4.5": {
3129
+ "UpdateDate": 1759487413226,
3130
+ "Prerelease": true,
3131
+ "UpdateContents": [
3132
+ {
3133
+ "PR": 869,
3134
+ "Description": "Update CSS selector (again...)"
3135
+ }
3136
+ ],
3137
+ "Notes": "为什么这个破东西老是换位置"
3116
3138
  }
3117
3139
  }
3118
3140
  }
package/XMOJ.user.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // ==UserScript==
2
2
  // @name XMOJ
3
- // @version 2.4.3
3
+ // @version 2.4.5
4
4
  // @description XMOJ增强脚本
5
5
  // @author @XMOJ-Script-dev, @langningchen and the community
6
6
  // @namespace https://github/langningchen
@@ -1506,6 +1506,8 @@ async function main() {
1506
1506
  }, {
1507
1507
  "ID": "RefreshSolution", "Type": "F", "Name": "状态页面结果自动刷新每次只能刷新一个"
1508
1508
  }, {"ID": "CopyMD", "Type": "A", "Name": "复制题目或题解内容"}, {
1509
+ "ID": "ProblemSwitcher", "Type": "A", "Name": "比赛题目切换器"
1510
+ }, {
1509
1511
  "ID": "OpenAllProblem", "Type": "A", "Name": "比赛题目界面一键打开所有题目"
1510
1512
  }, {
1511
1513
  "ID": "CheckCode", "Type": "A", "Name": "提交代码前对代码进行检查", "Children": [{
@@ -1642,8 +1644,60 @@ async function main() {
1642
1644
  }
1643
1645
  } else if (location.pathname == "/problem.php") {
1644
1646
  await RenderMathJax();
1645
- if (SearchParams.get("cid") != null) {
1647
+ if (SearchParams.get("cid") != null && UtilityEnabled("ProblemSwitcher")) {
1646
1648
  document.getElementsByTagName("h2")[0].innerHTML += " (" + localStorage.getItem("UserScript-Contest-" + SearchParams.get("cid") + "-Problem-" + SearchParams.get("pid") + "-PID") + ")";
1649
+ let ContestProblemList = localStorage.getItem("UserScript-Contest-" + SearchParams.get("cid") + "-ProblemList");
1650
+ if (ContestProblemList == null) {
1651
+ const contestReq = await fetch("https://www.xmoj.tech/contest.php?cid=" + SearchParams.get("cid"));
1652
+ const res = await contestReq.text();
1653
+ if (contestReq.status === 200 && res.indexOf("比赛尚未开始或私有,不能查看题目。") === -1) {
1654
+ const parser = new DOMParser();
1655
+ const dom = parser.parseFromString(res, "text/html");
1656
+ const rows = (dom.querySelector("#problemset > tbody")).rows;
1657
+ let problemList = [];
1658
+ for (let i = 0; i < rows.length; i++) {
1659
+ problemList.push({
1660
+ "title": rows[i].children[2].innerText,
1661
+ "url": rows[i].children[2].children[0].href
1662
+ });
1663
+ }
1664
+ localStorage.setItem("UserScript-Contest-" + SearchParams.get("cid") + "-ProblemList", JSON.stringify(problemList));
1665
+ ContestProblemList = JSON.stringify(problemList);
1666
+ }
1667
+ }
1668
+
1669
+ let problemSwitcher = document.createElement("div");
1670
+ problemSwitcher.style.position = "fixed";
1671
+ problemSwitcher.style.top = "50%";
1672
+ problemSwitcher.style.left = "0";
1673
+ problemSwitcher.style.transform = "translateY(-50%)";
1674
+ problemSwitcher.style.maxHeight = "80vh";
1675
+ problemSwitcher.style.overflowY = "auto";
1676
+ if (document.querySelector("html").getAttribute("data-bs-theme") == "dark") {
1677
+ problemSwitcher.style.backgroundColor = "rgba(0, 0, 0, 0.8)";
1678
+ } else {
1679
+ problemSwitcher.style.backgroundColor = "rgba(255, 255, 255, 0.8)";
1680
+ }
1681
+ problemSwitcher.style.padding = "10px";
1682
+ problemSwitcher.style.borderRadius = "0 10px 10px 0";
1683
+ problemSwitcher.style.display = "flex";
1684
+ problemSwitcher.style.flexDirection = "column";
1685
+
1686
+ let problemList = JSON.parse(ContestProblemList);
1687
+ for (let i = 0; i < problemList.length; i++) {
1688
+ let buttonText = "";
1689
+ if (i < 26) {
1690
+ buttonText = String.fromCharCode(65 + i);
1691
+ } else {
1692
+ buttonText = String.fromCharCode(97 + (i - 26));
1693
+ }
1694
+ let activeClass = "";
1695
+ if (problemList[i].url === location.href) {
1696
+ activeClass = "active";
1697
+ }
1698
+ problemSwitcher.innerHTML += `<a href="${problemList[i].url}" class="btn btn-outline-secondary mb-2 ${activeClass}">${buttonText}</a>`;
1699
+ }
1700
+ document.body.appendChild(problemSwitcher);
1647
1701
  }
1648
1702
  if (document.querySelector("body > div > div.mt-3 > h2") != null) {
1649
1703
  document.querySelector("body > div > div.mt-3").innerHTML = "没有此题目或题目对你不可见";
@@ -1672,6 +1726,9 @@ async function main() {
1672
1726
  if (SubmitLink == null) { //为什么这个破东西老是换位置
1673
1727
  SubmitLink = document.querySelector('.mt-3 > center:nth-child(1) > a:nth-child(7)');
1674
1728
  }
1729
+ if (SubmitLink == null) { //tmd又换位置
1730
+ SubmitLink = document.querySelector('.mt-3 > center:nth-child(1) > a:nth-child(8)');
1731
+ }
1675
1732
  let SubmitButton = document.createElement('button');
1676
1733
  SubmitButton.id = 'SubmitButton';
1677
1734
  SubmitButton.className = 'btn btn-outline-secondary';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xmoj-script",
3
- "version": "2.4.3",
3
+ "version": "2.4.5",
4
4
  "description": "an improvement script for xmoj.tech",
5
5
  "main": "AddonScript.js",
6
6
  "scripts": {