Files
Microsoft-Rewards-Script/src/functions/activities/Poll.ts
TheNetsky c86a903793 1.1.0
2023-10-11 15:08:11 +02:00

26 lines
718 B
TypeScript

import { Page } from 'puppeteer'
import { log } from '../../util/Logger'
import { randomNumber, wait } from '../../util/Utils'
export async function doPoll(page: Page) {
log('POLL', 'Trying to complete poll')
try {
const buttonId = `#btoption${Math.floor(randomNumber(0, 1))}`
await page.waitForNetworkIdle({ timeout: 5000 })
await page.waitForSelector(buttonId, { visible: true, timeout: 5000 })
await wait(2000)
await page.click(buttonId)
await wait(4000)
await page.close()
log('POLL', 'Completed the poll successfully')
} catch (error) {
await page.close()
log('POLL', 'An error occurred:' + error, 'error')
}
}