kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
fix: minor cleanups of executablePath
rodzic
94d54836a7
commit
d685b7800c
|
@ -3,11 +3,7 @@ import type { Browser, HTTPRequest, HTTPResponse, Page } from 'puppeteer'
|
|||
import { v4 as uuidv4 } from 'uuid'
|
||||
|
||||
import * as types from './types'
|
||||
import {
|
||||
defaultChromeExecutablePath,
|
||||
getBrowser,
|
||||
getOpenAIAuth
|
||||
} from './openai-auth'
|
||||
import { getBrowser, getOpenAIAuth } from './openai-auth'
|
||||
import {
|
||||
browserPostEventStream,
|
||||
isRelevantRequest,
|
||||
|
@ -63,7 +59,7 @@ export class ChatGPTAPIBrowser {
|
|||
isGoogleLogin = false,
|
||||
minimize = true,
|
||||
captchaToken,
|
||||
browserPath = defaultChromeExecutablePath()
|
||||
browserPath
|
||||
} = opts
|
||||
|
||||
this._email = email
|
||||
|
@ -95,6 +91,8 @@ export class ChatGPTAPIBrowser {
|
|||
this._page.on('request', this._onRequest.bind(this))
|
||||
this._page.on('response', this._onResponse.bind(this))
|
||||
|
||||
maximizePage(this._page)
|
||||
|
||||
// bypass cloudflare and login
|
||||
await getOpenAIAuth({
|
||||
email: this._email,
|
||||
|
|
|
@ -46,7 +46,8 @@ export async function getOpenAIAuth({
|
|||
page,
|
||||
timeoutMs = 2 * 60 * 1000,
|
||||
isGoogleLogin = false,
|
||||
captchaToken = process.env.CAPTCHA_TOKEN
|
||||
captchaToken = process.env.CAPTCHA_TOKEN,
|
||||
executablePath
|
||||
}: {
|
||||
email?: string
|
||||
password?: string
|
||||
|
@ -55,13 +56,14 @@ export async function getOpenAIAuth({
|
|||
timeoutMs?: number
|
||||
isGoogleLogin?: boolean
|
||||
captchaToken?: string
|
||||
executablePath?: string
|
||||
}): Promise<OpenAIAuth> {
|
||||
const origBrowser = browser
|
||||
const origPage = page
|
||||
|
||||
try {
|
||||
if (!browser) {
|
||||
browser = await getBrowser({ captchaToken })
|
||||
browser = await getBrowser({ captchaToken, executablePath })
|
||||
}
|
||||
|
||||
const userAgent = await browser.userAgent()
|
||||
|
|
Ładowanie…
Reference in New Issue