Skip to content

Commit b50ef12

Browse files
aponbikreymer
andauthored
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 <[email protected]>
1 parent 7dd13a9 commit b50ef12

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/crawler.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ export class Crawler {
592592
}
593593

594594
extraChromeArgs() {
595-
const args = [];
595+
const args: string[] = [];
596596
if (this.params.lang) {
597597
if (this.params.profile) {
598598
logger.warn(
@@ -603,6 +603,16 @@ export class Crawler {
603603
args.push(`--accept-lang=${this.params.lang}`);
604604
}
605605
}
606+
607+
const extra = this.params.extraChromeArgs;
608+
if (Array.isArray(extra) && extra.length > 0) {
609+
for (const v of extra) {
610+
if (v) {
611+
args.push(String(v));
612+
}
613+
}
614+
}
615+
606616
return args;
607617
}
608618

src/util/argParser.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,13 @@ class ArgParser {
691691
"path to SSH known hosts file for SOCKS5 over SSH proxy connection",
692692
type: "string",
693693
},
694+
695+
extraChromeArgs: {
696+
describe:
697+
"Extra arguments to pass directly to the Chrome instance (space-separated or multiple --extraChromeArgs)",
698+
type: "array",
699+
default: [],
700+
},
694701
});
695702
}
696703

0 commit comments

Comments
 (0)