kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
get chrome executable path based on the platform
rodzic
5beb30d6bc
commit
cee3c2ee22
|
@ -1,4 +1,5 @@
|
||||||
import delay from 'delay'
|
import delay from 'delay'
|
||||||
|
import { platform } from 'os'
|
||||||
import {
|
import {
|
||||||
type Browser,
|
type Browser,
|
||||||
type Page,
|
type Page,
|
||||||
|
@ -125,15 +126,26 @@ 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
|
||||||
|
* defaults to the path for macOs
|
||||||
|
*/
|
||||||
|
const executablePath = (): string => {
|
||||||
|
switch (platform()) {
|
||||||
|
case 'win32':
|
||||||
|
return 'C:\\ProgramFiles\\Google\\Chrome\\Application\\chrome.exe'
|
||||||
|
case 'linux':
|
||||||
|
return '/usr/bin/google-chrome-stable'
|
||||||
|
default:
|
||||||
|
return '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue