|
1 | 1 | // ==UserScript== |
2 | 2 | // @name XMOJ |
3 | | -// @version 2.4.2 |
| 3 | +// @version 2.4.3 |
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 | | - }, {"ID": "ApplyData", "Type": "A", "Name": "获取数据功能"}, { |
| 1472 | + }, { |
1473 | 1473 | "ID": "AutoCheat", "Type": "A", "Name": "自动提交当年代码" |
1474 | 1474 | }, {"ID": "Rating", "Type": "A", "Name": "添加用户评分和用户名颜色"}, { |
1475 | 1475 | "ID": "AutoRefresh", "Type": "A", "Name": "比赛列表、比赛排名界面自动刷新" |
@@ -3420,121 +3420,6 @@ async function main() { |
3420 | 3420 | if (document.getElementById("apply_data")) { |
3421 | 3421 | let ApplyDiv = document.getElementById("apply_data").parentElement; |
3422 | 3422 | console.log("启动!!!"); |
3423 | | - if (UtilityEnabled("ApplyData")) { |
3424 | | - let GetDataButton = document.createElement("button"); |
3425 | | - GetDataButton.className = "ms-2 btn btn-outline-secondary"; |
3426 | | - GetDataButton.innerText = "获取数据"; |
3427 | | - console.log("按钮创建成功"); |
3428 | | - ApplyDiv.appendChild(GetDataButton); |
3429 | | - GetDataButton.addEventListener("click", async () => { |
3430 | | - GetDataButton.disabled = true; |
3431 | | - GetDataButton.innerText = "正在获取数据..."; |
3432 | | - let PID = localStorage.getItem("UserScript-Solution-" + SearchParams.get("sid") + "-Problem"); |
3433 | | - if (PID == null) { |
3434 | | - GetDataButton.innerText = "失败! 无法获取PID"; |
3435 | | - GetDataButton.disabled = false; |
3436 | | - await new Promise((resolve) => { |
3437 | | - setTimeout(resolve, 800); |
3438 | | - }); |
3439 | | - GetDataButton.innerText = "获取数据"; |
3440 | | - return; |
3441 | | - } |
3442 | | - let Code = ""; |
3443 | | - if (localStorage.getItem(`UserScript-Problem-${PID}-IOFilename`) !== null) { |
3444 | | - Code = `#define IOFile "${localStorage.getItem(`UserScript-Problem-${PID}-IOFilename`)}"\n`; |
3445 | | - } |
3446 | | - Code += `//XMOJ-Script 获取数据代码 |
3447 | | - #include <bits/stdc++.h> |
3448 | | -using namespace std; |
3449 | | -string Base64Encode(string Input) |
3450 | | -{ |
3451 | | - const string Base64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; |
3452 | | - string Output; |
3453 | | - for (int i = 0; i < Input.length(); i += 3) |
3454 | | - { |
3455 | | - Output.push_back(i + 0 > Input.length() ? '=' : Base64Chars[(Input[i + 0] & 0xfc) >> 2]); |
3456 | | - Output.push_back(i + 1 > Input.length() ? '=' : Base64Chars[((Input[i + 0] & 0x03) << 4) + ((Input[i + 1] & 0xf0) >> 4)]); |
3457 | | - Output.push_back(i + 2 > Input.length() ? '=' : Base64Chars[((Input[i + 1] & 0x0f) << 2) + ((Input[i + 2] & 0xc0) >> 6)]); |
3458 | | - Output.push_back(i + 3 > Input.length() ? '=' : Base64Chars[Input[i + 2] & 0x3f]); |
3459 | | - } |
3460 | | - return Output; |
3461 | | -} |
3462 | | -int main() |
3463 | | -{ |
3464 | | -#ifdef IOFile |
3465 | | - freopen(IOFile ".in", "r", stdin); |
3466 | | - freopen(IOFile ".out", "w", stdout); |
3467 | | -#endif |
3468 | | - string Input; |
3469 | | - while (1) |
3470 | | - { |
3471 | | - char Data = getchar(); |
3472 | | - if (Data == EOF) |
3473 | | - break; |
3474 | | - Input.push_back(Data); |
3475 | | - } |
3476 | | - throw runtime_error("[" + Base64Encode(Input.c_str()) + "]"); |
3477 | | - return 0; |
3478 | | -}`; |
3479 | | - |
3480 | | - await fetch("https://www.xmoj.tech/submit.php", { |
3481 | | - "headers": { |
3482 | | - "content-type": "application/x-www-form-urlencoded" |
3483 | | - }, |
3484 | | - "referrer": "https://www.xmoj.tech/submitpage.php?id=" + PID, |
3485 | | - "method": "POST", |
3486 | | - "body": "id=" + PID + "&" + "language=1&" + "source=" + encodeURIComponent(Code) + "&" + "enable_O2=on" |
3487 | | - }); |
3488 | | - |
3489 | | - let SID = await fetch("https://www.xmoj.tech/status.php").then((Response) => { |
3490 | | - return Response.text(); |
3491 | | - }).then((Response) => { |
3492 | | - let ParsedDocument = new DOMParser().parseFromString(Response, "text/html"); |
3493 | | - return ParsedDocument.querySelector("#result-tab > tbody > tr:nth-child(1) > td:nth-child(2)").innerText; |
3494 | | - }); |
3495 | | - |
3496 | | - await new Promise((Resolve) => { |
3497 | | - let Interval = setInterval(async () => { |
3498 | | - await fetch("status-ajax.php?solution_id=" + SID).then((Response) => { |
3499 | | - return Response.text(); |
3500 | | - }).then((Response) => { |
3501 | | - if (Response.split(",")[0] >= 4) { |
3502 | | - clearInterval(Interval); |
3503 | | - Resolve(); |
3504 | | - } |
3505 | | - }); |
3506 | | - }, 500); |
3507 | | - }); |
3508 | | - |
3509 | | - await fetch(`https://www.xmoj.tech/reinfo.php?sid=${SID}`).then((Response) => { |
3510 | | - return Response.text(); |
3511 | | - }).then((Response) => { |
3512 | | - let ParsedDocument = new DOMParser().parseFromString(Response, "text/html"); |
3513 | | - let ErrorData = ParsedDocument.getElementById("errtxt").innerText; |
3514 | | - let MatchResult = ErrorData.match(/\what\(\): \[([A-Za-z0-9+\/=]+)\]/g); |
3515 | | - if (MatchResult === null) { |
3516 | | - GetDataButton.innerText = "获取数据失败"; |
3517 | | - GetDataButton.disabled = false; |
3518 | | - return; |
3519 | | - } |
3520 | | - for (let i = 0; i < MatchResult.length; i++) { |
3521 | | - let Data = CryptoJS.enc.Base64.parse(MatchResult[i].substring(10, MatchResult[i].length - 1)).toString(CryptoJS.enc.Utf8); |
3522 | | - ApplyDiv.appendChild(document.createElement("hr")); |
3523 | | - ApplyDiv.appendChild(document.createTextNode("数据" + (i + 1) + ":")); |
3524 | | - let CodeElement = document.createElement("div"); |
3525 | | - ApplyDiv.appendChild(CodeElement); |
3526 | | - CodeMirror(CodeElement, { |
3527 | | - value: Data, |
3528 | | - theme: (UtilityEnabled("DarkMode") ? "darcula" : "default"), |
3529 | | - lineNumbers: true, |
3530 | | - readOnly: true |
3531 | | - }).setSize("100%", "auto"); |
3532 | | - } |
3533 | | - GetDataButton.innerText = "获取数据成功"; |
3534 | | - GetDataButton.disabled = false; |
3535 | | - }); |
3536 | | - }); |
3537 | | - } |
3538 | 3423 | document.getElementById("apply_data").addEventListener("click", () => { |
3539 | 3424 | let ApplyElements = document.getElementsByClassName("data"); |
3540 | 3425 | for (let i = 0; i < ApplyElements.length; i++) { |
|
0 commit comments