### Manual Setup Steps Source: https://github.com/cloverlabsai/camoufox/blob/main/service-tester/README.md Follow these steps for manual setup, including dependency installation, virtual environment activation, building and installing the Python library, and downloading the browser binary. ```bash # Install build-tester deps (once) cd ../build-tester && npm install && cd ../service-tester # Create and activate virtualenv python3 -m venv .venv source .venv/bin/activate # Build wheel from local source and install it pip install build (cd ../pythonlib && rm -rf dist && python -m build --wheel -o dist) pip install --force-reinstall ../pythonlib/dist/*.whl # Download the browser binary python -m camoufox fetch # Run tests python run_tests.py ``` -------------------------------- ### Setup and Run build-tester Source: https://github.com/cloverlabsai/camoufox/blob/main/CONTRIBUTING.md Install dependencies and run the build-tester suite, which tests the raw binary in isolation. This is recommended when modifying browser patches, C++/JS browser layer, or spoofing logic. ```bash cd build-tester npm install # first time only pip install -r requirements.txt python scripts/run_tests.py /path/to/camoufox-binary ``` -------------------------------- ### Setup Camoufox Environment Source: https://github.com/cloverlabsai/camoufox/blob/main/tests/README.md Run this command to set up the virtual environment and install necessary dependencies for Camoufox tests. ```bash bash setup-venv.sh ``` -------------------------------- ### Example Usage of Build Tester Source: https://github.com/cloverlabsai/camoufox/blob/main/build-tester/README.md An example command demonstrating how to run the Camoufox build tester with a specific binary path. ```bash python scripts/run_tests.py /path/to/camoufox-bin/camoufox ``` -------------------------------- ### Docker CLI Build Example Source: https://github.com/cloverlabsai/camoufox/blob/main/README.md Example of running the Camoufox Docker build with multiple target platforms and architectures. The output artifacts will be saved in the 'dist/' directory. ```bash $ docker run -v "$(pwd)/dist:/app/dist" camoufox-builder --target windows macos linux --arch x86_64 arm64 i686 ``` -------------------------------- ### Install npm and Python Dependencies Source: https://github.com/cloverlabsai/camoufox/blob/main/build-tester/README.md Install npm dependencies for building the checks bundle and Python dependencies for the build tester. ```bash npm install pip install -r requirements.txt ``` -------------------------------- ### Print Camoufox Install Path Source: https://github.com/cloverlabsai/camoufox/blob/main/pythonlib/README.md Use 'camoufox path' to print the directory path where Camoufox is installed. ```bash > camoufox path /home/name/.cache/camoufox ``` -------------------------------- ### Install Camoufox with GUI Support Source: https://github.com/cloverlabsai/camoufox/blob/main/pythonlib/README.md Install Camoufox with the 'gui' extra to enable the UI Manager. This provides a graphical interface for managing browsers and settings. ```bash pip install 'camoufox[gui]' ``` -------------------------------- ### Install cloverlabs-camoufox Package Source: https://github.com/cloverlabsai/camoufox/blob/main/README.md Install the cloverlabs-camoufox package for access to per-context fingerprints and hardware spoofing. Ensure you are using a virtual environment. ```bash pip install cloverlabs-camoufox ``` -------------------------------- ### Setup Vanilla Firefox Source: https://github.com/cloverlabsai/camoufox/blob/main/README.md Sets up a vanilla Firefox distribution with minimal patches. This is a prerequisite for certain debugging steps. ```bash make ff-dbg ``` -------------------------------- ### Touch Event Listener Setup Source: https://github.com/cloverlabsai/camoufox/blob/main/tests/assets/input/touches.html Sets up event listeners for touchstart, touchend, and touchmove on a button. Logs the identifiers of changed touches. ```javascript window.result = []; const button = document.querySelector('button'); button.style.height = '200px'; button.style.width = '200px'; button.focus(); button.addEventListener('touchstart', event => { log('Touchstart:', ...Array.from(event.changedTouches).map(touch => touch.identifier)); }); button.addEventListener('touchend', event => { log('Touchend:', ...Array.from(event.changedTouches).map(touch => touch.identifier)); }); button.addEventListener('touchmove', event => { log('Touchmove:', ...Array.from(event.changedTouches).map(touch => touch.identifier)); }); ``` -------------------------------- ### Install ccache for Faster Rebuilds Source: https://github.com/cloverlabsai/camoufox/blob/main/CONTRIBUTING.md Install ccache using package managers for macOS and Linux to speed up compilation times during development. ```bash # macOS brew install ccache ``` ```bash # Linux sudo apt install ccache # Debian/Ubuntu sudo dnf install ccache # Fedora ``` -------------------------------- ### List Camoufox Versions Source: https://github.com/cloverlabsai/camoufox/blob/main/pythonlib/README.md Use 'camoufox list' to display installed or all available Camoufox versions in a tree format. Options include showing full install paths. ```bash > camoufox list # show installed versions ``` ```bash > camoufox list all # show all available versions from synced repos ``` ```bash > camoufox list --path # show full install paths ``` -------------------------------- ### Camoufox CLI Build Parameters Source: https://github.com/cloverlabsai/camoufox/blob/main/README.md Example usage of the multibuild script with specified target platforms and architectures. Available options include --target, --arch, --bootstrap, and --clean. ```bash $ python3 multibuild.py --target linux windows macos --arch x86_64 arm64 ``` -------------------------------- ### Install Camoufox Package Source: https://github.com/cloverlabsai/camoufox/blob/main/pythonlib/README.md Install the camoufox package with optional geoip support for proxy detection bypass. The geoip extra downloads an additional dataset for location and timezone determination. ```bash pip install -U camoufox[geoip] ``` -------------------------------- ### Python Configuration Data Source: https://github.com/cloverlabsai/camoufox/blob/main/jsonvv/README.md Example of a Python dictionary representing user configuration data to be validated. ```python config = { "username": "johndoe", "email": "johndoe@example.com", "age": 30, "chat": "Hello world!", "preferences": { "notifications": True, "theme": "dark" }, "allowed_commands": [ "/help", "/time", "/weather" ], "location": [40.7128, -74.0060], "hobbies": [ { "name": "Traveling", "cities": ["Paris", "London"] }, { "name": "reading", "hours": { "Sunday": 2, "Monday": 3, } } ] } ``` -------------------------------- ### Setup and Run service-tester Source: https://github.com/cloverlabsai/camoufox/blob/main/CONTRIBUTING.md Configure proxies and run the service-tester suite, which tests the full stack including the Python package. This is recommended for changes in the Python library, proxy handling, or interactions between the Python package and the binary. ```bash cd service-tester # Add proxies (one per line, format: user:pass@domain:port) cp proxies.txt.example proxies.txt # or create manually ./run_tests.sh ``` -------------------------------- ### Replace Camoufox Binary on Linux Source: https://github.com/cloverlabsai/camoufox/blob/main/docs/beta-testing-ff146.md Copy the newly built Camoufox binary to the default installation directory on Linux. ```bash cp /path/to/built/camoufox-bin ~/.cache/camoufox/camoufox-bin ``` -------------------------------- ### Launch Camoufox GUI Manager Source: https://github.com/cloverlabsai/camoufox/blob/main/pythonlib/README.md Launch the Camoufox Manager GUI. This application allows for managing installed browsers, active versions, and IP geolocation databases. ```bash camoufox gui ``` -------------------------------- ### Fetch Latest Camoufox Version Source: https://github.com/cloverlabsai/camoufox/blob/main/pythonlib/README.md Use 'camoufox fetch' to install the latest version from the active channel or a specified channel/version. It also syncs repository assets. ```bash > camoufox fetch # Install the latest in the channel ``` ```bash > camoufox set coryking/stable > camoufox fetch # Will download the latest release from CoryKing's repo for now on ``` ```bash > camoufox fetch official/stable/135.0-beta.25 # Install a specific version ``` -------------------------------- ### JSONvv List of Keys Syntax Source: https://github.com/cloverlabsai/camoufox/blob/main/jsonvv/README.md Shows how to specify multiple possible keys for a single value using a comma-separated string in JSONvv schemas. Includes an example with regex. ```python "key1,key2,key3": "type" "/k[ey]{2}1/,key2": "type" ``` -------------------------------- ### Proxy Configuration Format Source: https://github.com/cloverlabsai/camoufox/blob/main/service-tester/README.md Specify proxies in a text file, one per line. Blank lines and lines starting with '#' are ignored. Proxies are assigned round-robin across test profiles. ```text user:pass@domain:port ``` ```text alice:secret123@proxy1.example.com:10000 bob:hunter2@proxy2.example.com:10000 alice:secret123@proxy1.example.com:10001 ``` -------------------------------- ### Run Camoufox Tests Source: https://github.com/cloverlabsai/camoufox/blob/main/service-tester/README.md Execute the main test script for Camoufox. This script handles dependency installation, virtual environment creation, and runs tests against both local and official builds. ```bash ./run_tests.sh ``` -------------------------------- ### Camoufox CLI Help Message Source: https://github.com/cloverlabsai/camoufox/blob/main/pythonlib/README.md Display the help message for the Camoufox command-line interface. This outlines available commands for managing Camoufox installations and servers. ```bash $ python -m camoufox --help Usage: python -m camoufox [OPTIONS] COMMAND [ARGS]... ╭─ Options ─────────────────────────────────────────────────────────────────────────────╮ │ --help Show this message and exit. │ ╰───────────────────────────────────────────────────────────────────────────────────────╯ ╭─ Commands ────────────────────────────────────────────────────────────────────────────╮ │ active Print the current active version │ │ fetch Install the active version, or a specific version │ │ gui Launch the Camoufox Manager GUI (requires PySide6) │ │ list List Camoufox versions │ │ path Print the install directory path │ │ remove Remove downloaded data. By default, this removes everything. │ │ Pass --select to pick a browser version to remove. │ │ server Launch a Playwright server │ │ set Set the active Camoufox version to use & fetch. │ │ By default, this opens an interactive selector for versions and settings. │ │ You can also pass a specifier to activate directly: │ │ camoufox set official/stable/134.0.2-beta.20 │ │ Automatically find latest in a channel source: │ │ camoufox set official/stable │ │ sync Sync available versions from remote repositories │ │ test Open the Playwright inspector │ │ version Display version, package, browser, and storage info │ ╰───────────────────────────────────────────────────────────────────────────────────────╯ ``` -------------------------------- ### Python JSON Validation Example Source: https://github.com/cloverlabsai/camoufox/blob/main/jsonvv/README.md Demonstrates how to use the JsonValidator class to validate a Python dictionary against a defined schema. Includes basic error handling for validation failures. ```python from jsonvv import JsonValidator, JvvRuntimeException val = JsonValidator(validator) try: val.validate(config) except JvvRuntimeException as exc: print("Failed:", exc) else: print('Config is valid!') ``` -------------------------------- ### Setup Interstitial Event Listener Source: https://github.com/cloverlabsai/camoufox/blob/main/tests/assets/input/handle-locator.html Initializes DOM element references and sets up event listeners for click interactions on a target element and a close button for an interstitial overlay. Handles click counts and conditional closing logic for the interstitial. ```javascript const target = document.querySelector('#target'); const interstitial = document.querySelector('#interstitial'); const close = document.querySelector('#close'); target.addEventListener('click', () => { window.clicked = (window.clicked ?? 0) + 1; }, false); close.addEventListener('click', () => { const closeInterstitial = () => { interstitial.classList.remove('visible'); target.classList.remove('hidden'); target.classList.remove('removed'); }; if (interstitial.classList.contains('timeout')) setTimeout(closeInterstitial, 3000); else closeInterstitial(); }); ``` -------------------------------- ### Cross-Process Storage IPDL Messages Source: https://github.com/cloverlabsai/camoufox/blob/main/docs/per-context-patches.md These are synchronous IPDL messages used for cross-process synchronization of per-context fingerprint values. `RoverfoxStoragePut` sends data to the parent, and `RoverfoxStorageGet` retrieves it. Both handlers validate that the pref name starts with "roverfox.s.". ```cpp child -> parent: sync RoverfoxStoragePut(nsCString prefName, nsCString value) sync RoverfoxStorageGet(nsCString prefName) returns (nsCString value) ``` -------------------------------- ### Firefox 146 ESM Migration - components.conf Example Source: https://github.com/cloverlabsai/camoufox/blob/main/docs/playwright-maintenance.md Configuration for Playwright's Juggler component, updated for Firefox 146+ ESM compatibility. It uses the 'esModule' field instead of the deprecated 'jsm' field. ```json { "esModule": "chrome://juggler/content/components/Juggler.sys.mjs", "constructor": "JugglerFactory" } ``` -------------------------------- ### Set Up Camoufox Build Environment Source: https://github.com/cloverlabsai/camoufox/blob/main/docs/beta-testing-ff146.md Prepare the build environment by creating necessary directories and bootstrapping the project. 'bootstrap' is only needed on the first run. ```bash make dir make bootstrap # only needed once ``` -------------------------------- ### Build Camoufox with Local .mozbuild Directory Source: https://github.com/cloverlabsai/camoufox/blob/main/README.md Run the Camoufox Docker build, mounting the host's local '~/.mozbuild' directory for persistent build configurations. Ensure correct permissions with ':rw,z'. ```bash docker run \ -v "$HOME/.mozbuild":/root/.mozbuild:rw,z \ -v "$(pwd)/dist:/app/dist" \ camoufox-builder \ --target \ --arch ``` -------------------------------- ### Apply Patch and Check for Rejects Source: https://github.com/cloverlabsai/camoufox/blob/main/docs/patch-upgrading-guide.md Clean the build, navigate to the source directory, apply the patch, and check for any reject files. ```bash make clean cd camoufox- patch -p1 < ../patches/patch-name.patch find . -name '*.rej' -type f ``` -------------------------------- ### Font List Spoofing Source: https://github.com/cloverlabsai/camoufox/blob/main/docs/per-context-patches.md Controls which fonts appear to be installed for fingerprinting scripts. Websites detect fonts by measuring text widths using canvas `measureText()`. This patch allows specifying a subset of fonts that should appear installed per context. ```APIDOC ## window.setFontList ### Description Sets a comma-separated list of font names that should appear as installed to the browser. Fonts not included in this list will be reported as "not installed" to fingerprinting scripts. Essential web fonts (serif, sans-serif, monospace fallbacks) will always function correctly. ### Method ```javascript window.setFontList(fontList); ``` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **fontList** (string) - Required - A comma-separated string of font names (case-insensitive) to be considered installed. Example: 'Arial,Helvetica,Georgia,Courier New,Verdana'. ``` -------------------------------- ### Font List Spoofing Patch Source: https://github.com/cloverlabsai/camoufox/blob/main/docs/per-context-patches.md Applies a patch to control the list of fonts reported as installed. ```APIDOC ## `window.setFontList(fonts)` ### Description Controls the list of fonts that appear to be "installed" to fingerprinting scripts. ### Method JavaScript Function Call ### Parameters - **fonts** (array of strings) - Required - An array of font names to report as installed. ### Notes This function self-destructs after the first call. ``` -------------------------------- ### Bootstrap Camoufox Build System Source: https://github.com/cloverlabsai/camoufox/blob/main/README.md Bootstrap the Camoufox build system. This command only needs to be run once. ```bash make bootstrap ``` -------------------------------- ### Create Camoufox Docker Image Source: https://github.com/cloverlabsai/camoufox/blob/main/README.md Create a Docker image named 'camoufox-builder' that contains the necessary environment for building Camoufox. ```bash docker build -t camoufox-builder . ``` -------------------------------- ### Set Font List Source: https://github.com/cloverlabsai/camoufox/blob/main/docs/per-context-patches.md Defines the set of fonts that will appear 'installed' for the current context. Fonts not in this list will be treated as not present by fingerprinting scripts. ```javascript window.setFontList('Arial,Helvetica,Georgia,Courier New,Verdana'); // Comma-separated list of font names. Fonts NOT in this list will appear "not installed". // Case-insensitive matching. Essential web fonts (serif/sans-serif/monospace fallbacks) always work. ``` -------------------------------- ### Initialize Camoufox with Real Fingerprint Presets Source: https://github.com/cloverlabsai/camoufox/blob/main/README.md Initialize Camoufox using real fingerprint presets for enhanced evasion against complex consistency checks. The library auto-routes by binary version. ```python with Camoufox(fingerprint_preset=True, os="macos") as browser: ... ``` -------------------------------- ### Prepare Patched Source Directory Source: https://github.com/cloverlabsai/camoufox/blob/main/README.md This command prepares the local directory with the patched Firefox source code, ready for building. It follows the source fetching step. ```bash make dir ``` -------------------------------- ### Remove Camoufox Installation Source: https://github.com/cloverlabsai/camoufox/blob/main/pythonlib/README.md Use 'camoufox remove' to delete the Camoufox data directory or a specific version. Confirmation prompts can be skipped with '-y'. ```bash > camoufox remove ``` ```bash > camoufox remove -y # skip confirmation prompt ``` ```bash > camoufox remove official/stable/134.0.2-beta.20 ``` ```bash > camoufox remove --select ``` -------------------------------- ### Initialize WebGL and Handle UI Source: https://github.com/cloverlabsai/camoufox/blob/main/scripts/examples/webgl.html Initializes WebGL contexts, checks for Firefox, displays a warning if not Firefox, and sets up event listeners for copying JSON data. Executes on DOMContentLoaded. ```javascript document.addEventListener( "DOMContentLoaded", async () => { // Check if the user agent is Firefox const isFirefox = navigator.userAgent.toLowerCase().indexOf("firefox") > -1; if (!isFirefox) { document.getElementById("warning").style.display = "block"; } // Add event listener for close button document .getElementById("close-warning") .addEventListener("click", function () { document.getElementById("warning").classList.add("hide"); }); const [webglDetail, webgl2Detail] = await Promise.all([ dumpWebGLCore("webgl", "experimental-webgl"), dumpWebGLCore("webgl2", "experimental-webgl2"), ]); const combinedInfo = { ...webglDetail, ...webgl2Detail }; const jsonString = JSON.stringify(combinedInfo, null, 2); const minifiedJson = JSON.stringify(combinedInfo); const hashValue = await sha256(minifiedJson); document.getElementById("hash").textContent = `SHA256: ${hashValue}`; document.getElementById("output").innerHTML = syntaxHighlight(jsonString); document.getElementById("copy-btn").addEventListener("click", () => { navigator.clipboard.writeText(jsonString).then(() => { alert("Copied formatted JSON to clipboard!"); }); }); document .getElementById("copy-minified-btn") .addEventListener("click", () => { navigator.clipboard.writeText(minifiedJson).then(() => { alert("Copied minified JSON to clipboard!"); }); }); }, false ); ``` -------------------------------- ### Using Real Fingerprint Presets in AsyncCamoufox Source: https://github.com/cloverlabsai/camoufox/blob/main/docs/per-context-patches.md Demonstrates how to opt into using randomly-sampled real fingerprint presets or pin a specific preset dictionary when initializing AsyncCamoufox. This is recommended for v149+ binaries. ```python from camoufox.async_api import AsyncCamoufox # Use a randomly-sampled real preset matching the binary's Firefox version async with AsyncCamoufox(fingerprint_preset=True, os='macos') as browser: page = await browser.new_page() ... # Or pin a specific preset dict async with AsyncCamoufox(fingerprint_preset=my_preset_dict) as browser: ... ``` -------------------------------- ### Initiate Continuous Button Jumping Source: https://github.com/cloverlabsai/camoufox/blob/main/tests/assets/input/animating-button.html Starts a continuous jumping animation for the button. It resets the position and uses requestAnimationFrame for smooth, repeated calls to the 'jump' function. ```javascript function startJumping() { x = 0; const moveIt = () => { jump(); requestAnimationFrame(moveIt); }; setInterval(jump, 0); moveIt(); } ``` -------------------------------- ### Initialize Camoufox (Sync API) Source: https://github.com/cloverlabsai/camoufox/blob/main/README.md Use the synchronous API for Camoufox integration with Playwright. This is the standard way to initialize the browser for sync operations. ```python from camoufox.sync_api import Camoufox with Camoufox() as browser: page = browser.new_page() page.goto("https://example.com") ``` -------------------------------- ### Launch Camoufox Server Source: https://github.com/cloverlabsai/camoufox/blob/main/pythonlib/README.md Use 'camoufox server' to launch a remote Playwright server. ```bash > camoufox server ``` -------------------------------- ### JSONvv Validator Schema Source: https://github.com/cloverlabsai/camoufox/blob/main/jsonvv/README.md Example of a JSONvv validator schema defining rules for validating JSON data. Supports basic types, regex, ranges, unions, and nested structures. ```python validator = { "username": "str", # Basic username "email": "str[/S+@S+\.S+ /]", # Validate emails "age": "int[>=18]", # Age must be 18 or older "chat": "str | nil", # Optional chat message "preferences": { "notifications": "bool", "theme": "str[light, dark] | nil", # Optional theme }, # Commands must start with "/", but not contain "sudo" "allowed_commands": "array[str[/^//] - str[/Sudo/] ]", # Validate coordinate ranges "location": "tuple[double[-90 - 90], double[-180 - 180]]", # Handle an array of hobby types "hobbies": "array[@traveling | @other, >=1]", "@traveling": { # Require 1 or more cities/countries iff name is "Traveling" "*name,type": "str[Traveling]", "*cities,countries": "array[str[A-Za-z*], >=1]", }, "@other": { "name,type": "str - str[Traveling]", # Non-traveling types # If hour(s) is specified, require days have >0 hours "/hours?/": { "*/day$/": "int[>0]" } } } ``` -------------------------------- ### Mermaid Flowchart for Leak Debugging Source: https://github.com/cloverlabsai/camoufox/blob/main/README.md A flowchart illustrating the process for determining leaks without deobfuscating WAF Javascript. It guides through incremental reintroduction of features to identify the source of the leak. ```mermaid flowchart TD A[Start] --> B[Does website flag in the official Firefox?] B -->|Yes| C[Likely bad IP/rate-limiting. If the website fails on both headless and headful mode on the official Firefox distribution, the issue is not with the browser.] B -->|No| D["Run make ff-dbg(1) and build(2) a clean distribution of Firefox. Does the website flag in Firefox **headless** mode(4)?"] D -->|Yes| E["Does the website flag in headful mode(3) AND headless mode(4)?"] D -->|No| F["Open the developer UI(5), apply config.patch, then rebuild(2). Does the website still flag(3)?"] E -->|No| G["Enable privacy.resistFingerprinting in the config(6). Does the website still flag(3)?"] E -->|Yes| C G -->|No| H["In the config(6), enable FPP and start omitting overrides until you find the one that fixed the leak."] G -->|Yes| I[If you get to this point, you may need to deobfuscate the Javascript behind the website to identify what it's testing.] F -->|Yes| K["Open the developer UI, apply the playwright bootstrap patch, then rebuild. Does it still flag?"] F -->|No| J["Omit options from camoufox.cfg(6) and rerun(3) until you find the one causing the leak."] K -->|No| M[Juggler needs to be debugged to locate the leak.] K -->|Yes| L[The issue has nothing to do with Playwright. Apply the rest of the Camoufox patches one by one until the one causing the leak is found.] M --> I ``` -------------------------------- ### Original Code Causing Crash Source: https://github.com/cloverlabsai/camoufox/blob/main/patches/macos-sandbox-crash-fix.README.md This C++ code snippet shows the original implementation where a failure to get the repository directory path in non-packaged builds would trigger a MOZ_CRASH. ```cpp if (!mozilla::IsPackagedBuild()) { rv = nsMacUtilsImpl::GetRepoDir(getter_AddRefs(repoDir)); if (NS_FAILED(rv)) { MOZ_CRASH("Failed to get path to repo dir"); // ← CRASH HERE } // ... } ``` -------------------------------- ### Run Camoufox Build Tester Source: https://github.com/cloverlabsai/camoufox/blob/main/build-tester/README.md Execute the Camoufox build tester script with the path to the Camoufox binary. This script tests the binary directly against antibot-detection checks. ```bash python scripts/run_tests.py [options] ``` -------------------------------- ### Fetch Latest Prerelease Browser Source: https://github.com/cloverlabsai/camoufox/blob/main/README.md Fetch the latest prerelease browser using Camoufox commands. This is recommended for the newest patches and features. ```bash python -m camoufox sync python -m camoufox set official/prerelease python -m camoufox fetch ``` -------------------------------- ### Get Current Geolocation Position Source: https://github.com/cloverlabsai/camoufox/blob/main/tests/assets/geolocation.html Retrieves the user's current geographical position asynchronously. This code wraps the geolocation API call in a Promise for easier handling of the asynchronous result. ```javascript window.geolocationPromise = new Promise(resolve => { navigator.geolocation.getCurrentPosition(position => { resolve({latitude: position.coords.latitude, longitude: position.coords.longitude}); }); }); ``` -------------------------------- ### Run Developer UI Source: https://github.com/cloverlabsai/camoufox/blob/main/README.md Access the developer UI to manage patches. This is the entry point for editing, creating, and removing patches. ```bash make edits ``` -------------------------------- ### Firefox 146 ESM Migration - Juggler.sys.mjs Example Source: https://github.com/cloverlabsai/camoufox/blob/main/docs/playwright-maintenance.md An ESM wrapper for Playwright's Juggler component, designed for Firefox 146+ compatibility. It imports the legacy JSM file and exports the JugglerFactory. ```javascript const { JugglerFactory } = ChromeUtils.import( "chrome://juggler/content/components/Juggler.js" ); export { JugglerFactory }; ``` -------------------------------- ### Fetch Firefox Source for Camoufox Source: https://github.com/cloverlabsai/camoufox/blob/main/README.md This command fetches the necessary Firefox source code to begin building Camoufox. It's the initial step in the build process. ```bash make fetch ``` -------------------------------- ### Initialize Camoufox (Async API) Source: https://github.com/cloverlabsai/camoufox/blob/main/README.md Use the asynchronous API for Camoufox integration with Playwright. This is the standard way to initialize the browser for async operations. ```python from camoufox.async_api import AsyncCamoufox async with AsyncCamoufox() as browser: page = await browser.new_page() await page.goto("https://example.com") ``` -------------------------------- ### Build Camoufox using Docker Source: https://github.com/cloverlabsai/camoufox/blob/main/README.md Build Camoufox patches for a target platform and architecture using a Docker container. Mount the local 'dist' directory to persist build artifacts. ```bash docker run -v "$(pwd)/dist:/app/dist" camoufox-builder --target --arch ``` -------------------------------- ### Attach and Load Iframe with JavaScript Source: https://github.com/cloverlabsai/camoufox/blob/main/tests/assets/frames/nested-frames.html Dynamically creates an iframe, sets its source and ID, appends it to the document body, and waits for it to load. Returns a string upon successful load. ```javascript async function attachFrame(frameId, url) { var frame = document.createElement('iframe'); frame.src = url; frame.id = frameId; document.body.appendChild(frame); await new Promise(x => frame.onload = x); return 'kazakh'; } ``` -------------------------------- ### Fixed Code Handling Path Failures Source: https://github.com/cloverlabsai/camoufox/blob/main/patches/macos-sandbox-crash-fix.README.md This C++ code snippet demonstrates the fix. Instead of crashing, it now logs a warning if the repository directory path cannot be obtained and proceeds without setting the optional sandbox path. ```cpp if (NS_SUCCEEDED(rv)) { nsCString repoDirPath; (void)repoDir->GetNativePath(repoDirPath); info.testingReadPath3 = repoDirPath.get(); } else { NS_WARNING("Failed to get repo dir path for sandbox, skipping testingReadPath3"); } ``` -------------------------------- ### Run Camoufox Source: https://github.com/cloverlabsai/camoufox/blob/main/README.md Runs the built Camoufox browser. Use this to test changes after building. ```bash make run ``` -------------------------------- ### Dump WebGL Core Information Source: https://github.com/cloverlabsai/camoufox/blob/main/scripts/examples/webgl.html Initializes a WebGL context and retrieves core information such as the renderer, vendor, context attributes, supported extensions, and various WebGL parameters. This function is useful for gathering detailed WebGL capabilities for fingerprinting purposes. ```javascript const dumpWebGLCore = async ( webglContextId, experimentalWebglContextId ) => { function getWebGLContext() { const canvas = new OffscreenCanvas(256, 256); let result = null; try { result = canvas.getContext(webglContextId, { preserveDrawingBuffer: false, }) || canvas.getContext(experimentalWebglContextId, { preserveDrawingBuffer: false, }); } catch (ex) {} result || (result = null); return result; } const webglContext = getWebGLContext(); if (!webglContext) { return {}; } const glEnums = [ 2849, 2884, 2885, 2886, 2928, 2929, 2930, 2931, 2932, 2960, 2961, 2962, 2963, 2964, 2965, 2966, 2967, 2968, 2978, 3024, 3042, 3074, 3088, 3089, 3106, 3107, 3314, 3315, 3316, 3317, 3330, 3331, 3332, 3333, 3379, 3386, 3408, 3410, 3411, 3412, 3413, 3414, 3415, 7936, 7937, 7938, 10752, 32773, 32777, 32823, 32824, 32873, 32877, 32878, 32883, 32926, 32928, 32936, 32937, 32938, 32939, 32968, 32969, 32970, 32971, 33000, 33001, 33170, 33901, 33902, 34016, 34024, 34045, 34047, 34068, 34076, 34467, 34816, 34817, 34818, 34819, 34852, 34853, 34854, 34855, 34856, 34857, 34858, 34859, 34860, 34877, 34921, 34930, 34964, 34965, 35071, 35076, 35077, 35371, 35373, 35374, 35375, 35376, 35377, 35379, 35380, 35657, 35658, 35659, 35660, 35661, 35723, 35724, 35725, 35738, 35739, 35968, 35977, 35978, 35979, 36003, 36004, 36005, 36006, 36007, 36063, 36183, 36203, 36345, 36347, 36348, 36349, 36387, 36388, 36392, 36795, 37137, 37154, 37157, 37440, 37441, 37443, 37444, 37445, 37446, 37447, 38449, ]; let rendererInfo = null; const debug_ext = webglContext.getExtension( "WEBGL_debug_renderer_info" ); if (debug_ext) { rendererInfo = { webglVendor: webglContext.getParameter( debug_ext.UNMASKED_VENDOR_WEBGL ), webglRenderer: webglContext.getParameter( debug_ext.UNMASKED_RENDERER_WEBGL ), }; } const result = { [`${webglContextId}:renderer`]: rendererInfo ? rendererInfo.webglRenderer : "Not available", [`${webglContextId}:vendor`]: rendererInfo ? rendererInfo.webglVendor : "Not available", [`${webglContextId}:contextAttributes`]: webglContext.getContextAttributes(), [`${webglContextId}:supportedExtensions`]: webglContext.getSupportedExtensions() || [], [`${webglContextId}:parameters`]: {}, [`${webglContextId}:shaderPrecisionFormats`]: {}, }; for (const glEnum of glEnums) { try { const parmValue = webglContext.getParameter(glEnum); if ( Array.isArray(parmValue) || [Float32Array, Int32Array, Uint32Array].some( (type) => parmValue instanceof type ) ) { const arrayValue = Array.from(parmValue); result[`${webglContextId}:parameters`][glEnum] = arrayValue.length > 0 ? arrayValue : null; } else { result[`${webglContextId}:parameters`][glEnum] = parmValue; } } catch (err) { console.log(err); } } const shaderTypes = [ webglContext.VERTEX_SHADER, webglContext.FRAGMENT_SHADER, ]; const precisionTypes = [ webglContext.LOW_FLOAT, webglContext.MEDIUM_FLOAT, webglContext.HIGH_FLOAT, webglContext.LOW_INT, webglContext.MEDIUM_INT, webglContext.HIGH_INT, ]; for (let shaderType of shaderTypes) { for (let precisionType of precisionTypes) { const r = webglContext.getShaderPrecisionFormat( shaderType, p ``` -------------------------------- ### Build and Package Camoufox Source: https://github.com/cloverlabsai/camoufox/blob/main/README.md Build and package Camoufox for multiple target platforms and architectures using the multibuild script. Specify desired targets and architectures. ```bash python3 multibuild.py --target linux windows macos --arch x86_64 arm64 i686 ``` -------------------------------- ### Apply Context Patch Source: https://github.com/cloverlabsai/camoufox/blob/main/docs/patch-upgrading-guide.md Apply the context-specific patch file on top of the base patch. ```bash patch -p1 < ../font-fingerprinting.context.patch ``` -------------------------------- ### Run Camoufox Tests via Makefile Source: https://github.com/cloverlabsai/camoufox/blob/main/tests/README.md Alternative method to run Camoufox tests using the Makefile. Set headful=true for visual testing. ```makefile make tests headful=true ``` -------------------------------- ### Create Isolated Browser Contexts Source: https://github.com/cloverlabsai/camoufox/blob/main/docs/per-context-patches.md Use `browser.newContext()` to create isolated contexts. `addInitScript` allows injecting custom JavaScript to configure each context with specific settings like timezone, screen dimensions, and GPU information. ```javascript // Context A — appears as a New York user with Intel GPU const ctxA = await browser.newContext(); await ctxA.addInitScript((v) => { if (typeof window.setTimezone === 'function') window.setTimezone(v.tz); if (typeof window.setAudioFingerprintSeed === 'function') window.setAudioFingerprintSeed(v.audio); if (typeof window.setScreenDimensions === 'function') window.setScreenDimensions(v.sw, v.sh); if (typeof window.setCanvasSeed === 'function') window.setCanvasSeed(v.canvas); if (typeof window.setWebGLRenderer === 'function') window.setWebGLRenderer(v.gpu); }, { tz: 'America/New_York', audio: 11111, sw: 1920, sh: 1080, canvas: 44444, gpu: 'Intel Iris OpenGL Engine' }); // Context B — appears as a Tokyo user with Apple GPU (fully isolated from A) const ctxB = await browser.newContext(); await ctxB.addInitScript((v) => { if (typeof window.setTimezone === 'function') window.setTimezone(v.tz); if (typeof window.setAudioFingerprintSeed === 'function') window.setAudioFingerprintSeed(v.audio); if (typeof window.setScreenDimensions === 'function') window.setScreenDimensions(v.sw, v.sh); if (typeof window.setCanvasSeed === 'function') window.setCanvasSeed(v.canvas); if (typeof window.setWebGLRenderer === 'function') window.setWebGLRenderer(v.gpu); }, { tz: 'Asia/Tokyo', audio: 99999, sw: 2560, sh: 1440, canvas: 88888, gpu: 'Apple M1' }); ``` -------------------------------- ### List Available Patches Source: https://github.com/cloverlabsai/camoufox/blob/main/docs/patch-upgrading-guide.md Check which patches are available in the `patches/` directory. ```bash ls patches/*.patch ``` -------------------------------- ### Replace Camoufox Binary on Windows Source: https://github.com/cloverlabsai/camoufox/blob/main/docs/beta-testing-ff146.md Copy the built camoufox.exe to the default user cache directory on Windows. ```powershell copy C:\path\to\built\camoufox.exe C:\Users\\AppData\Local\camoufox\camoufox\Cache\camoufox.exe ``` -------------------------------- ### View Reject File Content Source: https://github.com/cloverlabsai/camoufox/blob/main/docs/patch-upgrading-guide.md Examine the content of a reject file to understand the differences between the expected code and the actual code in the source file. ```bash cat path/to/file.cpp.rej ``` -------------------------------- ### Create and Communicate with a Web Worker Source: https://github.com/cloverlabsai/camoufox/blob/main/tests/assets/worker/worker.html Instantiate a new Web Worker and set up a message handler to receive data from it. Ensure the worker script ('worker.js') is correctly referenced. ```javascript var worker = new Worker('worker.js'); worker.onmessage = function(message) { console.log(message.data); }; ``` -------------------------------- ### Run Camoufox Tests via Shell Script Source: https://github.com/cloverlabsai/camoufox/blob/main/tests/README.md Execute Camoufox tests using the provided shell script. Use the --headful flag for visual testing and specify the --executable-path to your Camoufox binary. ```bash bash run-tests.sh --headful --executable-path /path/to/camoufox-bin ``` -------------------------------- ### Find Reject Files Source: https://github.com/cloverlabsai/camoufox/blob/main/docs/patch-upgrading-guide.md After applying a patch, use this command to locate any files that were not patched cleanly (reject files). ```bash find . -name '*.rej' -type f ``` -------------------------------- ### Create and Populate Shadow DOM Source: https://github.com/cloverlabsai/camoufox/blob/main/tests/assets/shadow.html Attaches a shadow root to the document body and appends a heading and a button. The button click is tracked. ```javascript let h1 = null; let button = null; let clicked = false; window.addEventListener('DOMContentLoaded', () => { const shadowRoot = document.body.attachShadow({mode: 'open'}); h1 = document.createElement('h1'); h1.textContent = 'Hellow Shadow DOM v1'; button = document.createElement('button'); button.textContent = 'Click'; button.addEventListener('click', () => clicked = true); shadowRoot.appendChild(h1); shadowRoot.appendChild(button); }); ``` -------------------------------- ### JSONvv Regex Key Syntax Source: https://github.com/cloverlabsai/camoufox/blob/main/jsonvv/README.md Illustrates how to use regular expressions within dictionary keys for flexible pattern matching in JSONvv schemas. ```python "/key\d+/": "type" ``` -------------------------------- ### Verify Patch Application Source: https://github.com/cloverlabsai/camoufox/blob/main/docs/patch-upgrading-guide.md After generating a new patch, re-apply it to a clean source tree to confirm it applies without rejects. ```bash cd .. make clean cd camoufox-146.0.1-beta.25 patch -p1 < ../patches/0-playwright.patch find . -name '*.rej' -type f # Should be empty ``` -------------------------------- ### Service Tester Command-Line Options Source: https://github.com/cloverlabsai/camoufox/blob/main/service-tester/README.md Options for running tests via shell script or Python script. Customize browser version, profile count, proxy path, and more. ```bash ./run_tests.sh [options] python run_tests.py [options] ``` ```text --browser-version VER Camoufox version specifier (default: official/stable) e.g. official/prerelease/146.0.1-beta.50 --profile-count N Number of profiles to test (1-6, default: 6) --proxies PATH Path to proxies file (default: proxies.txt) --headful Run with visible browser window --no-cert Skip certificate generation --save-cert PATH Save certificate text to a file --secret KEY HMAC signing key for the certificate --binary MODE Which binary to test: local | fetched | both (default: both) (run_tests.sh only — orchestrates the two phases) --executable-path PATH Run against a specific binary path (run_tests.py only — used internally by phase 1) ``` -------------------------------- ### Find Class Definitions Source: https://github.com/cloverlabsai/camoufox/blob/main/docs/patch-upgrading-guide.md Use grep to search for class definitions within header files. ```bash grep -r "class Navigator" . --include="*.h" ``` -------------------------------- ### Fetch Dummy Response Source: https://github.com/cloverlabsai/camoufox/blob/main/tests/assets/serviceworkers/fetchdummy/sw.html Fetches a resource and returns its text content or an error status. Useful for testing network interactions. ```javascript async function fetchDummy(name) { const response = await fetch(name); if (!response.ok) return 'FAILURE: ' + response.statusText; const text = await response.text(); return text; } ``` -------------------------------- ### Build Camoufox for Target Platform Source: https://github.com/cloverlabsai/camoufox/blob/main/docs/beta-testing-ff146.md Compile Camoufox for your specific operating system and architecture. Refer to the table for valid parameter options. ```python python3 multibuild.py --target --arch ``` -------------------------------- ### Clone Camoufox Repository Source: https://github.com/cloverlabsai/camoufox/blob/main/docs/beta-testing-ff146.md Clone the Camoufox repository to your local machine. Use --depth 1 for a shallow clone. ```bash git clone --depth 1 https://github.com/daijro/camoufox cd camoufox ``` -------------------------------- ### Build Camoufox Windows Portable Source: https://github.com/cloverlabsai/camoufox/blob/main/README.md This command builds a portable Windows version of Camoufox. Ensure the patched source is ready before executing. ```bash make package-windows ``` -------------------------------- ### Basic String Type Source: https://github.com/cloverlabsai/camoufox/blob/main/jsonvv/README.md Use this for any string value. No specific format is enforced. ```python "username": "str" ``` -------------------------------- ### Verify Patch Application Source: https://github.com/cloverlabsai/camoufox/blob/main/docs/patch-upgrading-guide.md After generating an updated patch, verify that it applies cleanly to a clean Firefox source directory. No reject files should be found. ```bash cd .. make clean cd camoufox- patch -p1 < ../patches/patch-name.patch find . -name '*.rej' -type f # Should return nothing ``` -------------------------------- ### Set Camoufox Version Channel or Pin Source: https://github.com/cloverlabsai/camoufox/blob/main/pythonlib/README.md Use 'camoufox set' to choose a version channel or pin a specific version. It can also activate a specifier directly. ```bash > camoufox set ``` ```bash > camoufox set official/stable # Default setting ``` ```bash > camoufox set official/prerelease ``` ```bash > camoufox set official/stable/134.0.2-beta.20 ``` -------------------------------- ### Analyze Reject File Source: https://github.com/cloverlabsai/camoufox/blob/main/docs/patch-upgrading-guide.md Examine the content of a reject file to understand the specific changes that failed to apply. ```bash cat dom/base/Navigator.cpp.rej ``` -------------------------------- ### Drag and Drop Event Handlers (JavaScript) Source: https://github.com/cloverlabsai/camoufox/blob/main/tests/assets/drag-n-drop.html Implement dragstart, dragover, and drop event handlers to enable moving elements on the page. The dragstart handler sets data and visual feedback, dragover prevents default behavior, and drop handles the data transfer and appends the element to the target. ```javascript function dragstart_handler(ev) { ev.currentTarget.style.border = "dashed"; ev.dataTransfer.setData("text/plain", ev.target.id); } function dragover_handler(ev) { ev.preventDefault(); } function drop_handler(ev) { console.log("Drop"); ev.preventDefault(); var data = ev.dataTransfer.getData("text"); ev.target.appendChild(document.getElementById(data)); } ``` -------------------------------- ### Build Camoufox Source: https://github.com/cloverlabsai/camoufox/blob/main/README.md This command compiles the patched Firefox source code into a built version of Camoufox. This is a core step before packaging. ```bash make build ``` -------------------------------- ### Build Camoufox Linux Portable Source: https://github.com/cloverlabsai/camoufox/blob/main/README.md This command builds a portable Linux version of Camoufox. Ensure the patched source is ready before executing. ```bash make package-linux ``` -------------------------------- ### Fetch Camoufox Browser Source: https://github.com/cloverlabsai/camoufox/blob/main/pythonlib/README.md Download the Camoufox browser. Use 'camoufox fetch' on Windows and 'python3 -m camoufox fetch' on MacOS and Linux. ```bash camoufox fetch ``` ```bash python3 -m camoufox fetch ``` -------------------------------- ### Clean Firefox Source Directory Source: https://github.com/cloverlabsai/camoufox/blob/main/docs/patch-upgrading-guide.md Always use `make clean` to reset to fresh Firefox source before applying patches. Avoid using `git reset` or `git clean` directly. ```bash make clean ``` -------------------------------- ### Run Headless Firefox Source: https://github.com/cloverlabsai/camoufox/blob/main/README.md Runs a URL in headless mode. This command is used to test website behavior without a graphical interface and to check for redirects. ```bash make run args="--headless https://test.com" ``` -------------------------------- ### Create and Animate Button Source: https://github.com/cloverlabsai/camoufox/blob/main/tests/assets/input/animating-button.html Creates a button element, sets its text and animation properties, and appends it to the document body. The animation is set to run infinitely. ```javascript function addButton() { const button = document.createElement('button'); button.textContent = 'Click me'; button.style.animation = '3s linear move'; button.style.animationIterationCount = 'infinite'; button.addEventListener('click', () => window.clicked = true); document.body.appendChild(button); } ``` -------------------------------- ### Camoufox Configuration Settings Source: https://github.com/cloverlabsai/camoufox/blob/main/docs/per-context-patches.md Configuration settings for Camoufox, including enabling Fission, setting web content isolation strategy, and disabling process prelaunch. ```cfg fission.autostart = true fission.webContentIsolationStrategy = 1 dom.ipc.processPrelaunch.enabled = false ```