Skip to content

Commit

Permalink
Merge pull request #5 from vetrivelcsamy/quiz-beta
Browse files Browse the repository at this point in the history
Refactor problem URL and submission result selector (quiz/problem)
  • Loading branch information
vetrivelcsamy authored Dec 24, 2023
2 parents 7b9db10 + cb4d539 commit 679cca9
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions scripts/bfe.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,14 @@ const extractProblemInfo = async () => {
);
const item = QUESTION_INFO.props.pageProps.item;
const permalink = QUESTION_INFO.query.permalink;
const PAGE_TYPE = QUESTION_INFO.page === "/problem/[permalink]" ? "problem" : "quiz"; // quiz or problem

return {
problemId: item.id,
problemIndex: permalink,
problemName: item.title,
problemLevel: item.difficulty,
problemUrl: `https://bigfrontend.dev/problem/${permalink}`,
problemUrl: `https://bigfrontend.dev/${PAGE_TYPE}/${permalink}`,
};
};

Expand All @@ -92,7 +93,7 @@ const monitorSubmissionResult = async () => {
return;
}

const submissionResultSelector = 'p[class^="TestResultView__Success"]';
const submissionResultSelector = 'p[class^="TestResultView__Success"]' || 'p[class^="permalink__Success"]';
const submissionResult = document.querySelector(submissionResultSelector);

if (!submissionResult) {
Expand All @@ -101,9 +102,7 @@ const monitorSubmissionResult = async () => {
}

clearInterval(functionId);
const isSuccess = submissionResult.innerText.includes(
"👍 well done! all cases passed"
);
const isSuccess = submissionResult.innerText.includes("👍 well done! all cases passed" || "👍 well done! it passed");

const submissionTime = Date.now();
const { problemId, problemIndex, problemName, problemLevel, problemUrl } =
Expand Down

0 comments on commit 679cca9

Please sign in to comment.