kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
feat: close browser on error
rodzic
b3f71bc1e4
commit
1f1fc66429
|
@ -59,18 +59,29 @@ export class ChatGPTAPIBrowser {
|
||||||
this._browser = null
|
this._browser = null
|
||||||
}
|
}
|
||||||
|
|
||||||
this._browser = await getBrowser({ captchaToken: this._captchaToken })
|
try {
|
||||||
this._page =
|
this._browser = await getBrowser({ captchaToken: this._captchaToken })
|
||||||
(await this._browser.pages())[0] || (await this._browser.newPage())
|
this._page =
|
||||||
|
(await this._browser.pages())[0] || (await this._browser.newPage())
|
||||||
|
|
||||||
// bypass cloudflare and login
|
// bypass cloudflare and login
|
||||||
await getOpenAIAuth({
|
await getOpenAIAuth({
|
||||||
email: this._email,
|
email: this._email,
|
||||||
password: this._password,
|
password: this._password,
|
||||||
browser: this._browser,
|
browser: this._browser,
|
||||||
page: this._page,
|
page: this._page,
|
||||||
isGoogleLogin: this._isGoogleLogin
|
isGoogleLogin: this._isGoogleLogin
|
||||||
})
|
})
|
||||||
|
} catch (err) {
|
||||||
|
if (this._browser) {
|
||||||
|
await this._browser.close()
|
||||||
|
}
|
||||||
|
|
||||||
|
this._browser = null
|
||||||
|
this._page = null
|
||||||
|
|
||||||
|
throw err
|
||||||
|
}
|
||||||
|
|
||||||
const chatUrl = 'https://chat.openai.com/chat'
|
const chatUrl = 'https://chat.openai.com/chat'
|
||||||
const url = this._page.url().replace(/\/$/, '')
|
const url = this._page.url().replace(/\/$/, '')
|
||||||
|
|
Ładowanie…
Reference in New Issue