xmoj-script 2.4.6 → 2.4.7
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 +11 -0
- package/XMOJ.user.js +117 -2
- package/package.json +1 -1
package/Update.json
CHANGED
@@ -3146,6 +3146,17 @@
|
|
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"
|
3149
3160
|
}
|
3150
3161
|
}
|
3151
3162
|
}
|
package/XMOJ.user.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
// ==UserScript==
|
2
2
|
// @name XMOJ
|
3
|
-
// @version 2.4.
|
3
|
+
// @version 2.4.7
|
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": "比赛列表、比赛排名界面自动刷新"
|
@@ -3477,6 +3477,121 @@ async function main() {
|
|
3477
3477
|
if (document.getElementById("apply_data")) {
|
3478
3478
|
let ApplyDiv = document.getElementById("apply_data").parentElement;
|
3479
3479
|
console.log("启动!!!");
|
3480
|
+
if (UtilityEnabled("ApplyData")) {
|
3481
|
+
let GetDataButton = document.createElement("button");
|
3482
|
+
GetDataButton.className = "ms-2 btn btn-outline-secondary";
|
3483
|
+
GetDataButton.innerText = "获取数据";
|
3484
|
+
console.log("按钮创建成功");
|
3485
|
+
ApplyDiv.appendChild(GetDataButton);
|
3486
|
+
GetDataButton.addEventListener("click", async () => {
|
3487
|
+
GetDataButton.disabled = true;
|
3488
|
+
GetDataButton.innerText = "正在获取数据...";
|
3489
|
+
let PID = localStorage.getItem("UserScript-Solution-" + SearchParams.get("sid") + "-Problem");
|
3490
|
+
if (PID == null) {
|
3491
|
+
GetDataButton.innerText = "失败! 无法获取PID";
|
3492
|
+
GetDataButton.disabled = false;
|
3493
|
+
await new Promise((resolve) => {
|
3494
|
+
setTimeout(resolve, 800);
|
3495
|
+
});
|
3496
|
+
GetDataButton.innerText = "获取数据";
|
3497
|
+
return;
|
3498
|
+
}
|
3499
|
+
let Code = "";
|
3500
|
+
if (localStorage.getItem(`UserScript-Problem-${PID}-IOFilename`) !== null) {
|
3501
|
+
Code = `#define IOFile "${localStorage.getItem(`UserScript-Problem-${PID}-IOFilename`)}"\n`;
|
3502
|
+
}
|
3503
|
+
Code += `//XMOJ-Script 获取数据代码
|
3504
|
+
#include <bits/stdc++.h>
|
3505
|
+
using namespace std;
|
3506
|
+
string Base64Encode(string Input)
|
3507
|
+
{
|
3508
|
+
const string Base64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
3509
|
+
string Output;
|
3510
|
+
for (int i = 0; i < Input.length(); i += 3)
|
3511
|
+
{
|
3512
|
+
Output.push_back(i + 0 > Input.length() ? '=' : Base64Chars[(Input[i + 0] & 0xfc) >> 2]);
|
3513
|
+
Output.push_back(i + 1 > Input.length() ? '=' : Base64Chars[((Input[i + 0] & 0x03) << 4) + ((Input[i + 1] & 0xf0) >> 4)]);
|
3514
|
+
Output.push_back(i + 2 > Input.length() ? '=' : Base64Chars[((Input[i + 1] & 0x0f) << 2) + ((Input[i + 2] & 0xc0) >> 6)]);
|
3515
|
+
Output.push_back(i + 3 > Input.length() ? '=' : Base64Chars[Input[i + 2] & 0x3f]);
|
3516
|
+
}
|
3517
|
+
return Output;
|
3518
|
+
}
|
3519
|
+
int main()
|
3520
|
+
{
|
3521
|
+
#ifdef IOFile
|
3522
|
+
freopen(IOFile ".in", "r", stdin);
|
3523
|
+
freopen(IOFile ".out", "w", stdout);
|
3524
|
+
#endif
|
3525
|
+
string Input;
|
3526
|
+
while (1)
|
3527
|
+
{
|
3528
|
+
char Data = getchar();
|
3529
|
+
if (Data == EOF)
|
3530
|
+
break;
|
3531
|
+
Input.push_back(Data);
|
3532
|
+
}
|
3533
|
+
throw logic_error("[" + Base64Encode(Input.c_str()) + "]");
|
3534
|
+
return 0;
|
3535
|
+
}`;
|
3536
|
+
|
3537
|
+
await fetch("https://www.xmoj.tech/submit.php", {
|
3538
|
+
"headers": {
|
3539
|
+
"content-type": "application/x-www-form-urlencoded"
|
3540
|
+
},
|
3541
|
+
"referrer": "https://www.xmoj.tech/submitpage.php?id=" + PID,
|
3542
|
+
"method": "POST",
|
3543
|
+
"body": "id=" + PID + "&" + "language=1&" + "source=" + encodeURIComponent(Code) + "&" + "enable_O2=on"
|
3544
|
+
});
|
3545
|
+
|
3546
|
+
let SID = await fetch("https://www.xmoj.tech/status.php").then((Response) => {
|
3547
|
+
return Response.text();
|
3548
|
+
}).then((Response) => {
|
3549
|
+
let ParsedDocument = new DOMParser().parseFromString(Response, "text/html");
|
3550
|
+
return ParsedDocument.querySelector("#result-tab > tbody > tr:nth-child(1) > td:nth-child(2)").innerText;
|
3551
|
+
});
|
3552
|
+
|
3553
|
+
await new Promise((Resolve) => {
|
3554
|
+
let Interval = setInterval(async () => {
|
3555
|
+
await fetch("status-ajax.php?solution_id=" + SID).then((Response) => {
|
3556
|
+
return Response.text();
|
3557
|
+
}).then((Response) => {
|
3558
|
+
if (Response.split(",")[0] >= 4) {
|
3559
|
+
clearInterval(Interval);
|
3560
|
+
Resolve();
|
3561
|
+
}
|
3562
|
+
});
|
3563
|
+
}, 500);
|
3564
|
+
});
|
3565
|
+
|
3566
|
+
await fetch(`https://www.xmoj.tech/reinfo.php?sid=${SID}`).then((Response) => {
|
3567
|
+
return Response.text();
|
3568
|
+
}).then((Response) => {
|
3569
|
+
let ParsedDocument = new DOMParser().parseFromString(Response, "text/html");
|
3570
|
+
let ErrorData = ParsedDocument.getElementById("errtxt").innerText;
|
3571
|
+
let MatchResult = ErrorData.match(/\what\(\): \[([A-Za-z0-9+\/=]+)\]/g);
|
3572
|
+
if (MatchResult === null) {
|
3573
|
+
GetDataButton.innerText = "获取数据失败";
|
3574
|
+
GetDataButton.disabled = false;
|
3575
|
+
return;
|
3576
|
+
}
|
3577
|
+
for (let i = 0; i < MatchResult.length; i++) {
|
3578
|
+
let Data = CryptoJS.enc.Base64.parse(MatchResult[i].substring(10, MatchResult[i].length - 1)).toString(CryptoJS.enc.Utf8);
|
3579
|
+
ApplyDiv.appendChild(document.createElement("hr"));
|
3580
|
+
ApplyDiv.appendChild(document.createTextNode("数据" + (i + 1) + ":"));
|
3581
|
+
let CodeElement = document.createElement("div");
|
3582
|
+
ApplyDiv.appendChild(CodeElement);
|
3583
|
+
CodeMirror(CodeElement, {
|
3584
|
+
value: Data,
|
3585
|
+
theme: (UtilityEnabled("DarkMode") ? "darcula" : "default"),
|
3586
|
+
lineNumbers: true,
|
3587
|
+
readOnly: true
|
3588
|
+
}).setSize("100%", "auto");
|
3589
|
+
}
|
3590
|
+
GetDataButton.innerText = "获取数据成功";
|
3591
|
+
GetDataButton.disabled = false;
|
3592
|
+
});
|
3593
|
+
});
|
3594
|
+
}
|
3480
3595
|
document.getElementById("apply_data").addEventListener("click", () => {
|
3481
3596
|
let ApplyElements = document.getElementsByClassName("data");
|
3482
3597
|
for (let i = 0; i < ApplyElements.length; i++) {
|