Understand Patchright's anti-detection patches
mainPatchright applies several patches to the Playwright/Chromium stack to avoid common detection vectors:
- Runtime.enable Leak: Avoids using
Runtime.enableby executing JavaScript in isolatedExecutionContexts. - Console.enable Leak: Disables the
ConsoleAPI entirely to prevent detection. Note that this means standard console functionality will not work. - Command Flags Leaks: Tweaks default arguments to avoid detection. Specifically:
- Adds
--disable-blink-features=AutomationControlledto avoidnavigator.webdriverdetection. - Removes
--enable-automationto avoidnavigator.webdriverdetection. - Removes
--disable-popup-blocking,--disable-component-update,--disable-default-apps, and--disable-extensionsto avoid various stealth driver and feature-based detections.
- Adds
- Closed Shadow Roots: Patchright allows interacting with elements inside Closed Shadow Roots using standard locators and XPaths.