mirror of
https://github.com/TheNetsky/Microsoft-Rewards-Script.git
synced 2026-01-11 19:06:18 +00:00
1.2.1
This commit is contained in:
@@ -1,16 +1,18 @@
|
||||
import puppeteer from 'puppeteer-extra'
|
||||
import StealthPlugin from 'puppeteer-extra-plugin-stealth'
|
||||
import stealthPlugin from 'puppeteer-extra-plugin-stealth'
|
||||
|
||||
import { getUserAgent } from '../util/UserAgent'
|
||||
import { loadSesion } from './BrowserFunc'
|
||||
|
||||
import { AccountProxy } from '../interface/Account'
|
||||
|
||||
import { headless } from '../config.json'
|
||||
|
||||
puppeteer.use(StealthPlugin())
|
||||
puppeteer.use(stealthPlugin())
|
||||
|
||||
class Browser {
|
||||
|
||||
async createBrowser(email: string, isMobile: boolean) {
|
||||
async createBrowser(email: string, proxy: AccountProxy, isMobile: boolean) {
|
||||
const userAgent = await getUserAgent(isMobile)
|
||||
|
||||
const browser = await puppeteer.launch({
|
||||
@@ -21,7 +23,8 @@ class Browser {
|
||||
'--mute-audio',
|
||||
'--disable-setuid-sandbox',
|
||||
`--user-agent=${userAgent.userAgent}`,
|
||||
isMobile ? '--window-size=568,1024' : ''
|
||||
isMobile ? '--window-size=568,1024' : '',
|
||||
proxy.url ? `--proxy-server=${proxy.url}:${proxy.port}` : ''
|
||||
]
|
||||
})
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Page } from 'puppeteer'
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import { load } from 'cheerio'
|
||||
import { CheerioAPI, load } from 'cheerio'
|
||||
|
||||
import { tryDismissAllMessages, tryDismissCookieBanner } from './BrowserUtil'
|
||||
import { getFormattedDate, wait } from './../util/Utils'
|
||||
@@ -200,7 +200,7 @@ export async function loadSesion(email: string): Promise<string> {
|
||||
}
|
||||
}
|
||||
|
||||
export async function waitForQuizRefresh(page: Page) {
|
||||
export async function waitForQuizRefresh(page: Page): Promise<boolean> {
|
||||
try {
|
||||
await page.waitForSelector('#rqHeaderCredits', { visible: true, timeout: 5000 })
|
||||
await wait(2000)
|
||||
@@ -212,7 +212,7 @@ export async function waitForQuizRefresh(page: Page) {
|
||||
}
|
||||
}
|
||||
|
||||
export async function checkQuizCompleted(page: Page) {
|
||||
export async function checkQuizCompleted(page: Page): Promise<boolean> {
|
||||
try {
|
||||
await page.waitForSelector('#quizCompleteContainer', { visible: true, timeout: 1000 })
|
||||
await wait(2000)
|
||||
@@ -223,14 +223,14 @@ export async function checkQuizCompleted(page: Page) {
|
||||
}
|
||||
}
|
||||
|
||||
export async function refreshCheerio(page: Page) {
|
||||
export async function refreshCheerio(page: Page): Promise<CheerioAPI> {
|
||||
const html = await page.content()
|
||||
const $ = load(html)
|
||||
|
||||
return $
|
||||
}
|
||||
|
||||
export async function getPunchCardActivity(page: Page, activity: PromotionalItem | MorePromotion) {
|
||||
export async function getPunchCardActivity(page: Page, activity: PromotionalItem | MorePromotion): Promise<string> {
|
||||
let selector = ''
|
||||
try {
|
||||
const html = await page.content()
|
||||
|
||||
@@ -62,7 +62,7 @@ export async function tryDismissBingCookieBanner(page: Page): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
export async function getLatestTab(page: Page) {
|
||||
export async function getLatestTab(page: Page): Promise<Page> {
|
||||
try {
|
||||
await wait(500)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user