fix: minor PR cleanups

pull/220/head
Travis Fischer 2022-12-31 15:21:55 -06:00
rodzic 5c7b9d64a4
commit c1ec537903
1 zmienionych plików z 6 dodań i 5 usunięć

Wyświetl plik

@ -126,7 +126,7 @@ export async function getOpenAIAuth({
await delay(500) await delay(500)
// click login button and wait for navigation to finish // click login button and wait for navigation to finish
while (page.url().endsWith('/auth/login')) { do {
await Promise.all([ await Promise.all([
page.waitForNavigation({ page.waitForNavigation({
waitUntil: 'networkidle2', waitUntil: 'networkidle2',
@ -134,8 +134,8 @@ export async function getOpenAIAuth({
}), }),
page.click('#__next .btn-primary') page.click('#__next .btn-primary')
]) ])
delay(500) await delay(500)
} } while (page.url().endsWith('/auth/login'))
await checkForChatGPTAtCapacity(page, { timeoutMs }) await checkForChatGPTAtCapacity(page, { timeoutMs })
@ -181,8 +181,9 @@ export async function getOpenAIAuth({
if (hasNopechaExtension) { if (hasNopechaExtension) {
await waitForRecaptcha(page, { timeoutMs }) await waitForRecaptcha(page, { timeoutMs })
} else if (hasRecaptchaPlugin) { } else if (hasRecaptchaPlugin) {
// Add retry for network unstable
console.log('solving captchas using 2captcha...') console.log('solving captchas using 2captcha...')
// Add retries in case network is unstable
const retries = 3 const retries = 3
for (let i = 0; i < retries; i++) { for (let i = 0; i < retries; i++) {
try { try {
@ -192,7 +193,7 @@ export async function getOpenAIAuth({
break break
} else { } else {
console.log('no captchas found') console.log('no captchas found')
delay(500) await delay(500)
} }
} catch (e) { } catch (e) {
console.log('captcha error', e) console.log('captcha error', e)