Commit 8169c9c4 authored by Travis Fischer's avatar Travis Fischer Committed by GitHub

Merge pull request #129 from tpholston/main

parents c9363910 5dad4463
......@@ -40,12 +40,14 @@ export async function getOpenAIAuth({
email,
password,
timeoutMs = 2 * 60 * 1000,
browser
browser,
isGoogleLogin
}: {
email?: string
password?: string
timeoutMs?: number
browser?: Browser
isGoogleLogin?: boolean
}): Promise<OpenAIAuth> {
let page: Page
let origBrowser = browser
......@@ -76,7 +78,23 @@ export async function getOpenAIAuth({
waitUntil: 'networkidle0'
})
])
await page.waitForSelector('#username')
if (isGoogleLogin) {
await page.click('button[data-provider="google"]')
await page.waitForSelector('input[type="email"]')
await page.type('input[type="email"]', email, { delay: 10 })
await Promise.all([
page.waitForNavigation(),
await page.keyboard.press('Enter')
])
await page.waitForSelector('input[type="password"]', { visible: true })
await page.type('input[type="password"]', password, { delay: 10 })
await page.keyboard.press('Enter')
await Promise.all([
page.waitForNavigation({
waitUntil: 'networkidle0'
})
])
} else {
await page.type('#username', email, { delay: 10 })
await page.click('button[type="submit"]')
await page.waitForSelector('#password')
......@@ -88,6 +106,7 @@ export async function getOpenAIAuth({
})
])
}
}
const pageCookies = await page.cookies()
const cookies = pageCookies.reduce(
......
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