Modular plugin framework to teach puppeteer new tricks through plugins.
npx @tessl/cli install tessl/npm-puppeteer-extra@2.1.0Puppeteer Extra is a modular plugin framework that acts as a drop-in replacement for Puppeteer while extending it with additional functionality through a clean plugin architecture. It enables developers to compose multiple plugins to enhance browser automation capabilities including stealth mode, user agent anonymization, resource blocking, reCAPTCHA solving, and developer tools integration.
npm install puppeteer puppeteer-extraconst puppeteer = require('puppeteer-extra');For ES modules:
import puppeteer from 'puppeteer-extra';Note: The module exports a singleton PuppeteerExtra instance, not the class itself.
const puppeteer = require('puppeteer-extra');
// Add plugins before browser launch
const StealthPlugin = require('puppeteer-extra-plugin-stealth');
puppeteer.use(StealthPlugin());
// Use exactly like regular Puppeteer
const browser = await puppeteer.launch({ headless: false });
const page = await browser.newPage();
await page.goto('https://example.com');
await browser.close();Puppeteer Extra is built around several key components:
Core functionality for registering and managing plugins that extend Puppeteer's capabilities.
/**
* Register a plugin with the framework
* @param plugin - Plugin instance extending PuppeteerExtraPlugin
* @returns The PuppeteerExtra instance for method chaining
*/
use(plugin): this;
/**
* Get all registered plugins
* @returns Array of registered plugin instances
*/
get plugins(): Array<PuppeteerExtraPlugin>;
/**
* Collect exposed data from all registered plugins
* @param name - Optional filter by plugin name
* @returns Array of plugin data objects
*/
getPluginData(name?: string): Array<Object>;Enhanced browser launch and connection methods with plugin lifecycle integration.
/**
* Launch a new browser instance with plugin lifecycle support
* @param options - Regular Puppeteer launch options
* @returns Promise resolving to Browser instance
*/
launch(options?: Object): Promise<Puppeteer.Browser>;
/**
* Connect to existing Chromium instance with plugin lifecycle support
* @param options - Connection options with browserWSEndpoint and ignoreHTTPSErrors
* @returns Promise resolving to Browser instance
*/
connect(options?: {
browserWSEndpoint: string;
ignoreHTTPSErrors?: boolean;
}): Promise<Puppeteer.Browser>;Standard Puppeteer methods that are passed through unchanged for full compatibility.
/**
* Get the path to the bundled Chromium executable
* @returns Path to Chromium executable
*/
executablePath(): string;
/**
* Get default launch arguments for Chromium
* @returns Array of default launch arguments
*/
defaultArgs(): Array<string>;
/**
* Create a browser fetcher for downloading Chromium
* @param options - Fetcher configuration options
* @returns BrowserFetcher instance
*/
createBrowserFetcher(options?: Object): PuppeteerBrowserFetcher;/**
* Base class that all plugins must extend
*/
class PuppeteerExtraPlugin {
/** Plugin name identifier */
name: string;
/** Set of plugin requirements ('launch', 'headful', 'dataFromPlugins', 'runLast') */
requirements: Set<string>;
/** Set of plugin dependencies (auto-resolved plugin names) */
dependencies: Set<string>;
/** Plugin-specific data for sharing with other plugins */
data: Array<{ name: string; value: any }>;
/** Plugin configuration options */
opts: Object;
/** Debug logger function */
debug: Function;
/** Whether this is a valid PuppeteerExtraPlugin */
_isPuppeteerExtraPlugin: boolean;
}
/**
* Puppeteer Browser Fetcher for downloading Chromium
*/
interface PuppeteerBrowserFetcher {
/** Download a specific revision of Chromium */
download(revision: string): Promise<Object>;
/** Get path to downloaded revision */
revisionInfo(revision: string): Object;
/** Remove a downloaded revision */
remove(revision: string): Promise<void>;
/** List all downloaded revisions */
localRevisions(): Array<string>;
}
/**
* Plugin configuration options
*/
interface PluginOptions {
[key: string]: any;
}
/**
* Plugin data structure for sharing between plugins
*/
interface PluginData {
name: string;
value: any;
}Puppeteer Extra maintains the same error handling patterns as standard Puppeteer. Plugin-related errors include:
Popular plugins that extend Puppeteer Extra functionality: