Commit d1b74a87 authored by Travis Fischer's avatar Travis Fischer Committed by GitHub

Merge pull request #180 from timmsGithub/main

parents 091914a0 ba377298
......@@ -118,6 +118,22 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
this._page =
(await this._browser.pages())[0] || (await this._browser.newPage())
if (this._proxyServer && this._proxyServer.includes('@')) {
const proxyUsername = this._proxyServer.split('@')[0].split(':')[0]
const proxyPassword = this._proxyServer.split('@')[0].split(':')[1]
try {
await this._page.authenticate({
username: proxyUsername,
password: proxyPassword
})
} catch (err) {
console.error(
`Proxy "${this._proxyServer}" throws an error at authenticating`,
err.toString()
)
}
}
// bypass annoying popup modals
this._page.evaluateOnNewDocument(() => {
window.localStorage.setItem('oai/apps/hasSeenOnboarding/chat', 'true')
......
......@@ -313,7 +313,10 @@ export async function getBrowser(
}
if (proxyServer) {
puppeteerArgs.push(`--proxy-server=${proxyServer}`)
const ipPort = proxyServer.includes('@')
? proxyServer.split('@')[1]
: proxyServer
puppeteerArgs.push(`--proxy-server=${ipPort}`)
}
const browser = await puppeteer.launch({
......
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