xmoj-script 2.4.6 → 2.5.1
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 +119 -21
- package/package.json +1 -1
package/Update.json
CHANGED
@@ -3146,6 +3146,63 @@
|
|
3146
3146
|
}
|
3147
3147
|
],
|
3148
3148
|
"Notes": "现在, 你只需要将鼠标悬浮在比赛题目切换器上方, 即可查看题目名称"
|
3149
|
+
},
|
3150
|
+
"2.4.7": {
|
3151
|
+
"UpdateDate": 1759549826774,
|
3152
|
+
"Prerelease": true,
|
3153
|
+
"UpdateContents": [
|
3154
|
+
{
|
3155
|
+
"PR": 872,
|
3156
|
+
"Description": "修复获取数据"
|
3157
|
+
}
|
3158
|
+
],
|
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."
|
3149
3206
|
}
|
3150
3207
|
}
|
3151
3208
|
}
|
package/XMOJ.user.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
// ==UserScript==
|
2
2
|
// @name XMOJ
|
3
|
-
// @version 2.
|
3
|
+
// @version 2.5.1
|
4
4
|
// @description XMOJ增强脚本
|
5
5
|
// @author @XMOJ-Script-dev, @langningchen and the community
|
6
6
|
// @namespace https://github/langningchen
|
@@ -1469,7 +1469,7 @@ async function main() {
|
|
1469
1469
|
"Name": "恢复讨论与短消息功能"
|
1470
1470
|
}, {
|
1471
1471
|
"ID": "MoreSTD", "Type": "F", "Name": "查看到更多标程"
|
1472
|
-
},
|
1472
|
+
}, {"ID": "ApplyData", "Type": "A", "Name": "获取数据功能"}, {
|
1473
1473
|
"ID": "AutoCheat", "Type": "A", "Name": "自动提交当年代码"
|
1474
1474
|
}, {"ID": "Rating", "Type": "A", "Name": "添加用户评分和用户名颜色"}, {
|
1475
1475
|
"ID": "AutoRefresh", "Type": "A", "Name": "比赛列表、比赛排名界面自动刷新"
|
@@ -1710,25 +1710,8 @@ async function main() {
|
|
1710
1710
|
document.querySelector("body > div > div.mt-3 > center").lastElementChild.style.marginLeft = "10px";
|
1711
1711
|
}
|
1712
1712
|
//修复提交按钮
|
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
|
-
}
|
1713
|
+
const links = document.querySelectorAll('.mt-3 > center:nth-child(1) > a');
|
1714
|
+
const SubmitLink = Array.from(links).find(a => a.textContent.trim() === '提交');
|
1732
1715
|
let SubmitButton = document.createElement('button');
|
1733
1716
|
SubmitButton.id = 'SubmitButton';
|
1734
1717
|
SubmitButton.className = 'btn btn-outline-secondary';
|
@@ -3477,6 +3460,121 @@ async function main() {
|
|
3477
3460
|
if (document.getElementById("apply_data")) {
|
3478
3461
|
let ApplyDiv = document.getElementById("apply_data").parentElement;
|
3479
3462
|
console.log("启动!!!");
|
3463
|
+
if (UtilityEnabled("ApplyData")) {
|
3464
|
+
let GetDataButton = document.createElement("button");
|
3465
|
+
GetDataButton.className = "ms-2 btn btn-outline-secondary";
|
3466
|
+
GetDataButton.innerText = "获取数据";
|
3467
|
+
console.log("按钮创建成功");
|
3468
|
+
ApplyDiv.appendChild(GetDataButton);
|
3469
|
+
GetDataButton.addEventListener("click", async () => {
|
3470
|
+
GetDataButton.disabled = true;
|
3471
|
+
GetDataButton.innerText = "正在获取数据...";
|
3472
|
+
let PID = localStorage.getItem("UserScript-Solution-" + SearchParams.get("sid") + "-Problem");
|
3473
|
+
if (PID == null) {
|
3474
|
+
GetDataButton.innerText = "失败! 无法获取PID";
|
3475
|
+
GetDataButton.disabled = false;
|
3476
|
+
await new Promise((resolve) => {
|
3477
|
+
setTimeout(resolve, 800);
|
3478
|
+
});
|
3479
|
+
GetDataButton.innerText = "获取数据";
|
3480
|
+
return;
|
3481
|
+
}
|
3482
|
+
let Code = "";
|
3483
|
+
if (localStorage.getItem(`UserScript-Problem-${PID}-IOFilename`) !== null) {
|
3484
|
+
Code = `#define IOFile "${localStorage.getItem(`UserScript-Problem-${PID}-IOFilename`)}"\n`;
|
3485
|
+
}
|
3486
|
+
Code += `//XMOJ-Script 获取数据代码
|
3487
|
+
#include <bits/stdc++.h>
|
3488
|
+
using namespace std;
|
3489
|
+
string Base64Encode(string Input)
|
3490
|
+
{
|
3491
|
+
const string Base64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
3492
|
+
string Output;
|
3493
|
+
for (int i = 0; i < Input.length(); i += 3)
|
3494
|
+
{
|
3495
|
+
Output.push_back(i + 0 > Input.length() ? '=' : Base64Chars[(Input[i + 0] & 0xfc) >> 2]);
|
3496
|
+
Output.push_back(i + 1 > Input.length() ? '=' : Base64Chars[((Input[i + 0] & 0x03) << 4) + ((Input[i + 1] & 0xf0) >> 4)]);
|
3497
|
+
Output.push_back(i + 2 > Input.length() ? '=' : Base64Chars[((Input[i + 1] & 0x0f) << 2) + ((Input[i + 2] & 0xc0) >> 6)]);
|
3498
|
+
Output.push_back(i + 3 > Input.length() ? '=' : Base64Chars[Input[i + 2] & 0x3f]);
|
3499
|
+
}
|
3500
|
+
return Output;
|
3501
|
+
}
|
3502
|
+
int main()
|
3503
|
+
{
|
3504
|
+
#ifdef IOFile
|
3505
|
+
freopen(IOFile ".in", "r", stdin);
|
3506
|
+
freopen(IOFile ".out", "w", stdout);
|
3507
|
+
#endif
|
3508
|
+
string Input;
|
3509
|
+
while (1)
|
3510
|
+
{
|
3511
|
+
char Data = getchar();
|
3512
|
+
if (Data == EOF)
|
3513
|
+
break;
|
3514
|
+
Input.push_back(Data);
|
3515
|
+
}
|
3516
|
+
throw logic_error("[" + Base64Encode(Input.c_str()) + "]");
|
3517
|
+
return 0;
|
3518
|
+
}`;
|
3519
|
+
|
3520
|
+
await fetch("https://www.xmoj.tech/submit.php", {
|
3521
|
+
"headers": {
|
3522
|
+
"content-type": "application/x-www-form-urlencoded"
|
3523
|
+
},
|
3524
|
+
"referrer": "https://www.xmoj.tech/submitpage.php?id=" + PID,
|
3525
|
+
"method": "POST",
|
3526
|
+
"body": "id=" + PID + "&" + "language=1&" + "source=" + encodeURIComponent(Code) + "&" + "enable_O2=on"
|
3527
|
+
});
|
3528
|
+
|
3529
|
+
let SID = await fetch("https://www.xmoj.tech/status.php").then((Response) => {
|
3530
|
+
return Response.text();
|
3531
|
+
}).then((Response) => {
|
3532
|
+
let ParsedDocument = new DOMParser().parseFromString(Response, "text/html");
|
3533
|
+
return ParsedDocument.querySelector("#result-tab > tbody > tr:nth-child(1) > td:nth-child(2)").innerText;
|
3534
|
+
});
|
3535
|
+
|
3536
|
+
await new Promise((Resolve) => {
|
3537
|
+
let Interval = setInterval(async () => {
|
3538
|
+
await fetch("status-ajax.php?solution_id=" + SID).then((Response) => {
|
3539
|
+
return Response.text();
|
3540
|
+
}).then((Response) => {
|
3541
|
+
if (Response.split(",")[0] >= 4) {
|
3542
|
+
clearInterval(Interval);
|
3543
|
+
Resolve();
|
3544
|
+
}
|
3545
|
+
});
|
3546
|
+
}, 500);
|
3547
|
+
});
|
3548
|
+
|
3549
|
+
await fetch(`https://www.xmoj.tech/reinfo.php?sid=${SID}`).then((Response) => {
|
3550
|
+
return Response.text();
|
3551
|
+
}).then((Response) => {
|
3552
|
+
let ParsedDocument = new DOMParser().parseFromString(Response, "text/html");
|
3553
|
+
let ErrorData = ParsedDocument.getElementById("errtxt").innerText;
|
3554
|
+
let MatchResult = ErrorData.match(/\what\(\): \[([A-Za-z0-9+\/=]+)\]/g);
|
3555
|
+
if (MatchResult === null) {
|
3556
|
+
GetDataButton.innerText = "获取数据失败";
|
3557
|
+
GetDataButton.disabled = false;
|
3558
|
+
return;
|
3559
|
+
}
|
3560
|
+
for (let i = 0; i < MatchResult.length; i++) {
|
3561
|
+
let Data = CryptoJS.enc.Base64.parse(MatchResult[i].substring(10, MatchResult[i].length - 1)).toString(CryptoJS.enc.Utf8);
|
3562
|
+
ApplyDiv.appendChild(document.createElement("hr"));
|
3563
|
+
ApplyDiv.appendChild(document.createTextNode("数据" + (i + 1) + ":"));
|
3564
|
+
let CodeElement = document.createElement("div");
|
3565
|
+
ApplyDiv.appendChild(CodeElement);
|
3566
|
+
CodeMirror(CodeElement, {
|
3567
|
+
value: Data,
|
3568
|
+
theme: (UtilityEnabled("DarkMode") ? "darcula" : "default"),
|
3569
|
+
lineNumbers: true,
|
3570
|
+
readOnly: true
|
3571
|
+
}).setSize("100%", "auto");
|
3572
|
+
}
|
3573
|
+
GetDataButton.innerText = "获取数据成功";
|
3574
|
+
GetDataButton.disabled = false;
|
3575
|
+
});
|
3576
|
+
});
|
3577
|
+
}
|
3480
3578
|
document.getElementById("apply_data").addEventListener("click", () => {
|
3481
3579
|
let ApplyElements = document.getElementsByClassName("data");
|
3482
3580
|
for (let i = 0; i < ApplyElements.length; i++) {
|