### Verify Patch Command Installation Source: https://github.com/rebrowser/rebrowser-patches/blob/main/README.md This command checks if the 'patch' executable is correctly installed and accessible in your system's PATH. It should display the version of the patch utility. ```bash patch -v ``` -------------------------------- ### Set PATH Environment Variable on Windows Source: https://github.com/rebrowser/rebrowser-patches/blob/main/README.md This command adds the Git bin directory to your system's PATH environment variable, allowing you to use the 'patch' command from any directory. Ensure the path to Git's bin folder is correct for your installation. ```batch set PATH=%PATH%;C:\Program Files\Git\usr\bin\ ``` -------------------------------- ### Rebrowser Patches CLI Usage Source: https://github.com/rebrowser/rebrowser-patches/blob/main/README.md Commands for applying and reverting rebrowser patches to installed libraries. Supports patching by package name or by providing the full package path. Use `--help` for a full list of options. ```shell npx rebrowser-patches@latest patch --packageName puppeteer-core npx rebrowser-patches@latest unpatch --packageName puppeteer-core npx rebrowser-patches@latest patch --packagePath /web/app/node_modules/puppeteer-core-custom ``` -------------------------------- ### Integrate Rebrowser Puppeteer Patches (npm alias) Source: https://github.com/rebrowser/rebrowser-patches/blob/main/README.md This snippet demonstrates how to alias rebrowser-puppeteer packages in package.json to use the patched versions seamlessly with existing Puppeteer code. It involves updating dependencies and running an install command. ```javascript { "dependencies": { "puppeteer": "npm:rebrowser-puppeteer@^23.3.1", "puppeteer-core": "npm:rebrowser-puppeteer-core@^23.3.1" } } // Then run: npm install ``` -------------------------------- ### Integrate Rebrowser Playwright Patches (Python) Source: https://github.com/rebrowser/rebrowser-patches/blob/main/README.md This snippet shows how to install the rebrowser-playwright package for Python to utilize the patched Playwright functionality. It involves updating the package name in your project's dependencies. ```python pip install rebrowser-playwright ``` -------------------------------- ### Integrate Rebrowser Playwright Patches (direct replacement) Source: https://github.com/rebrowser/rebrowser-patches/blob/main/README.md This snippet details the process of directly replacing Playwright packages with rebrowser-playwright packages. It involves updating package names in package.json, installing, and updating any code that references the original Playwright package. ```javascript { "dependencies": { "playwright": "^1.x.x" } } // After install, replace references in code: // require('playwright') -> require('rebrowser-playwright') ``` -------------------------------- ### Integrate Rebrowser Puppeteer Patches (direct replacement) Source: https://github.com/rebrowser/rebrowser-patches/blob/main/README.md This snippet shows how to directly replace Puppeteer packages with rebrowser-puppeteer packages in package.json. It requires updating package names, running an install, and potentially refactoring code that references the original package names. ```javascript { "dependencies": { "puppeteer": "^23.3.1", "puppeteer-core": "^23.3.1" } } // After install, replace references in code: // require('puppeteer') -> require('rebrowser-puppeteer') // require('puppeteer-core') -> require('rebrowser-puppeteer-core') ``` -------------------------------- ### Integrating with puppeteer-extra Source: https://github.com/rebrowser/rebrowser-patches/blob/main/README.md Demonstrates how to integrate rebrowser-puppeteer with the puppeteer-extra library using the `addExtra` method. ```javascript // before import puppeteer from 'puppeteer-extra' // after import { addExtra } from 'puppeteer-extra' import rebrowserPuppeteer from 'rebrowser-puppeteer-core' const puppeteer = addExtra(rebrowserPuppeteer) ``` -------------------------------- ### Setting Runtime Fix Mode via Command Line Source: https://github.com/rebrowser/rebrowser-patches/blob/main/README.md Illustrates setting the Runtime.Enable leak fix mode when executing a Node.js application from the command line. ```shell REBROWSER_PATCHES_RUNTIME_FIX_MODE=alwaysIsolated node app.js ``` -------------------------------- ### Runtime.Enable Leak Fix Modes Source: https://github.com/rebrowser/rebrowser-patches/blob/main/README.md Configuration options for fixing the Runtime.Enable leak. These environment variables allow switching between different patching strategies or disabling the fix entirely. ```shell REBROWSER_PATCHES_RUNTIME_FIX_MODE=addBinding REBROWSER_PATCHES_RUNTIME_FIX_MODE=alwaysIsolated REBROWSER_PATCHES_RUNTIME_FIX_MODE=enableDisable REBROWSER_PATCHES_RUNTIME_FIX_MODE=0 ``` -------------------------------- ### Access Browser CDP Connection (JavaScript) Source: https://github.com/rebrowser/rebrowser-patches/blob/main/README.md This patch adds a `_connection()` method to the Browser class, allowing direct access to the browser's CDP session. This is useful for implementing custom CDP commands or listening to browser-level events. ```javascript browser._connection().on('Rebrowser.addRunEvent', (params) => { ... }) ``` -------------------------------- ### Setting Runtime Fix Mode in Code Source: https://github.com/rebrowser/rebrowser-patches/blob/main/README.md Demonstrates how to programmatically set the Runtime.Enable leak fix mode within a Node.js application using environment variables. ```javascript process.env.REBROWSER_PATCHES_RUNTIME_FIX_MODE = "alwaysIsolated" ``` -------------------------------- ### Runtime.Enable Leak Debug Mode Source: https://github.com/rebrowser/rebrowser-patches/blob/main/README.md Enables debug messages for the Runtime.Enable leak fix, aiding in troubleshooting and understanding the patch's behavior. ```shell REBROWSER_PATCHES_DEBUG=1 ``` -------------------------------- ### Integrate Rebrowser Playwright Patches (npm alias) Source: https://github.com/rebrowser/rebrowser-patches/blob/main/README.md This snippet illustrates how to use npm aliases in package.json to integrate rebrowser-playwright packages for Node.js. This method allows using the patched Playwright without modifying existing automation scripts. ```javascript { "dependencies": { "playwright": "npm:rebrowser-playwright@^1.x.x" } } // Then run: npm install ``` -------------------------------- ### Change Default Utility World Name (Shell) Source: https://github.com/rebrowser/rebrowser-patches/blob/main/README.md Allows customization of the default utility world name used by Puppeteer. The name can be changed via the `REBROWSER_PATCHES_UTILITY_WORLD_NAME` environment variable. Setting it to '0' disables the patch. ```shell REBROWSER_PATCHES_UTILITY_WORLD_NAME=customUtilityWorld # use 0 to completely disable this patch REBROWSER_PATCHES_UTILITY_WORLD_NAME=0 ``` -------------------------------- ### Changing sourceURL to Generic Script Name Source: https://github.com/rebrowser/rebrowser-patches/blob/main/README.md Modifies the default Puppeteer `sourceURL` comment added to evaluated scripts. This patch changes it from `//# sourceURL=pptr:...` to a generic name like `//# sourceURL=app.js` to avoid detection. ```shell # use any generic filename REBROWSER_PATCHES_SOURCE_URL=jquery.min.js # use 0 to completely disable this patch REBROWSER_PATCHES_SOURCE_URL=0 ``` -------------------------------- ### Playwright Runtime Enable Leak Fix Source: https://github.com/rebrowser/rebrowser-patches/blob/main/README.md Addresses a leak in Playwright's `Runtime.enable` functionality, specifically related to `addBinding` and `alwaysIsolated` modes. Disabling this fix via `REBROWSER_PATCHES_RUNTIME_FIX_MODE=0` is recommended for debugging with `page.pause()`. ```APIDOC Playwright Patches: Runtime.enable leak fix: - Addresses issues with `addBinding` and `alwaysIsolated` modes. - Can be disabled for debugging `page.pause()` using `REBROWSER_PATCHES_RUNTIME_FIX_MODE=0`. - Currently only supports Chrome. For WebKit or Firefox, please open an issue. Utility World Name Customization: - Allows changing the utility world name via `REBROWSER_PATCHES_UTILITY_WORLD_NAME` environment variable. - This setting is applied at module import time and cannot be changed dynamically. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.