Stealth mode plugin for puppeteer-extra that applies various techniques to make detection of headless browsers harder.
npx @tessl/cli install tessl/npm-puppeteer-extra-plugin-stealth@2.11.0Puppeteer Extra Plugin Stealth is a comprehensive stealth mode plugin for puppeteer-extra and playwright-extra that applies various techniques to make detection of headless browsers harder. It provides 17 different evasion techniques that can be selectively enabled to avoid detection by anti-bot systems.
npm install puppeteer-extra-plugin-stealthconst StealthPlugin = require('puppeteer-extra-plugin-stealth');For TypeScript:
import StealthPlugin from 'puppeteer-extra-plugin-stealth';const puppeteer = require('puppeteer-extra');
const StealthPlugin = require('puppeteer-extra-plugin-stealth');
// Use stealth plugin with all evasions enabled
puppeteer.use(StealthPlugin());
// Launch browser with stealth mode
const browser = await puppeteer.launch({ headless: true });
const page = await browser.newPage();
// Navigate normally - stealth techniques are applied automatically
await page.goto('https://example.com');
await browser.close();Individual evasion techniques can be used independently without the main stealth plugin:
const puppeteer = require('puppeteer-extra');
// Use only specific evasions
puppeteer.use(require('puppeteer-extra-plugin-stealth/evasions/navigator.webdriver')());
puppeteer.use(require('puppeteer-extra-plugin-stealth/evasions/user-agent-override')());
const browser = await puppeteer.launch({ headless: true });The Puppeteer Extra Plugin Stealth is built around several key components:
StealthPlugin extends PuppeteerExtraPlugin and manages evasion techniquesMain plugin functionality for configuring and managing stealth evasions. Controls which evasion techniques are active and provides access to plugin metadata.
/**
* Creates a new stealth plugin instance
* @param opts - Configuration options
* @param opts.enabledEvasions - Set of evasion names to enable
* @returns StealthPlugin instance
*/
function StealthPlugin(opts?: {
enabledEvasions?: Set<string>;
}): StealthPlugin;
class StealthPlugin extends PuppeteerExtraPlugin {
/** Plugin identifier */
get name(): string;
/** Default configuration with all available evasions */
get defaults(): {
availableEvasions: Set<string>;
enabledEvasions: Set<string>;
};
/** Get all available evasion technique names */
get availableEvasions(): Set<string>;
/** Get/set currently enabled evasion techniques */
get enabledEvasions(): Set<string>;
set enabledEvasions(evasions: Set<string>): void;
/** Browser setup hook for configuring browser-level options */
onBrowser(browser: any): Promise<void>;
}Evasion techniques that mock Chrome-specific APIs to prevent detection through missing Chrome objects. These evasions simulate the presence of Chrome extension APIs.
// Available Chrome API evasions:
// - chrome.app: Mocks chrome.app API
// - chrome.csi: Mocks chrome.csi API
// - chrome.loadTimes: Mocks chrome.loadTimes API
// - chrome.runtime: Mocks chrome.runtime APIEvasion techniques that modify navigator properties to hide headless browser indicators. These techniques fix various navigator object properties that can reveal automation.
// Available Navigator evasions:
// - navigator.hardwareConcurrency: Fixes hardware concurrency reporting
// - navigator.languages: Fixes language array detection
// - navigator.permissions: Fixes permission API behavior
// - navigator.plugins: Mocks browser plugins
// - navigator.vendor: Overrides navigator.vendor property
// - navigator.webdriver: Removes webdriver propertyAdvanced evasion techniques that modify browser fingerprinting vectors including media codecs, WebGL properties, and user agent handling.
// Available fingerprinting evasions:
// - media.codecs: Fixes media codec detection
// - webgl.vendor: Fixes WebGL vendor information
// - user-agent-override: Comprehensive user agent managementBrowser Fingerprinting Evasions
Evasion techniques that fix window dimension and iframe-related detection methods.
// Available window/frame evasions:
// - window.outerdimensions: Fixes outer window dimensions in headless mode
// - iframe.contentWindow: Fixes iframe content window detectionAdditional evasion techniques for launch arguments and source code obfuscation.
// Available miscellaneous evasions:
// - defaultArgs: Modifies default Puppeteer launch arguments
// - sourceurl: Removes source URL traces from injected codeinterface StealthOptions {
/** Set of evasion technique names to enable (default: all available) */
enabledEvasions?: Set<string>;
}The following evasion techniques are available:
chrome.app - Mocks Chrome app APIchrome.csi - Mocks Chrome CSI APIchrome.loadTimes - Mocks Chrome loadTimes APIchrome.runtime - Mocks Chrome runtime APIdefaultArgs - Modifies default launch argumentsiframe.contentWindow - Fixes iframe detectionmedia.codecs - Fixes media codec fingerprintingnavigator.hardwareConcurrency - Fixes hardware concurrencynavigator.languages - Fixes language detectionnavigator.permissions - Fixes permission APInavigator.plugins - Mocks browser pluginsnavigator.vendor - Overrides navigator.vendor propertynavigator.webdriver - Removes webdriver propertysourceurl - Removes source URL tracesuser-agent-override - Comprehensive user agent handlingwebgl.vendor - Fixes WebGL vendor fingerprintingwindow.outerdimensions - Fixes window dimensions