Commit 10db1601 authored by Travis Fischer's avatar Travis Fischer

feat: minor improvements to captcha bypass

parent d0506dad
......@@ -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')
}
}
......
......@@ -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) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment