From fb325fc6b0b6ebeb72259f1c8af47bf727cdad9c Mon Sep 17 00:00:00 2001 From: Jasper van Merle Date: Sat, 3 Aug 2024 22:46:57 +0200 Subject: [PATCH] Fix Toph parser --- src/parsers/problem/TophProblemParser.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/parsers/problem/TophProblemParser.ts b/src/parsers/problem/TophProblemParser.ts index eaaa572c..bc596a84 100644 --- a/src/parsers/problem/TophProblemParser.ts +++ b/src/parsers/problem/TophProblemParser.ts @@ -5,16 +5,16 @@ import { Parser } from '../Parser'; export class TophProblemParser extends Parser { public getMatchPatterns(): string[] { - return ['https://toph.co/p/*', 'https://toph.co/arena?contest=*/p/*']; + return ['https://toph.co/p/*', 'https://toph.co/arena?*=*/p/*']; } public async parse(url: string, html: string): Promise { const elem = htmlToElement(html); const task = new TaskBuilder('Toph').setUrl(url); - task.setName(elem.querySelector('.artifact h1').textContent); + task.setName(elem.querySelector('.artifact h1').textContent.replace(/\s+/g, ' ').trim()); - const limitsStr = elem.querySelector('span.dotted[data-target="#mdlFactors"]').textContent; + const limitsStr = elem.querySelector('span.dotted.limits').textContent; const [, timeAmount, timeUnit] = /([0-9.]+)(.*),/.exec(limitsStr); task.setTimeLimit(parseFloat(timeAmount) * (timeUnit === 'ms' ? 1 : 1000));