Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/browser/BrowserFunc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,9 @@ export default class BrowserFunc {
// /earn is the offers page
await page.goto(URLs.rewards.earn, { waitUntil: 'domcontentloaded' })

// first-time welcome modal blocks the dashboard from rendering
await this.dismissRewardsWelcomeDialog(page)

const earnDom = await page.content()
const earnRaw = await this.fetchBootstrapHtml(page, URLs.rewards.earn, '/earn')

Expand Down Expand Up @@ -339,6 +342,30 @@ export default class BrowserFunc {
}
}

/**
* Dismisses the first-time welcome modal on /earn, which otherwise
* prevents section#dailyset from rendering.
*/
private async dismissRewardsWelcomeDialog(page: Page): Promise<void> {
try {
const welcomeButton = await page
.waitForSelector('section[role="dialog"] button[slot="close"]', { timeout: 5000 })
.catch(() => null)
if (!welcomeButton) return

await welcomeButton.click({ timeout: 5000 })
this.bot.logger.info(this.bot.isMobile, 'BOOTSTRAP', 'Dismissed welcome dialog')

await page.waitForSelector('section#dailyset', { timeout: 15000 }).catch(() => undefined)
} catch (error) {
this.bot.logger.warn(
this.bot.isMobile,
'BOOTSTRAP',
`Failed to dismiss welcome dialog: ${error instanceof Error ? error.message : String(error)}`
)
}
}

private async fetchBootstrapHtml(page: Page, url: string, route: string): Promise<string> {
try {
const res = await page.request.get(url, { timeout: 20000 })
Expand Down