mirror of
https://github.com/TheNetsky/Microsoft-Rewards-Script.git
synced 2026-01-11 10:56:17 +00:00
1.5.3
Fix issue with pop-up dismissal
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "microsoft-rewards-script",
|
"name": "microsoft-rewards-script",
|
||||||
"version": "1.5.2",
|
"version": "1.5.3",
|
||||||
"description": "Automatically do tasks for Microsoft Rewards but in TS!",
|
"description": "Automatically do tasks for Microsoft Rewards but in TS!",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"engines": {
|
"engines": {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export default class BrowserUtil {
|
|||||||
this.bot = bot
|
this.bot = bot
|
||||||
}
|
}
|
||||||
|
|
||||||
async tryDismissAllMessages(page: Page): Promise<boolean> {
|
async tryDismissAllMessages(page: Page): Promise<void> {
|
||||||
const buttons = [
|
const buttons = [
|
||||||
{ selector: 'button[type="submit"]', label: 'Submit Button' },
|
{ selector: 'button[type="submit"]', label: 'Submit Button' },
|
||||||
{ selector: '#acceptButton', label: 'AcceptButton' },
|
{ selector: '#acceptButton', label: 'AcceptButton' },
|
||||||
@@ -29,26 +29,18 @@ export default class BrowserUtil {
|
|||||||
{ selector: '#reward_pivot_earn', label: 'Reward Coupon Accept' }
|
{ selector: '#reward_pivot_earn', label: 'Reward Coupon Accept' }
|
||||||
]
|
]
|
||||||
|
|
||||||
const dismissTasks = buttons.map(async (button) => {
|
for (const button of buttons) {
|
||||||
try {
|
try {
|
||||||
const element = button.isXPath
|
const element = button.isXPath ? page.locator(`xpath=${button.selector}`) : page.locator(button.selector)
|
||||||
? page.locator(`xpath=${button.selector}`)
|
await element.first().click({ timeout: 500 })
|
||||||
: page.locator(button.selector)
|
await page.waitForTimeout(500)
|
||||||
|
|
||||||
if (await element.first().isVisible({ timeout: 1000 })) {
|
this.bot.log(this.bot.isMobile, 'DISMISS-ALL-MESSAGES', `Dismissed: ${button.label}`)
|
||||||
await element.first().click({ timeout: 1000 })
|
|
||||||
await page.waitForTimeout(500)
|
} catch (error) {
|
||||||
this.bot.log(this.bot.isMobile, 'DISMISS-ALL-MESSAGES', `Dismissed: ${button.label}`)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
// Silent fail
|
// Silent fail
|
||||||
}
|
}
|
||||||
return false
|
}
|
||||||
})
|
|
||||||
|
|
||||||
const results = await Promise.allSettled(dismissTasks)
|
|
||||||
return results.some(result => result.status === 'fulfilled' && result.value === true)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async getLatestTab(page: Page): Promise<Page> {
|
async getLatestTab(page: Page): Promise<Page> {
|
||||||
|
|||||||
Reference in New Issue
Block a user