From 085db76f4cfa69ebf86a23cb6fd1904f06babe64 Mon Sep 17 00:00:00 2001 From: TheNetsky <56271887+TheNetsky@users.noreply.github.com> Date: Sun, 8 Oct 2023 16:16:54 +0200 Subject: [PATCH] 1.0.7 Hotfix --- README.md | 2 +- src/functions/activities/ABC.ts | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d78cb03..c874ebe 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Under development, however mainly for personal use! - [ ] Completing Punchcards - [ ] Solving This Or That Quiz - [x] Clicking Promotional Items -- [x] Solving ABC quiz +- [x] Solving ABC Quiz - [ ] Completing Shop And Earn - [ ] Proxy Support diff --git a/src/functions/activities/ABC.ts b/src/functions/activities/ABC.ts index a579cd1..4d56146 100644 --- a/src/functions/activities/ABC.ts +++ b/src/functions/activities/ABC.ts @@ -21,7 +21,10 @@ export async function doABC(page: Page, data: PromotionalItem | MorePromotion) { await wait(2000) let $ = await refreshCheerio(abcPage) - while (!$('span.rw_icon').length) { + // Don't loop more than 15 in case unable to solve, would lock otherwise + const maxIterations = 15 + let i + for (i = 0; i < maxIterations && !$('span.rw_icon').length; i++) { await abcPage.waitForSelector('.wk_OptionClickClass', { visible: true, timeout: 5000 }) const answers = $('.wk_OptionClickClass') @@ -44,7 +47,12 @@ export async function doABC(page: Page, data: PromotionalItem | MorePromotion) { await wait(4000) await abcPage.close() - log('ABC', 'Completed the ABC successfully') + if (i === maxIterations) { + log('ABC', 'Failed to solve quiz, exceeded max iterations of 15', 'warn') + } else { + log('ABC', 'Completed the ABC successfully') + } + } catch (error) { const abcPage = await getLatestTab(page) await abcPage.close()