From 353190b03093fa9e7c4ba69fcb5b706d8e7f74a4 Mon Sep 17 00:00:00 2001 From: conlacda Date: Sat, 7 Dec 2024 00:41:31 +0900 Subject: [PATCH] fix #5 --- .github/workflows/playwright.yml | 2 +- .../scripts/submission-details/dom.js | 2 +- .../scripts/submission-details/main.js | 2 +- .../submission-details/problem-info.js | 19 ++++++++----------- .../submission-details/testcase-downloader.js | 2 +- 5 files changed, 12 insertions(+), 15 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 058fd0f..ef6477d 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -1,7 +1,7 @@ name: Playwright Tests on: push: - branches: [ main, dev ] + branches: [ "*" ] pull_request: branches: [ main, dev ] jobs: diff --git a/browser-extension/chrome-extension/scripts/submission-details/dom.js b/browser-extension/chrome-extension/scripts/submission-details/dom.js index 5399b6b..f955f29 100644 --- a/browser-extension/chrome-extension/scripts/submission-details/dom.js +++ b/browser-extension/chrome-extension/scripts/submission-details/dom.js @@ -84,7 +84,7 @@ addDebugColumnToResultTable = (resultTable) => { debugIcon.attr('id', `debug-${index}`); debugIcon.css('cursor', 'pointer'); debugIcon.on("click", () => { - window.location.href = `https://atcoder.jp/contests/${getContestName()}/custom_test?submissionId=${getSubmissionId()}&testcase=${tcfile}&problem=${getProblemName()}`; + window.location.href = `https://atcoder.jp/contests/${getContestName()}/custom_test?submissionId=${getSubmissionId()}&testcase=${tcfile}&problem=${getProblemID()}`; }); const cell = $(''); cell.append(debugIcon); diff --git a/browser-extension/chrome-extension/scripts/submission-details/main.js b/browser-extension/chrome-extension/scripts/submission-details/main.js index 6edbfda..bc73f73 100644 --- a/browser-extension/chrome-extension/scripts/submission-details/main.js +++ b/browser-extension/chrome-extension/scripts/submission-details/main.js @@ -1,5 +1,5 @@ (async () => { - const testcaseList = await fetchTestCasesList(getContestName(), getProblemName()); + const testcaseList = await fetchTestCasesList(getContestName(), getProblemID()); if (testcaseList.length > 0) { const resultTable = $('.table:last'); addInputColumnToResultTable(resultTable); diff --git a/browser-extension/chrome-extension/scripts/submission-details/problem-info.js b/browser-extension/chrome-extension/scripts/submission-details/problem-info.js index 9989d03..b05892a 100644 --- a/browser-extension/chrome-extension/scripts/submission-details/problem-info.js +++ b/browser-extension/chrome-extension/scripts/submission-details/problem-info.js @@ -12,18 +12,15 @@ getContestName = () => { }; /** - * Retrieve the problem name + * Retrieve the problem ID * @example A, B, C or D - * @returns {string} The problem name + * @returns {string} The problem ID */ -getProblemName = () => { - return $(".table") // Selecting the "Submission Info" table - .first() - .find('tr') // The second row contains problem name - .eq(1) - .find('a') // contains url of the problem - .attr('href') - .at(-1) // Last character of url is the problem nam (A, B, C, D) +getProblemID = () => { + return document.querySelector('.table') + .querySelectorAll('tr')[1] + .querySelector('a') + .innerText[0] .toUpperCase(); }; @@ -35,4 +32,4 @@ getSubmissionId = () => { const regex = /contests\/.*\/submissions\/(.*)/gm; const match = regex.exec(curPath); return match[1]; -}; \ No newline at end of file +}; diff --git a/browser-extension/chrome-extension/scripts/submission-details/testcase-downloader.js b/browser-extension/chrome-extension/scripts/submission-details/testcase-downloader.js index 125c52b..df2fd1d 100644 --- a/browser-extension/chrome-extension/scripts/submission-details/testcase-downloader.js +++ b/browser-extension/chrome-extension/scripts/submission-details/testcase-downloader.js @@ -7,7 +7,7 @@ */ fetchTestCase = async (testcase, inOrOut = "in") => { const contest = getContestName(); - const problem = getProblemName(); + const problem = getProblemID(); const source = `https://raw.githubusercontent.com/conlacda/atcoder-testcases/${contest}/${contest}/${problem}/${inOrOut}/${testcase}`; const res = await fetchWithRetry(source); if (res.status !== 200) {