feat: minor improvements to captcha bypass

pull/211/head
Travis Fischer 2022-12-28 16:33:24 -06:00
rodzic d0506dad6b
commit 10db1601a0
2 zmienionych plików z 14 dodań i 7 usunięć

Wyświetl plik

@ -662,16 +662,21 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
}
if (this._browser) {
const pages = await this._browser.pages()
for (const page of pages) {
await page.close()
try {
const pages = await this._browser.pages()
for (const page of pages) {
await page.close()
}
} catch (err) {
console.warn('closeSession error', err)
}
await this._browser.close()
const browserProcess = this._browser.process()
// Rule number 1 of zombie process hunting: double-tap
if (this._browser.process()) {
this._browser.process().kill('SIGINT')
if (browserProcess) {
browserProcess.kill('SIGKILL')
}
}

Wyświetl plik

@ -188,12 +188,12 @@ export async function getOpenAIAuth({
}
}
await delay(1200)
await delay(2000)
const frame = page.mainFrame()
const submit = await page.waitForSelector('button[type="submit"]', {
timeout: timeoutMs
})
frame.focus('button[type="submit"]')
await frame.focus('button[type="submit"]')
await submit.focus()
await submit.click()
await page.waitForSelector('#password', { timeout: timeoutMs })
@ -588,12 +588,14 @@ async function waitForRecaptcha(
const captcha = await page.$('textarea#g-recaptcha-response')
if (!captcha) {
// the user may have gone past the page manually
console.log('captcha no longer found; continuing')
break
}
const value = (await captcha.evaluate((el) => el.value))?.trim()
if (value?.length) {
// recaptcha has been solved!
console.log('captcha solved; continuin')
break
}
} catch (err) {