Commit c1ec5379 authored by Travis Fischer's avatar Travis Fischer

fix: minor PR cleanups

parent 5c7b9d64
...@@ -126,7 +126,7 @@ export async function getOpenAIAuth({ ...@@ -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({ ...@@ -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({ ...@@ -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({ ...@@ -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)
......
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