feat: add extraChromeArgs support for passing custom Chrome flags (#877)

This change introduces a new CLI option --extraChromeArgs to Browsertrix
Crawler, allowing users to pass arbitrary Chrome flags without modifying
the codebase.

This approach is future-proof: any Chrome flag can be provided at
runtime, avoiding the need for hard-coded allowlists.
Maintains backward compatibility: if no extraChromeArgs are passed,
behavior remains unchanged.

---------

Co-authored-by: Ilya Kreymer <ikreymer@users.noreply.github.com>
This commit is contained in:
aponb 2025-11-11 21:03:30 +01:00 committed by GitHub
parent 7dd13a9ec4
commit b50ef1230f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 1 deletions

View file

@ -592,7 +592,7 @@ export class Crawler {
}
extraChromeArgs() {
const args = [];
const args: string[] = [];
if (this.params.lang) {
if (this.params.profile) {
logger.warn(
@ -603,6 +603,16 @@ export class Crawler {
args.push(`--accept-lang=${this.params.lang}`);
}
}
const extra = this.params.extraChromeArgs;
if (Array.isArray(extra) && extra.length > 0) {
for (const v of extra) {
if (v) {
args.push(String(v));
}
}
}
return args;
}

View file

@ -691,6 +691,13 @@ class ArgParser {
"path to SSH known hosts file for SOCKS5 over SSH proxy connection",
type: "string",
},
extraChromeArgs: {
describe:
"Extra arguments to pass directly to the Chrome instance (space-separated or multiple --extraChromeArgs)",
type: "array",
default: [],
},
});
}