=============== LIBRARY RULES =============== From library maintainers: - Use puppeteer-ghost as a drop-in replacement for puppeteer - Use ES6 import syntax (import puppeteer from 'puppeteer-ghost') instead of require for ESM projects - Import types from puppeteer-ghost for JSDoc and TypeScript: import('puppeteer-ghost').GhostLaunchOptions, GhostBrowser, GhostPage, ProxyConfig, TypeOptions - Use system Chrome (useSystemBrowser: true) for better stealth, defaults to true - This library does NOT support handling multiple pages - only use single page operations with browser.newPage() - Do NOT set defaultViewport to null (it's already null by default for full browser window), only set it if you need a specific size - While headless: false is the default for stealth, you can override it with headless: true when needed (e.g., for PDF generation, screenshots) - The enhanced page.click() includes human-like delays and randomized positioning by default, customize via options if needed - The enhanced page.type() has random delays (10-50ms) between keystrokes by default, use options.delay to customize - For scraping, always use proper waiting strategies: page.waitForSelector(), page.waitForFunction(), or page.waitForNavigation() before extracting data - All standard Puppeteer page methods work normally: page.pdf(), page.screenshot(), page.evaluate(), page.evaluateOnNewDocument(), etc. - To customize browser fingerprint, use page.evaluateOnNewDocument() to modify navigator properties before page scripts execute - Configure proxy through launch options with proxy object: { server: 'protocol://host:port', username: 'optional', password: 'optional' } - Proxy supports http://, https://, and socks5:// protocols - Never use --proxy-server in args, always use the proxy config object for proper authentication support - For resilient scraping with proxy rotation: close browser on detection, launch new browser with different proxy from list, retry failed URLs - Implement try-catch-finally blocks for robust scraping: try (scrape), catch (detect blocks/CAPTCHAs), finally (cleanup browser) - To load Chrome extensions, use: { pipe: true, enableExtensions: [extensionPath] } in launch options - Never use --disable-extensions-except or --load-extension args, always use enableExtensions array with pipe: true ### API: puppeteer.launch() Example Source: https://github.com/ovftank/puppeteer-ghost/blob/main/README.md Provides a concrete example of using the `puppeteer.launch` function with specific options, including headless mode and proxy configuration, to start an enhanced browser instance. ```javascript const browser = await puppeteer.launch({ headless: false, proxy: { server: 'http://proxy.example.com:8080', username: 'user', password: 'pass' } }); ``` -------------------------------- ### Quick Start: Launch Browser (CommonJS) Source: https://github.com/ovftank/puppeteer-ghost/blob/main/README.md Illustrates the basic usage of puppeteer-ghost in a CommonJS environment. This example shows how to require the library and launch a browser instance with default settings to navigate to a specified URL. ```javascript const puppeteer = require('puppeteer-ghost'); // Launch with optimized defaults - no configuration needed (async () => { const browser = await puppeteer.launch(); const page = await browser.newPage(); await page.goto('https://www.browserscan.net/'); })(); ``` -------------------------------- ### Quick Start: Launch Browser (ES Modules) Source: https://github.com/ovftank/puppeteer-ghost/blob/main/README.md Demonstrates the basic usage of puppeteer-ghost in an ES Modules environment. It shows how to import the library and launch a browser instance with default optimized settings to visit a webpage. ```javascript import puppeteer from 'puppeteer-ghost'; // Launch with optimized defaults - no configuration needed const browser = await puppeteer.launch(); const page = await browser.newPage(); await page.goto('https://www.browserscan.net/'); ``` -------------------------------- ### Install Puppeteer Ghost Source: https://github.com/ovftank/puppeteer-ghost/blob/main/README.md Installs the puppeteer-ghost package using npm, pnpm, or yarn. This is the initial step to integrate the library into your project. ```bash pnpm add puppeteer-ghost # or npm install puppeteer-ghost # or yarn add puppeteer-ghost ``` -------------------------------- ### Configure Browser Launch Options Source: https://github.com/ovftank/puppeteer-ghost/blob/main/README.md Shows how to customize the browser launch process using custom `GhostLaunchOptions`. This example demonstrates setting `headless` mode and providing specific browser arguments. ```javascript /** * @type {import('puppeteer-ghost').GhostLaunchOptions} */ const launchOptions = { headless: true, // Run in headless mode args: ['--window-size=1920,1080'] // Custom browser arguments }; const browser = await puppeteer.launch(launchOptions); ``` -------------------------------- ### Advanced Browser Configuration Source: https://github.com/ovftank/puppeteer-ghost/blob/main/README.md Provides an example of advanced configuration for launching the browser with puppeteer-ghost. This includes settings for `headless`, `defaultViewport`, `useSystemBrowser`, custom `args`, and proxy details. ```javascript /** * @type {import('puppeteer-ghost').GhostLaunchOptions} */ const advancedOptions = { headless: false, defaultViewport: { width: 1920, height: 1080 }, useSystemBrowser: true, // Use system Chrome (default: true) args: ['--disable-web-security', '--disable-features=VizDisplayCompositor'], proxy: { server: 'http://proxy.example.com:8080', username: 'user', password: 'pass' } }; ``` -------------------------------- ### Test Bot Detection Bypass with Puppeteer Ghost Source: https://context7.com/ovftank/puppeteer-ghost/llms.txt This example demonstrates testing anti-detection capabilities against common bot detection services using Puppeteer Ghost. It navigates through a list of test sites, checks for WebRTC leaks and webdriver detection, and takes screenshots. Ensure Puppeteer Ghost is installed and accessible. ```javascript import puppeteer from 'puppeteer-ghost'; async function testBotDetection() { const browser = await puppeteer.launch({ headless: false, defaultViewport: null }); const page = await browser.newPage(); // Test sites for bot detection const testSites = [ 'https://www.browserscan.net/', 'https://bot.sannysoft.com/', 'https://abrahamjuliot.github.io/creepjs/', 'https://pixelscan.net/' ]; for (const url of testSites) { console.log(`Testing: ${url}`); await page.goto(url, { waitUntil: 'networkidle2' }); // Wait for detection tests to complete await new Promise(resolve => setTimeout(resolve, 5000)); // Check for WebRTC leaks const webrtcBlocked = await page.evaluate(() => { return typeof window.RTCPeerConnection === 'undefined' && typeof navigator.mediaDevices === 'undefined'; }); console.log(`WebRTC blocked: ${webrtcBlocked}`); // Check for webdriver detection const webdriverPresent = await page.evaluate(() => { return navigator.webdriver; }); console.log(`Webdriver detected: ${webdriverPresent}`); // Take screenshot await page.screenshot({ path: `detection-test-${Date.now()}.png`, fullPage: true }); } await browser.close(); } testBotDetection(); ``` -------------------------------- ### Configure Proxy for Browser Traffic Routing Source: https://context7.com/ovftank/puppeteer-ghost/llms.txt Demonstrates `ProxyConfig` for routing browser traffic through proxy servers, supporting HTTP, HTTPS, and SOCKS5 protocols with optional authentication. This setup is crucial for masking IP addresses and accessing geo-restricted content. The example shows how to launch Puppeteer with a configured proxy and verifies traffic through an external IP check. ```javascript import puppeteer from 'puppeteer-ghost'; // HTTP proxy without authentication const httpProxy = { server: 'http://proxy.example.com:8080' }; // HTTPS proxy with authentication const httpsProxy = { server: 'https://secure-proxy.example.com:443', username: 'proxyuser', password: 'proxypass123' }; // SOCKS5 proxy const socks5Proxy = { server: 'socks5://socks-proxy.example.com:1080', username: 'sockuser', password: 'sockpass' }; // Use proxy in launch const browser = await puppeteer.launch({ proxy: httpsProxy }); const page = await browser.newPage(); await page.goto('https://api.ipify.org'); const response = await page.evaluate(() => document.body.textContent); console.log('Proxy IP:', response); await browser.close(); ``` -------------------------------- ### Load Chrome Extensions with Puppeteer Ghost Source: https://context7.com/ovftank/puppeteer-ghost/llms.txt This example demonstrates how to launch a browser with specific Chrome extensions loaded using Puppeteer Ghost. It requires the extensions to be present in the specified paths. The `pipe` option and non-headless mode are necessary for extension loading. ```javascript import puppeteer from 'puppeteer-ghost'; import path from 'path'; async function launchWithExtensions() { const extensionPath = path.join(process.cwd(), 'my-extension'); const adblockerPath = path.join(process.cwd(), 'ublock-origin'); const browser = await puppeteer.launch({ pipe: true, // Required for extensions headless: false, // Extensions require non-headless mode enableExtensions: [extensionPath, adblockerPath], args: [ `--disable-extensions-except=${extensionPath},${adblockerPath}`, `--load-extension=${extensionPath},${adblockerPath}` ] }); const page = await browser.newPage(); // Wait for extensions to load await new Promise(resolve => setTimeout(resolve, 2000)); // Navigate to page await page.goto('https://example.com'); // Interact with page await page.click('a.some-link'); await browser.close(); } launchWithExtensions(); ``` -------------------------------- ### Complete Web Scraping with Login and Data Extraction Source: https://context7.com/ovftank/puppeteer-ghost/llms.txt An end-to-end example of web scraping protected websites using Puppeteer Ghost. It covers launching the browser with proxy, navigating to a login page, simulating human-like form submission, accessing a data page, extracting structured data using `page.evaluate`, and taking a full-page screenshot. Error handling and browser closure are included. ```javascript import puppeteer from 'puppeteer-ghost'; async function scrapeProtectedSite() { const browser = await puppeteer.launch({ headless: false, proxy: { server: 'http://proxy.example.com:8080', username: 'user', password: 'pass' } }); try { const page = await browser.newPage(); // Navigate to login page await page.goto('https://protected-site.example.com/login', { waitUntil: 'networkidle2' }); // Fill login form with human-like typing await page.type('#email', 'user@example.com', { delay: 75 }); await page.type('#password', 'secure_password', { delay: 100 }); // Click login button await Promise.all([ page.waitForNavigation({ waitUntil: 'networkidle2' }), page.click('#login-button') ]); // Navigate to data page await page.goto('https://protected-site.example.com/data'); // Extract data const data = await page.evaluate(() => { const items = Array.from(document.querySelectorAll('.data-item')); return items.map(item => ({ title: item.querySelector('.title')?.textContent, value: item.querySelector('.value')?.textContent, timestamp: item.querySelector('.timestamp')?.textContent })); }); console.log('Extracted data:', data); // Take screenshot await page.screenshot({ path: 'result.png', fullPage: true }); return data; } catch (error) { console.error('Scraping failed:', error); throw error; } finally { await browser.close(); } } // Execute scraper scrapeProtectedSite() .then(data => console.log('Success:', data.length, 'items')) .catch(err => console.error('Error:', err.message)); ``` -------------------------------- ### Configure Ghost Launch Options with Anti-Detection Source: https://context7.com/ovftank/puppeteer-ghost/llms.txt Defines `GhostLaunchOptions` for launching Puppeteer with anti-detection capabilities. It supports standard Puppeteer arguments, system browser usage, proxy configuration, extension enablement, and custom executable paths. Dependencies include the 'puppeteer-ghost' package. ```javascript import puppeteer from 'puppeteer-ghost'; /** * @type {import('puppeteer-ghost').GhostLaunchOptions} */ const launchOptions = { // Standard Puppeteer options headless: false, defaultViewport: { width: 1920, height: 1080 }, args: [ '--no-sandbox', '--disable-setuid-sandbox', '--window-size=1920,1080' ], // Ghost-specific options useSystemBrowser: true, // Use system Chrome/Chromium proxy: { server: 'http://proxy.example.com:8080', username: 'optional_username', password: 'optional_password' }, // Extension support (requires pipe: true) pipe: true, enableExtensions: ['/path/to/extension'], // Custom browser path (overrides useSystemBrowser) executablePath: '/custom/path/to/chrome' }; const browser = await puppeteer.launch(launchOptions); ``` -------------------------------- ### Launch Browser with Puppeteer Ghost Source: https://context7.com/ovftank/puppeteer-ghost/llms.txt Launches a browser instance with anti-detection features enabled. Supports options for headless mode, viewport size, system browser usage, proxy configuration with authentication, and custom arguments or executable paths. ```javascript import puppeteer from 'puppeteer-ghost'; // Basic launch with default settings const browser = await puppeteer.launch(); const page = await browser.newPage(); await page.goto('https://bot-detector.example.com'); await browser.close(); // Advanced launch with custom configuration const browser = await puppeteer.launch({ headless: false, defaultViewport: { width: 1920, height: 1080 }, useSystemBrowser: true, proxy: { server: 'http://proxy.example.com:8080', username: 'proxyuser', password: 'proxypass' }, args: ['--window-size=1920,1080', '--disable-web-security'] }); // Using bundled Chromium instead of system browser const browserChromium = await puppeteer.launch({ useSystemBrowser: false, headless: true }); // Custom executable path const browserCustom = await puppeteer.launch({ executablePath: '/usr/bin/chromium-browser', headless: false }); ``` -------------------------------- ### GhostLaunchOptions Interface Source: https://github.com/ovftank/puppeteer-ghost/blob/main/README.md Defines the configuration options for launching a puppeteer-ghost browser instance, extending Puppeteer's standard launch options with additional properties for enhanced control. ```APIDOC ## GhostLaunchOptions ### Description Extends Puppeteer's `LaunchOptions` with additional anti-detection properties and proxy configuration. ### Properties - **proxy** (`ProxyConfig`) - Optional. Proxy configuration for routing traffic. - **useSystemBrowser** (`boolean`) - Optional. Use system browser instead of bundled Chromium (default: `true`). - **executablePath** (`string`) - Optional. Path to a specific browser executable. Overrides `useSystemBrowser`. - **headless** (`boolean | 'new'`) - Optional. Whether to run the browser in headless mode. - **defaultViewport** (`object | null`) - Optional. Sets the default viewport for new pages. - **args** (`string[]`) - Optional. Custom browser arguments. - **pipe** (`boolean`) - Optional. Whether to use the pipe transport for communication. Required for extensions. - **enableExtensions** (`string[]`) - Optional. An array of paths to Chrome extensions to load. ``` -------------------------------- ### puppeteer.launch() Source: https://github.com/ovftank/puppeteer-ghost/blob/main/README.md Launches a new browser instance with built-in anti-detection capabilities. Accepts optional launch options to customize the browser behavior. ```APIDOC ## puppeteer.launch(options?) ### Description Launches a new browser instance with built-in anti-detection capabilities. Allows for custom configuration through launch options. ### Method `puppeteer.launch` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```javascript // Launch with default options const browser = await puppeteer.launch(); // Launch with custom options including proxy const browser = await puppeteer.launch({ headless: false, proxy: { server: 'http://proxy.example.com:8080', username: 'user', password: 'pass' } }); ``` ### Response #### Success Response (200) - **browser** (GhostBrowser) - An enhanced browser instance with anti-detection features. #### Response Example ```json { "browser": "[Browser Object]" } ``` ``` -------------------------------- ### Puppeteer Ghost Launch API Source: https://context7.com/ovftank/puppeteer-ghost/llms.txt Launches a browser instance with anti-detection features enabled, including stealth mode, WebRTC blocking, and optional proxy support. ```APIDOC ## puppeteer.launch(options) ### Description Launches a browser instance with anti-detection features enabled, including stealth mode, WebRTC blocking, and optional proxy support. ### Method `puppeteer.launch(options)` ### Parameters #### Options - **`headless`** (boolean) - Optional - Whether to run the browser in headless mode. - **`defaultViewport`** (object) - Optional - Default viewport for the page (e.g., `{ width: 1920, height: 1080 }`). - **`useSystemBrowser`** (boolean) - Optional - Whether to use the system's installed browser instead of bundled Chromium. - **`proxy`** (object) - Optional - Proxy configuration with `server`, `username`, and `password` fields. - **`args`** (array) - Optional - Additional arguments to pass to the browser instance. - **`executablePath`** (string) - Optional - Path to a custom browser executable. ### Request Example ```javascript import puppeteer from 'puppeteer-ghost'; // Basic launch with default settings const browser = await puppeteer.launch(); // Advanced launch with custom configuration const browser = await puppeteer.launch({ headless: false, defaultViewport: { width: 1920, height: 1080 }, useSystemBrowser: true, proxy: { server: 'http://proxy.example.com:8080', username: 'proxyuser', password: 'proxypass' }, args: ['--window-size=1920,1080', '--disable-web-security'] }); // Using bundled Chromium instead of system browser const browserChromium = await puppeteer.launch({ useSystemBrowser: false, headless: true }); // Custom executable path const browserCustom = await puppeteer.launch({ executablePath: '/usr/bin/chromium-browser', headless: false }); ``` ### Response #### Success Response (Browser Instance) - **`browser`** (object) - A browser instance object. #### Response Example ```javascript // Successful launch returns a browser instance // Example response is not applicable as it returns an object ``` ``` -------------------------------- ### Configure Proxy Settings Source: https://github.com/ovftank/puppeteer-ghost/blob/main/README.md Illustrates how to configure proxy settings for the browser instance. This includes specifying the proxy server URL and optional authentication credentials (username and password). ```javascript /** * @type {import('puppeteer-ghost').ProxyConfig} */ const proxyConfig = { server: 'http://proxy.example.com:8080', username: 'your-username', // optional password: 'your-password' // optional }; const browser = await puppeteer.launch({ proxy: proxyConfig }); const page = await browser.newPage(); await page.goto('https://www.browserscan.net'); ``` -------------------------------- ### Create Enhanced Page Instance (JavaScript) Source: https://github.com/ovftank/puppeteer-ghost/blob/main/README.md Demonstrates how to create a new browser page using `browser.newPage()`, which automatically enables anti-detection features like WebRTC blocking and proxy authentication. Returns an enhanced `GhostPage` instance. ```javascript /** * @returns {Promise} Enhanced page instance */ const page = await browser.newPage(); ``` -------------------------------- ### Enable Chrome Extension Support Source: https://github.com/ovftank/puppeteer-ghost/blob/main/README.md Explains how to load Chrome extensions with puppeteer-ghost. This requires setting the `pipe` option to `true` and providing the path to the extension folder. ```javascript import path from 'path'; import fs from 'fs'; const extensionPath = path.join(process.cwd(), 'extension-folder'); const browser = await puppeteer.launch({ pipe: true, // required for extensions enableExtensions: [extensionPath] }); ``` -------------------------------- ### ProxyConfig Interface Source: https://github.com/ovftank/puppeteer-ghost/blob/main/README.md Defines the structure for configuring proxy settings, including the server address and optional authentication credentials. ```APIDOC ## ProxyConfig ### Description Configuration object for proxy settings. ### Properties - **server** (`string`) - Required. Proxy server URL (e.g., `http://host:port`, `https://host:port`, `socks5://host:port`). - **username** (`string`) - Optional. Authentication username for the proxy. - **password** (`string`) - Optional. Authentication password for the proxy. ``` -------------------------------- ### Browser New Page API Source: https://context7.com/ovftank/puppeteer-ghost/llms.txt Creates a new page with WebRTC blocking, proxy authentication, and enhanced interaction methods enabled. ```APIDOC ## browser.newPage() ### Description Creates a new page with WebRTC blocking, proxy authentication, and enhanced interaction methods enabled. ### Method `browser.newPage()` ### Parameters None ### Request Example ```javascript import puppeteer from 'puppeteer-ghost'; const browser = await puppeteer.launch({ proxy: { server: 'http://proxy.example.com:8080', username: 'user', password: 'pass' } }); // Create new page with anti-detection const page = await browser.newPage(); ``` ### Response #### Success Response (Page Instance) - **`page`** (object) - A page instance object. #### Response Example ```javascript // Successful creation returns a page instance // Example response is not applicable as it returns an object ``` ``` -------------------------------- ### Configure Browser Selection Source: https://github.com/ovftank/puppeteer-ghost/blob/main/README.md Demonstrates how to control which browser executable puppeteer-ghost uses. Options include using the system's Chrome, Puppeteer's bundled Chromium, or a custom executable path. ```javascript // Use system Chrome (default) const browser = await puppeteer.launch({ useSystemBrowser: true }); // Use Puppeteer's bundled Chromium const browser = await puppeteer.launch({ useSystemBrowser: false }); // Custom executable path (overrides useSystemBrowser) const browser = await puppeteer.launch({ executablePath: '/path/to/chrome' }); ``` -------------------------------- ### Create New Page with Puppeteer Ghost Source: https://context7.com/ovftank/puppeteer-ghost/llms.txt Creates a new browser page with pre-configured anti-detection features. This includes automatic WebRTC blocking and proxy authentication handling, ensuring privacy and security during web scraping or automation tasks. ```javascript import puppeteer from 'puppeteer-ghost'; const browser = await puppeteer.launch({ proxy: { server: 'http://proxy.example.com:8080', username: 'user', password: 'pass' } }); // Create new page with anti-detection const page = await browser.newPage(); // WebRTC is automatically blocked await page.goto('https://browserleaks.com/webrtc'); // Proxy authentication is automatically handled await page.goto('https://api.ipify.org'); const proxyIP = await page.evaluate(() => document.body.textContent); console.log('IP through proxy:', proxyIP); await browser.close(); ``` -------------------------------- ### Page Type API Source: https://context7.com/ovftank/puppeteer-ghost/llms.txt Types text into an element with human-like delays between keystrokes to simulate realistic typing behavior. ```APIDOC ## page.type(selector, text, options) ### Description Types text into an element with human-like delays between keystrokes to simulate realistic typing behavior. ### Method `page.type(selector, text, options)` ### Parameters #### Path Parameters - **`selector`** (string) - Required - A CSS selector to find the element to type into. - **`text`** (string) - Required - The text to type into the element. #### Query Parameters - **`delay`** (number) - Optional - Time to wait between each keystroke in milliseconds. Defaults to a random delay between 10ms and 50ms. ### Request Example ```javascript import puppeteer from 'puppeteer-ghost'; const browser = await puppeteer.launch(); const page = await browser.newPage(); await page.goto('https://example.com/login'); // Type with default random delay (10-50ms) await page.type('#username', 'john.doe@example.com'); // Type with custom delay await page.type('#password', 'SecureP@ssw0rd', { delay: 100 }); // Complex form filling await page.type('input[name="email"]', 'user@example.com', { delay: 75 }); await page.type('input[name="firstname"]', 'John'); await page.type('input[name="lastname"]', 'Doe'); await page.type('textarea[name="message"]', 'This is a test message with realistic typing speed.', { delay: 50 }); // Type and submit await page.type('#search-input', 'puppeteer ghost'); await page.click('#search-button'); await page.waitForSelector('.search-results'); await browser.close(); ``` ### Response #### Success Response (200) - **`void`** - This method does not return a value on success. #### Response Example ```javascript // No explicit response body for this method on success ``` ``` -------------------------------- ### Perform Human-like Click (JavaScript) Source: https://github.com/ovftank/puppeteer-ghost/blob/main/README.md Illustrates the usage of the `page.click()` method for performing clicks with human-like behavior. It includes randomized positioning and timing delays for more natural interactions. Accepts CSS selectors and optional click options. ```javascript /** * @param {string} selector - CSS selector to click * @param {MouseClickOptions} [options] - Click options * @returns {Promise} */ await page.click('#submit-button', { button: 'left' }); ``` -------------------------------- ### Define GhostPage Interface (TypeScript) Source: https://github.com/ovftank/puppeteer-ghost/blob/main/README.md Defines the `GhostPage` interface, extending Puppeteer's `Page` with methods for human-like clicking and typing. It includes options for randomized positioning, timing, and keystroke delays. ```typescript interface GhostPage extends Page { /** Click with randomized positioning and timing */ click(selector: string, options?: MouseClickOptions): Promise; /** Type with human-like delays between keystrokes */ type(selector: string, text: string, options?: TypeOptions): Promise; } ``` -------------------------------- ### Page Click API Source: https://context7.com/ovftank/puppeteer-ghost/llms.txt Clicks an element using human-like cursor movements with randomized positioning and natural timing delays. ```APIDOC ## page.click(selector, options) ### Description Clicks an element using human-like cursor movements with randomized positioning and natural timing delays. ### Method `page.click(selector, options)` ### Parameters #### Path Parameters - **`selector`** (string) - Required - A CSS selector to find the element to click. #### Query Parameters - **`button`** (string) - Optional - Defaults to `left`. The mouse button to use (`left`, `right`, `middle`). - **`clickCount`** (number) - Optional - Defaults to `1`. The number of times to click. - **`delay`** (number) - Optional - Time to wait between `mousedown` and `mouseup` in milliseconds. ### Request Example ```javascript import puppeteer from 'puppeteer-ghost'; const browser = await puppeteer.launch(); const page = await browser.newPage(); await page.goto('https://example.com/form'); // Simple click await page.click('#submit-button'); // Click with custom options await page.click('button[type="submit"]', { button: 'left', clickCount: 1, delay: 100 }); // Click on multiple elements sequentially await page.click('#checkbox1'); await page.click('#checkbox2'); await page.click('#checkbox3'); // Wait for navigation after click await Promise.all([ page.waitForNavigation({ waitUntil: 'networkidle2' }), page.click('a.next-page') ]); await browser.close(); ``` ### Response #### Success Response (200) - **`void`** - This method does not return a value on success. #### Response Example ```javascript // No explicit response body for this method on success ``` ``` -------------------------------- ### Define TypeOptions Interface (TypeScript) Source: https://github.com/ovftank/puppeteer-ghost/blob/main/README.md Defines the `TypeOptions` interface for customizing the behavior of the enhanced `type` method. It allows specifying the delay between keystrokes in milliseconds. ```typescript interface TypeOptions { /** Delay between keystrokes in milliseconds (default: random 10-50ms) */ delay?: number; } ``` -------------------------------- ### Perform Human-like Type (JavaScript) Source: https://github.com/ovftank/puppeteer-ghost/blob/main/README.md Shows how to use the `page.type()` method to input text into an element with human-like delays between keystrokes. This method takes a CSS selector, the text to type, and optional `TypeOptions` to control the typing speed. ```javascript /** * @param {string} selector - CSS selector to type into * @param {string} text - Text to type * @param {TypeOptions} [options] - Typing options * @returns {Promise} */ await page.type('#username', 'myusername', { delay: 100 }); ``` -------------------------------- ### Click Element with Human-like Behavior (Puppeteer Ghost) Source: https://context7.com/ovftank/puppeteer-ghost/llms.txt Simulates a mouse click on a specified element using human-like cursor movements and randomized positioning. It supports custom options for button type, click count, and delays, ensuring more natural interaction patterns. ```javascript import puppeteer from 'puppeteer-ghost'; const browser = await puppeteer.launch(); const page = await browser.newPage(); await page.goto('https://example.com/form'); // Simple click await page.click('#submit-button'); // Click with custom options await page.click('button[type="submit"]', { button: 'left', clickCount: 1, delay: 100 }); // Click on multiple elements sequentially await page.click('#checkbox1'); await page.click('#checkbox2'); await page.click('#checkbox3'); // Wait for navigation after click await Promise.all([ page.waitForNavigation({ waitUntil: 'networkidle2' }), page.click('a.next-page') ]); await browser.close(); ``` -------------------------------- ### Type Text with Realistic Delays (Puppeteer Ghost) Source: https://context7.com/ovftank/puppeteer-ghost/llms.txt Enables typing text into an input element with randomized delays between keystrokes, mimicking human typing behavior. This function helps bypass bot detection systems that monitor typing speed and patterns. It supports custom delay intervals. ```javascript import puppeteer from 'puppeteer-ghost'; const browser = await puppeteer.launch(); const page = await browser.newPage(); await page.goto('https://example.com/login'); // Type with default random delay (10-50ms) await page.type('#username', 'john.doe@example.com'); // Type with custom delay await page.type('#password', 'SecureP@ssw0rd', { delay: 100 }); // Complex form filling await page.type('input[name="email"]', 'user@example.com', { delay: 75 }); await page.type('input[name="firstname"]', 'John'); await page.type('input[name="lastname"]', 'Doe'); await page.type('textarea[name="message"]', 'This is a test message with realistic typing speed.', { delay: 50 }); // Type and submit await page.type('#search-input', 'puppeteer ghost'); await page.click('#search-button'); await page.waitForSelector('.search-results'); await browser.close(); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.