From 16100e2e114278ab2eb639b2c994c316bde70803 Mon Sep 17 00:00:00 2001 From: shohu Date: Wed, 20 May 2026 08:48:41 +0900 Subject: [PATCH] feat(browse): extend GSTACK_CHROMIUM_PATH support to headless launch launchHeaded() already reads GSTACK_CHROMIUM_PATH to select a custom Chromium binary, but launch() (headless mode, the default $B goto path) ignores the env var and always falls back to Playwright's bundled binary. This change applies the same pattern to launch(): if GSTACK_CHROMIUM_PATH is set and the path exists, pass it as executablePath to chromium.launch(). If unset or the binary is missing, falls back to standard Playwright Chromium automatically (existsSync guard). Motivation: enables drop-in use of stealth Chromium forks (e.g. CloakBrowser) for headless automation without forking gstack or patching vendored files. --- browse/src/browser-manager.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/browse/src/browser-manager.ts b/browse/src/browser-manager.ts index cdbd5fc500..af78663d6d 100644 --- a/browse/src/browser-manager.ts +++ b/browse/src/browser-manager.ts @@ -236,6 +236,14 @@ export class BrowserManager { console.log(`[browse] Extensions loaded from: ${extensionsDir}`); } + // Support custom Chromium binary via GSTACK_CHROMIUM_PATH (same as launchHeaded). + // Falls back to standard Playwright Chromium when unset or path does not exist. + const headlessCloakPath = process.env.GSTACK_CHROMIUM_PATH; + const headlessCloakExec = headlessCloakPath && require('fs').existsSync(headlessCloakPath) + ? headlessCloakPath + : undefined; + if (headlessCloakExec) console.log(`[browse] Using custom Chromium: ${headlessCloakExec}`); + this.browser = await chromium.launch({ headless: useHeadless, // On Windows, Chromium's sandbox fails when the server is spawned through @@ -244,6 +252,7 @@ export class BrowserManager { chromiumSandbox: process.platform !== 'win32', ...(launchArgs.length > 0 ? { args: launchArgs } : {}), ...(this.proxyConfig ? { proxy: this.proxyConfig } : {}), + ...(headlessCloakExec ? { executablePath: headlessCloakExec } : {}), }); // Chromium crash → exit with clear message