mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 13:34:58 +00:00
feat(browser): add extraArgs config for custom Chrome launch arguments
Adds a `browser.extraArgs` config option (string array) that is appended to Chrome's launch arguments. This enables users to add stealth flags, window size overrides, custom user-agent strings, or other Chrome flags without patching the source code. Example config: browser.extraArgs: ["--window-size=1920,1080", "--disable-infobars"] Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
committed by
Peter Steinberger
parent
de900bace8
commit
039fc1e04c
@@ -217,6 +217,11 @@ export async function launchOpenClawChrome(
|
|||||||
// Stealth: hide navigator.webdriver from automation detection (#80)
|
// Stealth: hide navigator.webdriver from automation detection (#80)
|
||||||
args.push("--disable-blink-features=AutomationControlled");
|
args.push("--disable-blink-features=AutomationControlled");
|
||||||
|
|
||||||
|
// Append user-configured extra arguments (e.g., stealth flags, window size)
|
||||||
|
if (resolved.extraArgs.length > 0) {
|
||||||
|
args.push(...resolved.extraArgs);
|
||||||
|
}
|
||||||
|
|
||||||
// Always open a blank tab to ensure a target exists.
|
// Always open a blank tab to ensure a target exists.
|
||||||
args.push("about:blank");
|
args.push("about:blank");
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ export type ResolvedBrowserConfig = {
|
|||||||
attachOnly: boolean;
|
attachOnly: boolean;
|
||||||
defaultProfile: string;
|
defaultProfile: string;
|
||||||
profiles: Record<string, BrowserProfileConfig>;
|
profiles: Record<string, BrowserProfileConfig>;
|
||||||
|
extraArgs: string[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ResolvedBrowserProfile = {
|
export type ResolvedBrowserProfile = {
|
||||||
@@ -196,6 +197,10 @@ export function resolveBrowserConfig(
|
|||||||
? DEFAULT_BROWSER_DEFAULT_PROFILE_NAME
|
? DEFAULT_BROWSER_DEFAULT_PROFILE_NAME
|
||||||
: DEFAULT_OPENCLAW_BROWSER_PROFILE_NAME);
|
: DEFAULT_OPENCLAW_BROWSER_PROFILE_NAME);
|
||||||
|
|
||||||
|
const extraArgs = Array.isArray(cfg?.extraArgs)
|
||||||
|
? cfg.extraArgs.filter((a): a is string => typeof a === "string" && a.trim().length > 0)
|
||||||
|
: [];
|
||||||
|
|
||||||
return {
|
return {
|
||||||
enabled,
|
enabled,
|
||||||
evaluateEnabled,
|
evaluateEnabled,
|
||||||
@@ -212,6 +217,7 @@ export function resolveBrowserConfig(
|
|||||||
attachOnly,
|
attachOnly,
|
||||||
defaultProfile,
|
defaultProfile,
|
||||||
profiles,
|
profiles,
|
||||||
|
extraArgs,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,4 +38,10 @@ export type BrowserConfig = {
|
|||||||
profiles?: Record<string, BrowserProfileConfig>;
|
profiles?: Record<string, BrowserProfileConfig>;
|
||||||
/** Default snapshot options (applied by the browser tool/CLI when unset). */
|
/** Default snapshot options (applied by the browser tool/CLI when unset). */
|
||||||
snapshotDefaults?: BrowserSnapshotDefaults;
|
snapshotDefaults?: BrowserSnapshotDefaults;
|
||||||
|
/**
|
||||||
|
* Additional Chrome launch arguments.
|
||||||
|
* Useful for stealth flags, window size overrides, or custom user-agent strings.
|
||||||
|
* Example: ["--window-size=1920,1080", "--disable-infobars"]
|
||||||
|
*/
|
||||||
|
extraArgs?: string[];
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user