kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
Adding a isGoogleLogin flag to getOpenAIAuth so users with a google account can authenticate that way.
rodzic
c936391041
commit
5dad44637c
|
@ -40,12 +40,14 @@ export async function getOpenAIAuth({
|
||||||
email,
|
email,
|
||||||
password,
|
password,
|
||||||
timeoutMs = 2 * 60 * 1000,
|
timeoutMs = 2 * 60 * 1000,
|
||||||
browser
|
browser,
|
||||||
|
isGoogleLogin
|
||||||
}: {
|
}: {
|
||||||
email?: string
|
email?: string
|
||||||
password?: string
|
password?: string
|
||||||
timeoutMs?: number
|
timeoutMs?: number
|
||||||
browser?: Browser
|
browser?: Browser
|
||||||
|
isGoogleLogin?: boolean
|
||||||
}): Promise<OpenAIAuth> {
|
}): Promise<OpenAIAuth> {
|
||||||
let page: Page
|
let page: Page
|
||||||
let origBrowser = browser
|
let origBrowser = browser
|
||||||
|
@ -76,17 +78,34 @@ export async function getOpenAIAuth({
|
||||||
waitUntil: 'networkidle0'
|
waitUntil: 'networkidle0'
|
||||||
})
|
})
|
||||||
])
|
])
|
||||||
await page.waitForSelector('#username')
|
if (isGoogleLogin) {
|
||||||
await page.type('#username', email, { delay: 10 })
|
await page.click('button[data-provider="google"]')
|
||||||
await page.click('button[type="submit"]')
|
await page.waitForSelector('input[type="email"]')
|
||||||
await page.waitForSelector('#password')
|
await page.type('input[type="email"]', email, { delay: 10 })
|
||||||
await page.type('#password', password, { delay: 10 })
|
await Promise.all([
|
||||||
await Promise.all([
|
page.waitForNavigation(),
|
||||||
page.click('button[type="submit"]'),
|
await page.keyboard.press('Enter')
|
||||||
page.waitForNavigation({
|
])
|
||||||
waitUntil: 'networkidle0'
|
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')
|
||||||
|
await page.type('#password', password, { delay: 10 })
|
||||||
|
await Promise.all([
|
||||||
|
page.click('button[type="submit"]'),
|
||||||
|
page.waitForNavigation({
|
||||||
|
waitUntil: 'networkidle0'
|
||||||
|
})
|
||||||
|
])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const pageCookies = await page.cookies()
|
const pageCookies = await page.cookies()
|
||||||
|
|
Ładowanie…
Reference in New Issue