vjudge: fix codeforces result fetch (picked from #599)

This commit is contained in:
undefined committed 2023-06-30 00:49:43 +08:00
1 parent a104b75bc0
commit 807bfb53e3
1 file changed
+9 -5
+9 -5
View File
@@ -302,7 +302,8 @@ export default class CodeforcesProvider extends BasicFetcher implements IBasicPr
? '/problemset/status?my=on' ? '/problemset/status?my=on'
: `/gym/${contestId}/my`); : `/gym/${contestId}/my`);
this.csrf = document.querySelector('meta[name="X-Csrf-Token"]').getAttribute('content'); this.csrf = document.querySelector('meta[name="X-Csrf-Token"]').getAttribute('content');
return document.querySelector('[data-submission-id]').getAttribute('data-submission-id'); const submission = document.querySelector('[data-submission-id]').getAttribute('data-submission-id');
return type !== 'GYM' ? submission : `${contestId}#${submission}`;
} }
async waitForSubmission(id: string, next, end) { async waitForSubmission(id: string, next, end) {
@@ -310,10 +311,13 @@ export default class CodeforcesProvider extends BasicFetcher implements IBasicPr
// eslint-disable-next-line no-constant-condition // eslint-disable-next-line no-constant-condition
while (true) { while (true) {
await sleep(3000); await sleep(3000);
const { body } = await this.post('/data/submitSource').send({ const contestId = id.includes('#') ? id.split('#')[0] : null;
csrf_token: this.csrf, const { body } = await this.post('/data/submitSource')
submissionId: id, .set('referer', contestId ? `https://codeforces.com/gym/${contestId}/my` : 'https://codeforces.com/problemset/status?my=on')
}); .send({
csrf_token: this.csrf,
submissionId: contestId ? id.split('#')[1] : id,
});
if (body.compilationError === 'true') { if (body.compilationError === 'true') {
return await end({ return await end({
compilerText: body['checkerStdoutAndStderr#1'], compilerText: body['checkerStdoutAndStderr#1'],