From 755237caa1da6ce976cbec96f5a27c4759947b2d Mon Sep 17 00:00:00 2001 From: CNOCM <80609142+CNOCM@users.noreply.github.com> Date: Sun, 18 Aug 2024 20:37:56 +0800 Subject: [PATCH] Skip locked Promotions (#132) --- src/browser/BrowserFunc.ts | 2 +- src/functions/Workers.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/browser/BrowserFunc.ts b/src/browser/BrowserFunc.ts index 946110d..c5c7759 100644 --- a/src/browser/BrowserFunc.ts +++ b/src/browser/BrowserFunc.ts @@ -158,7 +158,7 @@ export default class BrowserFunc { if (data.morePromotions?.length) { data.morePromotions.forEach(x => { // Only count points from supported activities - if (['quiz', 'urlreward'].includes(x.promotionType)) { + if (['quiz', 'urlreward'].includes(x.promotionType) && !x.attributes.is_unlocked) { totalEarnablePoints += (x.pointProgressMax - x.pointProgress) } }) diff --git a/src/functions/Workers.ts b/src/functions/Workers.ts index b347b44..43643ef 100644 --- a/src/functions/Workers.ts +++ b/src/functions/Workers.ts @@ -87,7 +87,7 @@ export class Workers { morePromotions.push(data.promotionalItem as unknown as MorePromotion) } - const activitiesUncompleted = morePromotions?.filter(x => !x.complete && x.pointProgressMax > 0) ?? [] + const activitiesUncompleted = morePromotions?.filter(x => !x.complete && x.pointProgressMax > 0 && !x.attributes.is_unlocked) ?? []; if (!activitiesUncompleted.length) { this.bot.log('MORE-PROMOTIONS', 'All "More Promotion" items have already been completed') @@ -149,7 +149,7 @@ export class Workers { // Wait for the new tab to fully load, ignore error. /* - Due to common false timeout on this function, we're ignoring the error regardless, if it worked then it's faster, + Due to common false timeout on this function, we're ignoring the error regardless, if it worked then it's faster, if it didn't then it gave enough time for the page to load. */ await activityPage.waitForLoadState('networkidle', { timeout: 10_000 }).catch(() => { })