Stealth mode plugin for puppeteer-extra that applies various techniques to make detection of headless browsers harder.
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Core plugin functionality for configuring and managing stealth evasions. The main StealthPlugin class controls which evasion techniques are active and provides access to plugin metadata.
Creates a new stealth plugin instance with optional configuration.
/**
* Creates a new stealth plugin instance
* @param opts - Configuration options
* @param opts.enabledEvasions - Set of evasion names to enable (default: all available)
* @returns StealthPlugin instance ready to use with puppeteer-extra
*/
function StealthPlugin(opts?: {
enabledEvasions?: Set<string>;
}): StealthPlugin;Usage Examples:
const StealthPlugin = require('puppeteer-extra-plugin-stealth');
// Enable all evasions (default behavior)
const stealthPlugin = StealthPlugin();
// Enable only specific evasions
const customStealth = StealthPlugin({
enabledEvasions: new Set([
'navigator.webdriver',
'user-agent-override',
'chrome.runtime'
])
});
// Use with puppeteer-extra
const puppeteer = require('puppeteer-extra');
puppeteer.use(stealthPlugin);Main plugin class that extends PuppeteerExtraPlugin and manages stealth evasion techniques.
class StealthPlugin extends PuppeteerExtraPlugin {
/**
* Constructor for StealthPlugin
* @param opts - Configuration options object
*/
constructor(opts?: Record<string, any>);
}Unique identifier for the stealth plugin.
/**
* Plugin identifier name
* @returns Always returns 'stealth'
*/
get name(): string;Default configuration including all available evasion techniques.
/**
* Default plugin configuration
* @returns Object containing available and enabled evasions
*/
get defaults(): {
availableEvasions: Set<string>;
enabledEvasions: Set<string>;
};Get all available evasion technique names.
/**
* Get all available evasion techniques
* @returns Set of all available evasion technique names
*/
get availableEvasions(): Set<string>;The available evasions include:
chrome.appchrome.csichrome.loadTimeschrome.runtimedefaultArgsiframe.contentWindowmedia.codecsnavigator.hardwareConcurrencynavigator.languagesnavigator.permissionsnavigator.pluginsnavigator.webdriversourceurluser-agent-overridewebgl.vendorwindow.outerdimensionsGet or set which evasion techniques are currently enabled.
/**
* Get currently enabled evasion techniques
* @returns Set of enabled evasion technique names
*/
get enabledEvasions(): Set<string>;
/**
* Set which evasion techniques should be enabled
* @param evasions - Set of evasion technique names to enable
*/
set enabledEvasions(evasions: Set<string>): void;Usage Examples:
const stealth = StealthPlugin();
// View enabled evasions
console.log(stealth.enabledEvasions);
// Set { 'chrome.app', 'chrome.csi', ... all evasions }
// Remove specific evasion
stealth.enabledEvasions.delete('navigator.plugins');
// Add specific evasion back
stealth.enabledEvasions.add('navigator.plugins');
// Replace with custom set
stealth.enabledEvasions = new Set([
'navigator.webdriver',
'user-agent-override'
]);Browser-level configuration hook that executes when a browser instance is created.
/**
* Browser setup hook for configuring browser-level options
* @param browser - Browser instance from puppeteer
* @returns Promise that resolves when setup is complete
*/
onBrowser(browser: any): Promise<void>;This method:
Internal system for managing dynamic plugin dependencies based on enabled evasions.
/**
* Internal dependency management (private)
* @returns Set of plugin dependency paths
*/
get dependencies(): Set<string>;This property:
stealth/evasions/${evasionName}// Enable only navigator-related evasions
const navigatorStealth = StealthPlugin({
enabledEvasions: new Set([
'navigator.webdriver',
'navigator.languages',
'navigator.plugins',
'navigator.hardwareConcurrency',
'navigator.permissions'
])
});
// Enable only Chrome API evasions
const chromeStealth = StealthPlugin({
enabledEvasions: new Set([
'chrome.app',
'chrome.csi',
'chrome.loadTimes',
'chrome.runtime'
])
});const stealth = StealthPlugin();
// Start with all evasions, then remove problematic ones
stealth.enabledEvasions.delete('chrome.runtime');
stealth.enabledEvasions.delete('navigator.plugins');
// Or start minimal and add as needed
const minimal = StealthPlugin({
enabledEvasions: new Set(['navigator.webdriver'])
});
// Add more evasions later
minimal.enabledEvasions.add('user-agent-override');
minimal.enabledEvasions.add('window.outerdimensions');Install with Tessl CLI
npx tessl i tessl/npm-puppeteer-extra-plugin-stealth