From 9901ffa62d1c6287d5323a950b27f82a7ef84f59 Mon Sep 17 00:00:00 2001 From: guke1024 <46668943+guke1024@users.noreply.github.com> Date: Fri, 20 Oct 2023 09:25:30 +0800 Subject: [PATCH] vjudge: fix csgoj (#673) --- README.md | 2 +- packages/vjudge/src/providers/csgoj.ts | 24 +++++++++++++++--------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 3270b2967..92d1273a9 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,7 @@ Hydro 同时支持 VJudge,这意味着你可以直接在系统内导入其他 - [UOJ](https://uoj.ac):国内知名 OJ,国家集训队常用; - [SPOJ](https://www.spoj.com):国内连接很不稳定,不推荐; - [洛谷](https://www.luogu.com.cn):使用此功能需要向洛谷购买授权; -- [CSGOJ](https://cpc.csgrandeur.cn); +- [CSGOJ](https://cpc.csgrandeur.cn):广东省赛与湖南省赛赛题评测平台; - [POJ](https://poj.org):较为古董,服务器稳定性差; - HUSTOJ:理论上支持所有 HUSTOJ 驱动的系统,但由于各个系统中 UI 有差异,通常需要手动适配。 diff --git a/packages/vjudge/src/providers/csgoj.ts b/packages/vjudge/src/providers/csgoj.ts index cd35c0c5e..62bd88b1a 100644 --- a/packages/vjudge/src/providers/csgoj.ts +++ b/packages/vjudge/src/providers/csgoj.ts @@ -37,16 +37,19 @@ csgoj.1: monaco: cpp highlight: cpp astyle-c comment: // -csgoj.2: - display: Pascal - monaco: pascal - highlight: pascal - comment: // csgoj.3: display: Java monaco: java highlight: java astyle-java comment: // +csgoj.6: + display: Python3 + highlight: python + comment: '#' +csgoj.17: + display: Go + highlight: go + comment: // */ const userAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0'; @@ -107,8 +110,8 @@ export default class CSGOJProvider extends BasicFetcher implements IBasicProvide const description = [...pDescription.children].map((i) => i.outerHTML).join(''); const input = [...document.querySelector('div[name="Input"]').children].map((i) => i.outerHTML).join(''); const output = [...document.querySelector('div[name="Output"]').children].map((i) => i.outerHTML).join(''); - const sampleInput = `\`\`\`input1\n${document.querySelector('div[name="Sample Input"]>pre').innerHTML.trim()}\n\`\`\``; - const sampleOutput = `\`\`\`output1\n${document.querySelector('div[name="Sample Output"]>pre').innerHTML.trim()}\n\`\`\``; + const sampleInput = `\`\`\`input1\n${document.querySelector('pre.sample_input_area').innerHTML.trim()}\n\`\`\``; + const sampleOutput = `\`\`\`output1\n${document.querySelector('pre.sample_output_area').innerHTML.trim()}\n\`\`\``; const contents = [description, input, output, sampleInput, sampleOutput]; const hint = document.querySelector('div[name="Hint"]'); if (hint.textContent.trim().length > 4) { @@ -160,9 +163,12 @@ export default class CSGOJProvider extends BasicFetcher implements IBasicProvide while (count < 60) { count++; await sleep(3000); - const { body } = await this.get(`/csgoj/Status/status_ajax?solution_id=${id}`).set('X-Requested-With', 'XMLHttpRequest'); + const { body } = await this + // eslint-disable-next-line max-len + .get(`/csgoj/status/status_ajax?sort=solution_id_show&order=desc&offset=0&limit=20&problem_id=&user_id=&solution_id=${id}&language=-1&result=-1`) + .set('X-Requested-With', 'XMLHttpRequest'); const status = statusDict[body.rows[0].result] || STATUS.STATUS_SYSTEM_ERROR; - if (status === STATUS.STATUS_JUDGING) continue; + if (status === STATUS.STATUS_JUDGING || status === STATUS.STATUS_COMPILING) continue; await end({ status, score: status === STATUS.STATUS_ACCEPTED ? 100 : 0,