### Install camoufox-js Source: https://github.com/lamualfa/camoufox-js/blob/master/README.md This command installs the camoufox-js package using npm. Ensure you have Node.js and npm installed. ```bash npm install camoufox-js ``` -------------------------------- ### Configure Custom Paths for camoufox-js Source: https://github.com/lamualfa/camoufox-js/blob/master/README.md Illustrates how to specify custom installation and data directories, as well as custom executable names for different operating systems when launching Camoufox. All path options are optional and will use defaults if not provided. ```javascript import { Camoufox, type CamoufoxPaths } from 'camoufox-js'; const customPaths: CamoufoxPaths = { installationDirectory: '/custom/install/dir', // Directory where Camoufox is installed dataDirectory: '/custom/data/dir', // Directory containing local data files executableNames: { win: 'custom.exe', mac: '../MacOS/custom', lin: 'custom-bin' } }; const browser = await Camoufox({ paths: customPaths }); ``` -------------------------------- ### Browser Installation Management with Camoufox.js Source: https://context7.com/lamualfa/camoufox-js/llms.txt Programmatically manage Camoufox browser installations, including checking the installed version, determining installation paths, and performing manual installations or cleanup. This utility is essential for automating browser setup and management in various environments. ```javascript import { CamoufoxFetcher, camoufoxPath, installedVerStr, launchPath } from 'camoufox-js'; // Check installed version try { const version = installedVerStr(); console.log('Installed version:', version); } catch (error) { console.log('Camoufox not installed'); } // Get installation path const installPath = camoufoxPath(false); // Don't auto-download console.log('Install path:', installPath); // Get executable path const execPath = launchPath(); console.log('Executable:', execPath); // Manual installation const fetcher = new CamoufoxFetcher(); await fetcher.init(); console.log('Latest version:', fetcher.version); console.log('Download URL:', fetcher.url); await fetcher.install(); console.log('Installation complete'); // Custom installation directory await fetcher.install({ installationDirectory: '/opt/camoufox' }); // Cleanup installation CamoufoxFetcher.cleanup('/opt/camoufox'); ``` -------------------------------- ### Camoufox Custom Paths Configuration with JavaScript Source: https://context7.com/lamualfa/camoufox-js/llms.txt Configures custom installation directories and executable names for Camoufox browser management. This allows users to specify non-standard locations for Camoufox binaries and data. Requires 'camoufox-js' library. ```javascript import { Camoufox, type CamoufoxPaths } from 'camoufox-js'; const customPaths = { installationDirectory: '/opt/camoufox', dataDirectory: '/var/lib/camoufox/data', executableNames: { win: 'camoufox.exe', mac: '../MacOS/camoufox', lin: 'camoufox-bin' } }; const browser = await Camoufox({ paths: customPaths, headless: true }); const page = await browser.newPage(); await page.goto('https://example.com'); await browser.close(); ``` -------------------------------- ### Generate Playwright Launch Options for Camoufox Source: https://context7.com/lamualfa/camoufox-js/llms.txt Generates Playwright launch options for Camoufox without directly launching the browser, offering granular control over browser configuration. This function is useful for integrating Camoufox with existing Playwright setups. Dependencies include 'camoufox-js' and 'playwright-core'. ```javascript import { launchOptions } from 'camoufox-js'; import { firefox } from 'playwright-core'; // Generate launch options with custom configuration const options = await launchOptions({ os: 'linux', headless: true, geoip: '8.8.8.8', // Spoof location for specific IP locale: 'fr-FR', fingerprint: undefined, // Auto-generate firefox_user_prefs: { 'network.http.http3.enable': false, 'browser.cache.disk.enable': false }, screen: { minWidth: 1280, maxWidth: 1920, minHeight: 720, maxHeight: 1080 }, debug: true // Print config to console }); // Launch with additional Playwright options const browser = await firefox.launch({ ...options, timeout: 60000, slowMo: 100 }); const page = await browser.newPage(); await page.goto('https://example.com'); await browser.close(); ``` -------------------------------- ### Basic Usage of camoufox-js Source: https://github.com/lamualfa/camoufox-js/blob/master/README.md Demonstrates how to launch a Playwright-controlled Camoufox instance using the camoufox-js library. It imports the Camoufox class and creates a new page. The `npx camoufox-js fetch` command may be required to download the browser. ```javascript import { Camoufox } from 'camoufox-js'; // you might need to run `npx camoufox-js fetch` to download the browser after installing the package const browser = await Camoufox({ // custom camoufox options }); const page = await browser.newPage(); // `page` is a Playwright Page instance ``` -------------------------------- ### Launch camoufox-js with Playwright Options Source: https://github.com/lamualfa/camoufox-js/blob/master/README.md Shows how to launch Camoufox with additional Playwright launch options by merging the options returned by `launchOptions` with custom Playwright configurations. This allows for more fine-grained control over the browser instance. The `npx camoufox-js fetch` command may be required. ```javascript import { launchOptions } from 'camoufox-js'; import { firefox } from 'playwright-core'; // you might need to run `npx camoufox-js fetch` to download the browser after installing the package const browser = await firefox.launch({ ...await launchOptions({ /* Camoufox options */ }), // other Playwright options, overriding the Camoufox options }); const page = await browser.newPage(); // `page` is a Playwright Page instance ``` -------------------------------- ### Configure Camoufox Browser with Advanced Options Source: https://context7.com/lamualfa/camoufox-js/llms.txt This snippet demonstrates initializing Camoufox with a comprehensive set of advanced configuration options. It includes settings for operating system, network (proxy, geoip), fingerprinting (window size, fonts), behavior (humanize, block_images), locale, caching, addons, Firefox user preferences, and debug/headless modes. The configuration is validated, and the browser instance is used to navigate to a webpage. ```javascript import { Camoufox } from 'camoufox-js'; import { FingerprintGenerator } from 'fingerprint-generator'; const browser = await Camoufox({ // Operating system os: ['windows', 'macos'], // Network configuration proxy: { server: 'http://proxy.example.com:8080', username: 'user', password: 'pass', bypass: 'localhost,127.0.0.1' }, geoip: true, // Fingerprinting window: [1920, 1080], fonts: ['Arial', 'Helvetica', 'Times New Roman'], custom_fonts_only: false, webgl_config: ['Intel Inc.', 'Intel HD Graphics'], // Behavior humanize: 2.0, // Humanize cursor up to 2 seconds block_images: false, block_webrtc: false, disable_coop: false, // Locale locale: ['en-US', 'en'], // Performance enable_cache: true, // Addons addons: ['/path/to/custom/addon'], exclude_addons: [], // Firefox preferences firefox_user_prefs: { 'network.http.http2.enabled': true, 'privacy.trackingprotection.enabled': false, 'dom.webdriver.enabled': false }, // Debug debug: false, headless: true }); const page = await browser.newPage(); await page.goto('https://httpbin.org/headers'); // Use main world eval (if enabled) const browserWithMainWorld = await Camoufox({ main_world_eval: true, headless: true }); const page2 = await browserWithMainWorld.newPage(); await page2.evaluate('mw:console.log("Running in main world")'); await browser.close(); await browserWithMainWorld.close(); ``` -------------------------------- ### Launch camoufox-js as a Remote Server Source: https://github.com/lamualfa/camoufox-js/blob/master/README.md Demonstrates how to launch Camoufox as a remote websocket server, accessible from other devices and languages. It shows how to configure the server port, websocket path, and custom paths, then connect to the server using Playwright's `connect` method. The server and browser should be closed when done. ```javascript import { launchServer, type CamoufoxPaths } from 'camoufox-js'; import { firefox } from 'playwright-core'; // you might need to run `npx camoufox-js fetch` to download the browser after installing the package const customPaths: CamoufoxPaths = { installationDirectory: '/custom/install/dir' }; const server = await launchServer({ port: 8888, ws_path: '/camoufox', paths: customPaths }); const browser = await firefox.connect(server.wsEndpoint()); const page = await browser.newPage(); // ... // Use your browser instance as usual // ... await browser.close(); await server.close(); // Close the server when done ``` -------------------------------- ### Launch Camoufox Browser Instance with Playwright Source: https://context7.com/lamualfa/camoufox-js/llms.txt Launches a Playwright-controlled Camoufox browser instance with automatic fingerprint generation and anti-detection features. It supports basic usage with default fingerprints or advanced configuration including geolocation, proxy, locale, and humanized cursor movements. Dependencies include 'camoufox-js' and 'playwright-core'. ```javascript import { Camoufox } from 'camoufox-js'; // Basic usage with default fingerprint const browser = await Camoufox({ headless: true, os: 'windows' }); const page = await browser.newPage(); await page.goto('https://example.com'); const userAgent = await page.evaluate(() => navigator.userAgent); console.log('User Agent:', userAgent); await browser.close(); // Advanced configuration with geolocation and proxy const browserWithGeo = await Camoufox({ os: ['linux', 'macos'], // Randomly choose from these geoip: true, // Auto-detect IP and set geolocation proxy: 'http://user:pass@proxy.example.com:8080', locale: 'en-US', humanize: 1.5, // Max 1.5 seconds for cursor movement addons: ['/path/to/custom/addon'], block_images: false, block_webrtc: false, enable_cache: true, window: [1920, 1080] }); const page2 = await browserWithGeo.newPage(); await page2.goto('https://browserleaks.com'); await page2.screenshot({ path: 'fingerprint.png' }); await browserWithGeo.close(); ``` -------------------------------- ### Camoufox: Launch Browser Source: https://context7.com/lamualfa/camoufox-js/llms.txt Launches a Playwright-controlled Camoufox browser instance with automatic fingerprint generation and anti-detection features. Supports various configurations for headless operation, OS, geolocation, proxies, and more. ```APIDOC ## Camoufox ### Description Launches a Playwright-controlled Camoufox browser instance with automatic fingerprint generation and anti-detection features. ### Method Function Call ### Endpoint N/A (Client-side library function) ### Parameters #### Function Parameters - **headless** (boolean) - Optional - Whether to run the browser in headless mode. - **os** (string | string[]) - Optional - The operating system to emulate. Can be a single OS string or an array of OS strings to randomly choose from. - **geoip** (boolean | string) - Optional - Enables IP geolocation spoofing. If a string is provided, it should be an IP address to spoof. - **proxy** (string) - Optional - The proxy server URL to use for the browser instance. - **locale** (string) - Optional - The locale to set for the browser. - **humanize** (number) - Optional - The maximum duration in seconds for humanized cursor movements. - **addons** (string[]) - Optional - An array of paths to custom browser extensions. - **block_images** (boolean) - Optional - Whether to block image loading. - **block_webrtc** (boolean) - Optional - Whether to block WebRTC. - **enable_cache** (boolean) - Optional - Whether to enable browser cache. - **window** (number[]) - Optional - An array specifying the window size [width, height]. ### Request Example ```javascript import { Camoufox } from 'camoufox-js'; // Basic usage with default fingerprint const browser = await Camoufox({ headless: true, os: 'windows' }); const page = await browser.newPage(); await page.goto('https://example.com'); console.log(await page.evaluate(() => navigator.userAgent)); await browser.close(); // Advanced configuration with geolocation and proxy const browserWithGeo = await Camoufox({ os: ['linux', 'macos'], geoip: true, proxy: 'http://user:pass@proxy.example.com:8080', locale: 'en-US', humanize: 1.5, addons: ['/path/to/custom/addon'], block_images: false, block_webrtc: false, enable_cache: true, window: [1920, 1080] }); await browserWithGeo.close(); ``` ### Response #### Success Response - **browser** (object) - A Playwright browser instance configured with Camoufox settings. ``` -------------------------------- ### launchServer: Launch Camoufox WebSocket Server Source: https://context7.com/lamualfa/camoufox-js/llms.txt Launches Camoufox as a remote WebSocket server, accessible from other devices or languages that support Playwright remote connections. ```APIDOC ## launchServer ### Description Launches Camoufox as a remote WebSocket server that can be accessed from other devices or languages supporting Playwright. ### Method Function Call ### Endpoint N/A (Client-side library function) ### Parameters #### Function Parameters - **port** (number) - Optional - The port to run the WebSocket server on. Defaults to a random available port. - **ws_path** (string) - Optional - The WebSocket path for the server. Defaults to '/camoufox'. - **os** (string) - Optional - The operating system to emulate. - **headless** (boolean) - Optional - Whether to run the browser in headless mode. - **geoip** (boolean | string) - Optional - Enables IP geolocation spoofing. If a string is provided, it should be an IP address to spoof. ### Request Example ```javascript import { launchServer } from 'camoufox-js'; import { firefox } from 'playwright-core'; const server = await launchServer({ port: 8888, ws_path: '/camoufox', os: 'windows', headless: true, geoip: true }); console.log('Server endpoint:', server.wsEndpoint()); const browser = await firefox.connect(server.wsEndpoint()); const page = await browser.newPage(); await page.goto('https://httpbin.org/headers'); console.log(await page.textContent('body')); await browser.close(); await server.close(); ``` ### Response #### Success Response - **server** (object) - An object representing the running WebSocket server, with a `wsEndpoint()` method to get the server URL and a `close()` method to shut it down. ``` -------------------------------- ### launchOptions: Generate Playwright Launch Options Source: https://context7.com/lamualfa/camoufox-js/llms.txt Generates Playwright launch options for Camoufox without directly launching the browser, allowing for fine-grained control over browser configuration. ```APIDOC ## launchOptions ### Description Generates Playwright launch options for Camoufox without directly launching the browser, providing fine-grained control over browser configuration. ### Method Function Call ### Endpoint N/A (Client-side library function) ### Parameters #### Function Parameters - **os** (string) - Optional - The operating system to emulate. - **headless** (boolean) - Optional - Whether to run the browser in headless mode. - **geoip** (boolean | string) - Optional - Enables IP geolocation spoofing. If a string is provided, it should be an IP address to spoof. - **locale** (string) - Optional - The locale to set for the browser. - **fingerprint** (object | undefined) - Optional - A fingerprint object to use. If undefined, a fingerprint will be auto-generated. - **firefox_user_prefs** (object) - Optional - Custom Firefox user preferences. - **screen** (object) - Optional - Screen resolution settings (`minWidth`, `maxWidth`, `minHeight`, `maxHeight`). - **debug** (boolean) - Optional - Enables debug logging to the console. ### Request Example ```javascript import { launchOptions } from 'camoufox-js'; import { firefox } from 'playwright-core'; const options = await launchOptions({ os: 'linux', headless: true, geoip: '8.8.8.8', locale: 'fr-FR', screen: { minWidth: 1280, maxWidth: 1920, minHeight: 720, maxHeight: 1080 }, debug: true }); const browser = await firefox.launch({ ...options, timeout: 60000, slowMo: 100 }); await browser.close(); ``` ### Response #### Success Response - **options** (object) - Playwright launch options suitable for `playwright-core.launch()`. ``` -------------------------------- ### Camoufox Addon Management with JavaScript Source: https://context7.com/lamualfa/camoufox-js/llms.txt Manages Firefox addons, including loading default addons like uBlock Origin and custom extensions from local paths or URLs. Supports excluding default addons and manually downloading/extracting custom addons. Requires 'camoufox-js' library. ```javascript import { Camoufox, DefaultAddons, addDefaultAddons, downloadAndExtract } from 'camoufox-js'; // Launch with default addons (uBlock Origin) const browser1 = await Camoufox({ headless: true }); // Exclude default addons const browser2 = await Camoufox({ exclude_addons: ['UBO'], headless: true }); // Add custom addons const browser3 = await Camoufox({ addons: [ '/path/to/extracted/addon/directory', 'https://addons.mozilla.org/firefox/downloads/file/123/addon.xpi' ], headless: true }); // Manually download addon await downloadAndExtract( 'https://example.com/addon.xpi', '/tmp/my-addon', 'My Custom Addon' ); const browser4 = await Camoufox({ addons: ['/tmp/my-addon'], headless: true }); await browser1.close(); await browser2.close(); await browser3.close(); await browser4.close(); ``` -------------------------------- ### Launch Camoufox as a Remote WebSocket Server Source: https://context7.com/lamualfa/camoufox-js/llms.txt Launches Camoufox as a remote WebSocket server, enabling connections from other devices or languages that support Playwright. This facilitates distributed testing or remote browser automation. Dependencies include 'camoufox-js' and 'playwright-core'. ```javascript import { launchServer } from 'camoufox-js'; import { firefox } from 'playwright-core'; // Launch server on custom port const server = await launchServer({ port: 8888, ws_path: '/camoufox', os: 'windows', headless: true, geoip: true }); console.log('Server endpoint:', server.wsEndpoint()); // Output: ws://localhost:8888/camoufox // Connect from same process const browser = await firefox.connect(server.wsEndpoint()); const page = await browser.newPage(); await page.goto('https://httpbin.org/headers'); const content = await page.textContent('body'); console.log('Response:', content); await browser.close(); await server.close(); // Connect from another process or device // const remoteBrowser = await firefox.connect('ws://server-ip:8888/camoufox'); ``` -------------------------------- ### Camoufox Persistent Context with JavaScript Source: https://context7.com/lamualfa/camoufox-js/llms.txt Launches Camoufox with a persistent user data directory to maintain cookies, local storage, and session data across multiple browser instances. This is useful for scenarios requiring state to be carried over between sessions. Dependencies include 'camoufox-js' and Node.js built-in 'fs/promises', 'os', and 'path' modules. ```javascript import { Camoufox } from 'camoufox-js'; import { mkdtemp } from 'node:fs/promises'; import { tmpdir } from 'node:os'; import { join } from 'node:path'; // Create persistent profile directory const userDataDir = await mkdtemp(join(tmpdir(), 'camoufox_profile_')); // First session - set cookies const context1 = await Camoufox({ user_data_dir: userDataDir, headless: true, os: 'linux' }); const page1 = await context1.newPage(); await page1.goto('https://example.com'); await page1.evaluate(() => { document.cookie = 'session=abc123; path=/; max-age=86400'; localStorage.setItem('user_id', '12345'); }); await context1.close(); // Second session - cookies persist const context2 = await Camoufox({ user_data_dir: userDataDir, headless: true }); const page2 = await context2.newPage(); await page2.goto('https://example.com'); const cookies = await page2.evaluate(() => document.cookie); const userId = await page2.evaluate(() => localStorage.getItem('user_id')); console.log('Cookies:', cookies); // session=abc123 console.log('User ID:', userId); // 12345 await context2.close(); ``` -------------------------------- ### Camoufox Fingerprint Generation with JavaScript Source: https://context7.com/lamualfa/camoufox-js/llms.txt Generates and applies custom browser fingerprints using BrowserForge integration for advanced spoofing scenarios. Supports auto-generated fingerprints and custom configurations with specific browser and OS combinations. Requires 'camoufox-js' and 'fingerprint-generator'. Input includes screen dimensions and window size. ```javascript import { Camoufox, launchOptions } from 'camoufox-js'; import { FingerprintGenerator } from 'fingerprint-generator'; // Auto-generated fingerprint (default) const browser1 = await Camoufox({ os: 'macos', screen: { minWidth: 1920, maxWidth: 2560, minHeight: 1080, maxHeight: 1440 }, window: [1920, 1080] }); // Custom fingerprint with BrowserForge const fpGenerator = new FingerprintGenerator({ browsers: ['firefox'], operatingSystems: ['macos'] }); const { fingerprint } = fpGenerator.getFingerprint(); const options = await launchOptions({ fingerprint: fingerprint, i_know_what_im_doing: true // Skip safety checks }); // Fingerprint is injected into browser await browser1.close(); ``` -------------------------------- ### Locale Configuration with Camoufox.js Source: https://context7.com/lamualfa/camoufox-js/llms.txt Configure browser locale, language preferences, and Accept-Language headers with support for regional variations. This allows setting a single locale, multiple locales with priority, or auto-detecting the locale based on geolocation data. ```javascript import { Camoufox } from 'camoufox-js'; // Single locale const browser1 = await Camoufox({ locale: 'fr-FR', headless: true }); // Multiple locales with priority const browser2 = await Camoufox({ locale: ['en-GB', 'en-US', 'en'], headless: true }); // Auto-detect locale from geoip const browser3 = await Camoufox({ geoip: true, // Locale set based on IP location headless: true }); const page = await browser2.newPage(); await page.goto('https://example.com'); const languages = await page.evaluate(() => navigator.languages); const locale = await page.evaluate(() => navigator.language); console.log('Languages:', languages); // ['en-GB', 'en-US', 'en'] console.log('Locale:', locale); // 'en-GB' await browser1.close(); await browser2.close(); await browser3.close(); ``` -------------------------------- ### Camoufox Virtual Display Mode with JavaScript Source: https://context7.com/lamualfa/camoufox-js/llms.txt Runs Camoufox in a virtual X11 display (Xvfb) on Linux systems for true headless mode with full rendering capabilities. This is essential for environments where a physical display is unavailable. Requires 'camoufox-js' and is OS-specific to Linux. Multiple instances can run in isolated virtual displays. ```javascript import { Camoufox } from 'camoufox-js'; // Launch with virtual display (Linux only) const browser = await Camoufox({ os: 'linux', headless: 'virtual' // Uses Xvfb }); const page = await browser.newPage(); await page.goto('https://example.com'); // Virtual display is automatically cleaned up on close await browser.close(); // Multiple browsers each get their own virtual display const browser1 = await Camoufox({ os: 'linux', headless: 'virtual' }); const browser2 = await Camoufox({ os: 'linux', headless: 'virtual' }); // Each runs in isolated X11 display await browser1.close(); await browser2.close(); ``` -------------------------------- ### WebGL Spoofing with Camoufox.js Source: https://context7.com/lamualfa/camoufox-js/llms.txt Configure WebGL vendor and renderer to match specific GPU hardware profiles for advanced fingerprint spoofing. This includes options for auto-generated fingerprints, custom vendor/renderer settings, or completely blocking WebGL. Ensure `i_know_what_im_doing: true` is set if blocking WebGL. ```javascript import { Camoufox, launchOptions } from 'camoufox-js'; // Auto-generated WebGL fingerprint (default) const browser1 = await Camoufox({ os: 'windows', headless: true }); // Custom WebGL vendor/renderer const browser2 = await Camoufox({ os: 'linux', webgl_config: ['NVIDIA Corporation', 'GeForce RTX 3080/PCIe/SSE2'], headless: true }); const page = await browser2.newPage(); await page.goto('https://example.com'); const webglInfo = await page.evaluate(() => { const canvas = document.createElement('canvas'); const gl = canvas.getContext('webgl'); const debugInfo = gl.getExtension('WEBGL_debug_renderer_info'); return { vendor: gl.getParameter(debugInfo.UNMASKED_VENDOR_WEBGL), renderer: gl.getParameter(debugInfo.UNMASKED_RENDERER_WEBGL) }; }); console.log('WebGL:', webglInfo); // Block WebGL entirely (not recommended) const browser3 = await Camoufox({ block_webgl: true, i_know_what_im_doing: true, headless: true }); await browser1.close(); await browser2.close(); await browser3.close(); ``` -------------------------------- ### Geolocation and IP Spoofing with Camoufox.js Source: https://context7.com/lamualfa/camoufox-js/llms.txt Configure geolocation, timezone, and locale based on IP address, with support for proxy servers. This functionality allows for precise control over the browser's perceived location and network identity. It can be used with automatically detected public IPs or manually specified IPs for testing purposes. ```javascript import { Camoufox } from 'camoufox-js'; import { publicIP, getGeolocation } from 'camoufox-js'; // Auto-detect public IP and set geolocation const browser1 = await Camoufox({ geoip: true, proxy: 'http://proxy.example.com:8080', headless: true }); // Use specific IP for geolocation const browser2 = await Camoufox({ geoip: '203.0.113.0', // Example IP block_webrtc: false, // Spoof WebRTC IP headless: true }); const page = await browser2.newPage(); await page.goto('https://example.com'); // Check spoofed geolocation const geo = await page.evaluate(() => { return new Promise((resolve) => { navigator.geolocation.getCurrentPosition( (pos) => resolve({ lat: pos.coords.latitude, lon: pos.coords.longitude }) ); }); }); console.log('Spoofed location:', geo); // Check timezone const tz = await page.evaluate(() => Intl.DateTimeFormat().resolvedOptions().timeZone); console.log('Timezone:', tz); await browser1.close(); await browser2.close(); // Manually get IP and geolocation const ip = await publicIP('http://proxy.example.com:8080'); console.log('Public IP:', ip); const location = await getGeolocation(ip); console.log('Location:', location); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.