Skip to content

Commit

Permalink
feat: allow custom chromium execs in config
Browse files Browse the repository at this point in the history
  • Loading branch information
SpikeHD committed Nov 5, 2023
1 parent 79edb91 commit 3dfd4df
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ A TLD, or *Top-Level Domain*, is the little `.com` or `.ca` of a URL. Each regio

If you're the efficient type, setting this to `true` will make sure that the links in stock/price notifications will bring you to a page that will automatically add the item to your cart.

## custom_chromium_exec

If you are on a platform that does not properly install Chromium when running `npm install`, you can install Chromium manually, and then set that path here. Most users can just leave this blank

## debug_enabled

If set to `true`, the console window will spit out all kinds of information related to what it's doing, in order to give you a better understanding of what's going on in case you're having trouble.
Expand Down
4 changes: 3 additions & 1 deletion common/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ const userAgents = [
]

export async function initBrowser() {
const config: Config = JSON.parse(fs.readFileSync('./config.json').toString())
const browser = await pup.launch({
headless: 'new',
args: ['--no-sandbox', '--disable-setuid-sandbox', '--disable-dev-shm-usage']
args: ['--no-sandbox', '--disable-setuid-sandbox', '--disable-dev-shm-usage'],
...(config.custom_chromium_exec && { executablePath: config.custom_chromium_exec })
})

global.browser = browser
Expand Down
3 changes: 2 additions & 1 deletion config.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
"required_perms":["permission_1", "permission_2"],
"tld":"com",
"auto_cart_link":true,
"debug_enabled":false
"debug_enabled":false,
"custom_chromium_exec":""
}
1 change: 1 addition & 0 deletions global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ interface Config {
tld: string
auto_cart_link: boolean
debug_enabled: boolean
custom_chromium_exec: string
}

interface Command {
Expand Down

0 comments on commit 3dfd4df

Please sign in to comment.