Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
dcea068
Update CSS selector
boomzero Oct 2, 2025
081f7f3
2.4.1
github-actions[bot] Oct 2, 2025
d0f4549
Update version info to 2.4.1
github-actions[bot] Oct 2, 2025
d49fcdc
Merge pull request #861 from XMOJ-Script-dev/boomzero/selupd
boomzero Oct 2, 2025
249456f
修复“NaN年前“
boomzero Oct 2, 2025
7841538
2.4.2
github-actions[bot] Oct 2, 2025
6b6ffe0
Update version info to 2.4.2
github-actions[bot] Oct 2, 2025
13831f4
Merge pull request #863 from XMOJ-Script-dev/boomzero/NaN
boomzero Oct 2, 2025
3b4873f
删除获取数据功能
boomzero Oct 2, 2025
037a14e
2.4.3
github-actions[bot] Oct 2, 2025
d5a6690
Update version info to 2.4.3
github-actions[bot] Oct 2, 2025
6e920c5
Merge pull request #865 from XMOJ-Script-dev/boomzero/rmAD
boomzero Oct 2, 2025
565b959
比赛题目页面里左侧栏加入题目序号列表(#860)
boomzero Oct 2, 2025
44821f1
Make this feature disableable
boomzero Oct 2, 2025
1f71aa8
2.4.4
github-actions[bot] Oct 2, 2025
0955311
Update version info to 2.4.4
github-actions[bot] Oct 2, 2025
491d3b6
Merge pull request #866 from XMOJ-Script-dev/boomzero/quickps
boomzero Oct 2, 2025
e6ca3d7
Update CSS selector (#868)
boomzero Oct 3, 2025
a6d9d06
2.4.5
github-actions[bot] Oct 3, 2025
7686431
Update version info to 2.4.5
github-actions[bot] Oct 3, 2025
a015b5d
Merge pull request #869 from XMOJ-Script-dev/boomzero/cssSel
boomzero Oct 3, 2025
84054aa
Add tooltip for ProblemSwitcher
boomzero Oct 4, 2025
a0727e2
2.4.6
github-actions[bot] Oct 4, 2025
822bb4d
Update version info to 2.4.6
github-actions[bot] Oct 4, 2025
022040b
Merge pull request #871 from XMOJ-Script-dev/boomzero/cstooltip
boomzero Oct 4, 2025
4aaa1a3
Revert "删除获取数据功能"
boomzero Oct 4, 2025
1d8db8b
修复获取数据
boomzero Oct 4, 2025
b297b71
2.4.7
github-actions[bot] Oct 4, 2025
eef02d8
Update version info to 2.4.7
github-actions[bot] Oct 4, 2025
2d55f9a
Merge pull request #872 from XMOJ-Script-dev/boomzero/getData
boomzero Oct 4, 2025
ef32bc9
2.5.0
github-actions[bot] Oct 4, 2025
a33be0b
Update to release 2.5.0
github-actions[bot] Oct 4, 2025
d299080
Merge pull request #875 from XMOJ-Script-dev/actions/temp
github-actions[bot] Oct 4, 2025
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
112 changes: 112 additions & 0 deletions Update.json
Original file line number Diff line number Diff line change
Expand Up @@ -3080,6 +3080,118 @@
}
],
"Notes": "请尽快升级至本版本!"
},
"2.4.1": {
"UpdateDate": 1759412851092,
"Prerelease": true,
"UpdateContents": [
{
"PR": 861,
"Description": "Update CSS selector"
}
],
"Notes": "No release notes were provided for this release."
},
"2.4.2": {
"UpdateDate": 1759413584731,
"Prerelease": true,
"UpdateContents": [
{
"PR": 863,
"Description": "修复“NaN年前“"
}
],
"Notes": "修复“NaN年前“"
},
"2.4.3": {
"UpdateDate": 1759414259108,
"Prerelease": true,
"UpdateContents": [
{
"PR": 865,
"Description": "删除获取数据功能"
}
],
"Notes": "因为它利用的bug被修复了"
},
"2.4.4": {
"UpdateDate": 1759417362937,
"Prerelease": true,
"UpdateContents": [
{
"PR": 866,
"Description": "比赛题目页面里左侧栏加入题目序号列表"
}
],
"Notes": "#860 ..."
},
"2.4.5": {
"UpdateDate": 1759487413226,
"Prerelease": true,
"UpdateContents": [
{
"PR": 869,
"Description": "Update CSS selector (again...)"
}
],
"Notes": "为什么这个破东西老是换位置"
},
"2.4.6": {
"UpdateDate": 1759548958578,
"Prerelease": true,
"UpdateContents": [
{
"PR": 871,
"Description": "Add tooltip for ProblemSwitcher"
}
],
"Notes": "现在, 你只需要将鼠标悬浮在比赛题目切换器上方, 即可查看题目名称"
},
"2.4.7": {
"UpdateDate": 1759549826774,
"Prerelease": true,
"UpdateContents": [
{
"PR": 872,
"Description": "修复获取数据"
}
],
"Notes": "funny"
},
"2.5.0": {
"UpdateDate": 1759568103629,
"Prerelease": false,
"UpdateContents": [
{
"PR": 861,
"Description": "Update CSS selector"
},
{
"PR": 863,
"Description": "修复“NaN年前“"
},
{
"PR": 865,
"Description": "删除获取数据功能"
},
{
"PR": 866,
"Description": "比赛题目页面里左侧栏加入题目序号列表"
},
{
"PR": 869,
"Description": "Update CSS selector (again...)"
},
{
"PR": 871,
"Description": "Add tooltip for ProblemSwitcher"
},
{
"PR": 872,
"Description": "修复获取数据"
}
],
"Notes": "XMOJ-Script 2.5.0 新增了比赛题目切换器,方便您在题目之间快速切换。此功能默认启用,您也可以在设置中禁用它。本版本还修复了一个导致时间显示为“NaN年前”的错误, 更新了一些 CSS selector,以适应 XMOJ 网站的最新变化."
}
}
}
68 changes: 64 additions & 4 deletions XMOJ.user.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ==UserScript==
// @name XMOJ
// @version 2.4.0
// @version 2.5.0
// @description XMOJ增强脚本
// @author @XMOJ-Script-dev, @langningchen and the community
// @namespace https://github/langningchen
Expand Down Expand Up @@ -81,7 +81,7 @@ let SmartAlert = (Message) => {
*/
let GetRelativeTime = (Input) => {
try {
Input = new Date(Input);
Input = new Date(parseInt(Input));
let Now = new Date().getTime();
let Delta = Now - Input.getTime();
let RelativeName = "";
Expand Down Expand Up @@ -1506,6 +1506,8 @@ async function main() {
}, {
"ID": "RefreshSolution", "Type": "F", "Name": "状态页面结果自动刷新每次只能刷新一个"
}, {"ID": "CopyMD", "Type": "A", "Name": "复制题目或题解内容"}, {
"ID": "ProblemSwitcher", "Type": "A", "Name": "比赛题目切换器"
}, {
"ID": "OpenAllProblem", "Type": "A", "Name": "比赛题目界面一键打开所有题目"
}, {
"ID": "CheckCode", "Type": "A", "Name": "提交代码前对代码进行检查", "Children": [{
Expand Down Expand Up @@ -1642,8 +1644,60 @@ async function main() {
}
} else if (location.pathname == "/problem.php") {
await RenderMathJax();
if (SearchParams.get("cid") != null) {
if (SearchParams.get("cid") != null && UtilityEnabled("ProblemSwitcher")) {
document.getElementsByTagName("h2")[0].innerHTML += " (" + localStorage.getItem("UserScript-Contest-" + SearchParams.get("cid") + "-Problem-" + SearchParams.get("pid") + "-PID") + ")";
let ContestProblemList = localStorage.getItem("UserScript-Contest-" + SearchParams.get("cid") + "-ProblemList");
if (ContestProblemList == null) {
const contestReq = await fetch("https://www.xmoj.tech/contest.php?cid=" + SearchParams.get("cid"));
const res = await contestReq.text();
if (contestReq.status === 200 && res.indexOf("比赛尚未开始或私有,不能查看题目。") === -1) {
const parser = new DOMParser();
const dom = parser.parseFromString(res, "text/html");
const rows = (dom.querySelector("#problemset > tbody")).rows;
let problemList = [];
for (let i = 0; i < rows.length; i++) {
problemList.push({
"title": rows[i].children[2].innerText,
"url": rows[i].children[2].children[0].href
});
}
localStorage.setItem("UserScript-Contest-" + SearchParams.get("cid") + "-ProblemList", JSON.stringify(problemList));
ContestProblemList = JSON.stringify(problemList);
}
}

let problemSwitcher = document.createElement("div");
problemSwitcher.style.position = "fixed";
problemSwitcher.style.top = "50%";
problemSwitcher.style.left = "0";
problemSwitcher.style.transform = "translateY(-50%)";
problemSwitcher.style.maxHeight = "80vh";
problemSwitcher.style.overflowY = "auto";
if (document.querySelector("html").getAttribute("data-bs-theme") == "dark") {
problemSwitcher.style.backgroundColor = "rgba(0, 0, 0, 0.8)";
} else {
problemSwitcher.style.backgroundColor = "rgba(255, 255, 255, 0.8)";
}
problemSwitcher.style.padding = "10px";
problemSwitcher.style.borderRadius = "0 10px 10px 0";
problemSwitcher.style.display = "flex";
problemSwitcher.style.flexDirection = "column";

let problemList = JSON.parse(ContestProblemList);
for (let i = 0; i < problemList.length; i++) {
let buttonText = "";
if (i < 26) {
buttonText = String.fromCharCode(65 + i);
} else {
buttonText = String.fromCharCode(97 + (i - 26));
}
let activeClass = "";
if (problemList[i].url === location.href) {
activeClass = "active";
}
problemSwitcher.innerHTML += `<a href="${problemList[i].url}" title="${problemList[i].title.trim()}" class="btn btn-outline-secondary mb-2 ${activeClass}">${buttonText}</a>`;
}
document.body.appendChild(problemSwitcher);
}
if (document.querySelector("body > div > div.mt-3 > h2") != null) {
document.querySelector("body > div > div.mt-3").innerHTML = "没有此题目或题目对你不可见";
Expand All @@ -1669,6 +1723,12 @@ async function main() {
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)');
}
let SubmitButton = document.createElement('button');
SubmitButton.id = 'SubmitButton';
SubmitButton.className = 'btn btn-outline-secondary';
Expand Down Expand Up @@ -3470,7 +3530,7 @@ int main()
break;
Input.push_back(Data);
}
throw runtime_error("[" + Base64Encode(Input.c_str()) + "]");
throw logic_error("[" + Base64Encode(Input.c_str()) + "]");
return 0;
}`;

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.4.0",
"version": "2.5.0",
"description": "an improvement script for xmoj.tech",
"main": "AddonScript.js",
"scripts": {
Expand Down