mirror of
https://github.com/LightZirconite/Microsoft-Rewards-Bot.git
synced 2026-01-11 01:36:16 +00:00
feat: Implement smart waiting utilities for improved page readiness and element detection
- Added `waitForPageReady` and `waitForElementSmart` functions to replace fixed timeouts with intelligent checks. - Updated various parts of the codebase to utilize the new smart wait functions, enhancing performance and reliability. - Improved logging for page readiness and element detection. - Refactored login and browser functions to reduce unnecessary waits and enhance user experience. - Fixed selector for MORE_ACTIVITIES to avoid strict mode violations. - Added unit tests for smart wait utilities to ensure functionality and performance.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { load } from 'cheerio'
|
||||
import { Page } from 'rebrowser-playwright'
|
||||
import { MicrosoftRewardsBot } from '../index'
|
||||
import { waitForPageReady } from '../util/browser/SmartWait'
|
||||
import { logError } from '../util/notifications/Logger'
|
||||
|
||||
type DismissButton = { selector: string; label: string; isXPath?: boolean }
|
||||
@@ -207,7 +208,8 @@ export default class BrowserUtil {
|
||||
const errorType = hasHttp400Error ? 'HTTP 400' : 'network error'
|
||||
this.bot.log(this.bot.isMobile, 'RELOAD-BAD-PAGE', `Bad page detected (${errorType}), reloading!`)
|
||||
await page.reload({ waitUntil: 'domcontentloaded' })
|
||||
await this.bot.utils.wait(1500)
|
||||
// IMPROVED: Use smart wait instead of fixed 1500ms delay
|
||||
await waitForPageReady(page)
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user