Browser

Stealth and Anti-Detection

Methods for reducing automation detection - CDP protection, toString overrides, dark mode, Google referrer spoofing, chromedriver patching, and stealth clicking.

Methods for reducing automation detection - CDP protection, toString overrides, dark mode, Google referrer spoofing, chromedriver patching, and stealth clicking.

WithUseStealth(StealthType) configures which anti-detection measures GPAL applies to the browser session. StealthType is a Flags enum, so multiple options can be combined with the bitwise OR operator. StealthType.CDP injects a script that hides Chrome DevTools Protocol detection signals before any page script runs. StealthType.ToStringOverride patches native function toString() output so automation-related overrides do not reveal themselves under inspection. StealthType.GoogleReferrer sets the HTTP referrer to look like the browser arrived from a Google search results page. StealthType.DarkMode launches Chrome with the force-dark-mode flag. StealthType.PatchChromeDriver patches the chromedriver binary itself to remove known automation markers before the browser launches. Use StealthType.All to enable every measure, or StealthType.None (the default) to disable stealth entirely. StealthLeftClick performs a left click while temporarily disabling the CDP Runtime domain around the click, reducing the chance the click is flagged as automated.

TIP

CDP protection, toString override, and Google referrer spoofing are applied once per browser session, the first time GoTo or Get runs. DarkMode and PatchChromeDriver take effect at browser launch, so call WithUseStealth before the first GoTo or Get.

WARNING

StealthType.CDP and StealthType.ToStringOverride have no effect when using the OttoMagic automation engine - they apply only to the Selenium and JavaScript-injection based engines.

Examples

GPAL Fluent: High-level fluent C# API

//WithUseStealth accepts a bitwise combination of StealthType flags and should be set before the first GoTo or Get call. StealthLeftClick takes the selector to click as a parameter, in addition to or instead of WithSelector.

// Enable a combination of stealth measures before navigating GPAL.Browser .WithBrowserType(BrowserType.Chrome) .WithUseStealth(StealthType.CDP | StealthType.ToStringOverride | StealthType.GoogleReferrer) .GoTo("https://example.com"); // Enable every stealth measure GPAL.Browser .WithUseStealth(StealthType.All) .GoTo("https://example.com"); // Patch chromedriver and force dark mode at launch GPAL.Browser .WithUseStealth(StealthType.PatchChromeDriver | StealthType.DarkMode) .GoTo("https://example.com"); // Stealth click on a login button GPAL.Browser .GoTo("https://example.com/login") .WithSelector("#login") .StealthLeftClick("#login");