mirror of
https://github.com/TheNetsky/Microsoft-Rewards-Script.git
synced 2026-01-17 21:43:59 +00:00
29 lines
763 B
TypeScript
29 lines
763 B
TypeScript
import { Page } from 'puppeteer'
|
|
|
|
import { Workers } from '../Workers'
|
|
|
|
|
|
export class Poll extends Workers {
|
|
|
|
async doPoll(page: Page) {
|
|
this.bot.log('POLL', 'Trying to complete poll')
|
|
|
|
try {
|
|
const buttonId = `#btoption${Math.floor(this.bot.utils.randomNumber(0, 1))}`
|
|
|
|
await page.waitForSelector(buttonId, { visible: true, timeout: 10_000 })
|
|
await this.bot.utils.wait(2000)
|
|
|
|
await page.click(buttonId)
|
|
|
|
await this.bot.utils.wait(4000)
|
|
await page.close()
|
|
|
|
this.bot.log('POLL', 'Completed the poll successfully')
|
|
} catch (error) {
|
|
await page.close()
|
|
this.bot.log('POLL', 'An error occurred:' + error, 'error')
|
|
}
|
|
}
|
|
|
|
} |