kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
Merge pull request #124 from kodjunkie/patch-1
commit
17ab3aba8d
|
@ -1,3 +1,5 @@
|
||||||
|
import * as fs from 'fs'
|
||||||
|
import * as os from 'os'
|
||||||
import delay from 'delay'
|
import delay from 'delay'
|
||||||
import {
|
import {
|
||||||
type Browser,
|
type Browser,
|
||||||
|
@ -145,15 +147,33 @@ export async function getOpenAIAuth({
|
||||||
* recognizes it and blocks access.
|
* recognizes it and blocks access.
|
||||||
*/
|
*/
|
||||||
export async function getBrowser(launchOptions?: PuppeteerLaunchOptions) {
|
export async function getBrowser(launchOptions?: PuppeteerLaunchOptions) {
|
||||||
const macChromePath =
|
|
||||||
'/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
|
|
||||||
|
|
||||||
return puppeteer.launch({
|
return puppeteer.launch({
|
||||||
headless: false,
|
headless: false,
|
||||||
args: ['--no-sandbox', '--exclude-switches', 'enable-automation'],
|
args: ['--no-sandbox', '--exclude-switches', 'enable-automation'],
|
||||||
ignoreHTTPSErrors: true,
|
ignoreHTTPSErrors: true,
|
||||||
// executablePath: executablePath()
|
executablePath: executablePath(),
|
||||||
executablePath: macChromePath,
|
|
||||||
...launchOptions
|
...launchOptions
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the correct path to chrome's executable
|
||||||
|
*/
|
||||||
|
const executablePath = (): string => {
|
||||||
|
switch (os.platform()) {
|
||||||
|
case 'win32':
|
||||||
|
return 'C:\\ProgramFiles\\Google\\Chrome\\Application\\chrome.exe'
|
||||||
|
case 'darwin':
|
||||||
|
return '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
|
||||||
|
default:
|
||||||
|
/**
|
||||||
|
* Since two (2) separate chrome releases exists on linux
|
||||||
|
* we first do a check to ensure we're executing the right one.
|
||||||
|
*/
|
||||||
|
const chromeExists = fs.existsSync('/usr/bin/google-chrome')
|
||||||
|
|
||||||
|
return chromeExists
|
||||||
|
? '/usr/bin/google-chrome'
|
||||||
|
: '/usr/bin/google-chrome-stable'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue