This commit is contained in:
TheNetsky
2023-10-08 13:55:36 +02:00
parent e982e6e25f
commit 03ba5129c6
16 changed files with 419 additions and 345 deletions

View File

@@ -8,35 +8,24 @@ import { headless } from '../config.json'
puppeteer.use(StealthPlugin())
export async function Browser(email: string) {
const userAgent = await getUserAgent(false)
class Browser {
const browser = await puppeteer.launch({
headless: headless,
userDataDir: await loadSesion(email),
args: [
'--no-sandbox',
'--disable-setuid-sandbox',
`--user-agent=${userAgent.userAgent}`
]
})
async createBrowser(email: string, isMobile: boolean) {
const userAgent = await getUserAgent(isMobile)
return browser
const browser = await puppeteer.launch({
headless: headless,
userDataDir: await loadSesion(email),
args: [
'--no-sandbox',
'--disable-setuid-sandbox',
`--user-agent=${userAgent.userAgent}`,
isMobile ? '--window-size=568,1024' : ''
]
})
return browser
}
}
export async function mobileBrowser(email: string) {
const userAgent = await getUserAgent(true)
const browser = await puppeteer.launch({
headless: headless,
userDataDir: await loadSesion(email),
args: [
'--no-sandbox',
'--disable-setuid-sandbox',
`--user-agent=${userAgent.userAgent}`,
'--window-size=568,1024'
]
})
return browser
}
export default Browser

View File

@@ -218,4 +218,11 @@ export async function checkQuizCompleted(page: Page) {
} catch (error) {
return false
}
}
export async function refreshCheerio(page: Page) {
const html = await page.content()
const $ = load(html)
return $
}