Skip to content

Commit

Permalink
fix(Codeforces & AtCoder): 在线代码运行超时时给出明确的提示
Browse files Browse the repository at this point in the history
  • Loading branch information
beijixiaohu committed Jan 22, 2025
1 parent 15678be commit dec85fc
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
16 changes: 12 additions & 4 deletions script/dev/atcoder-better.user.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ==UserScript==
// @name Atcoder Better!
// @namespace https://greasyfork.org/users/747162
// @version 1.18.0
// @version 1.18.1
// @description 一个适用于 AtCoder 的 Tampermonkey 脚本,增强功能与界面。
// @author 北极小狐
// @match *://atcoder.jp/*
Expand Down Expand Up @@ -12975,9 +12975,17 @@ async function runCode(event, runButton, sourceDiv) {
const result = await onlineCompilerConnect(sourceDiv.val(), data.input);

if (result.Errors) {
testCase.setStatus('Compilation error or Time limit', 'error');
testCase.setContent(result.Errors, TestCaseContentType.TERMINAL);
hasError = true;
if (result.Errors === "Verdict not ready, retrying...") {
testCase.setStatus(
"Server communication timeout. Judge service may be busy.",
"error"
);
hasError = true;
} else {
testCase.setStatus("Compilation error or Time limit", "error");
testCase.setContent(result.Errors, TestCaseContentType.TERMINAL);
hasError = true;
}
} else {
const resultCheck = judgeResultValidate(data.output, result.Result);
testCase.setJudgeChecker(resultCheck.message);
Expand Down
20 changes: 14 additions & 6 deletions script/dev/codeforces-better.user.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ==UserScript==
// @name Codeforces Better!
// @namespace https://greasyfork.org/users/747162
// @version 1.78.0
// @version 1.78.1
// @author 北极小狐
// @match *://*.codeforces.com/*
// @match *://*.codeforc.es/*
Expand Down Expand Up @@ -15547,9 +15547,17 @@ async function runCode(event, runButton, sourceDiv) {
const result = await onlineCompilerConnect(sourceDiv.val(), data.input);

if (result.Errors) {
testCase.setStatus("Compilation error or Time limit", "error");
testCase.setContent(result.Errors, TestCaseContentType.TERMINAL);
hasError = true;
if (result.Errors === "Verdict not ready, retrying...") {
testCase.setStatus(
"Server communication timeout. Judge service may be busy.",
"error"
);
hasError = true;
} else {
testCase.setStatus("Compilation error or Time limit", "error");
testCase.setContent(result.Errors, TestCaseContentType.TERMINAL);
hasError = true;
}
} else {
const resultCheck = judgeResultValidate(data.output, result.Result);
testCase.setJudgeChecker(resultCheck.message);
Expand Down Expand Up @@ -16079,7 +16087,7 @@ async function translate_youdao_web(raw) {
"An unknown network error occurred!",
response
);
const {data} = JSON.parse(response.responseText);
const { data } = JSON.parse(response.responseText);
return data;
}

Expand Down Expand Up @@ -16145,7 +16153,7 @@ async function translate_youdao_web(raw) {
const time = new Date().getTime();
const t = "asdjnjfenknafdfsdfsd";
const sign = getsign(time, t);
const {secretKey, aesKey, aesIv} = await getKey(sign, time);
const { secretKey, aesKey, aesIv } = await getKey(sign, time);
// 表单数据
const data = {
i: raw,
Expand Down

0 comments on commit dec85fc

Please sign in to comment.