Patches for Puppeteer and Playwright

Puppeteer and Playwright are the two most popular CDP (Chrome DevTools Protocol) drivers today. Many of our customers use these libraries in their software.

These libraries use the Runtime.enable CDP command, which makes it easy for websites to spot that you're using automation. We've written a detailed post about this issue on our blog. You can read it here: How to fix Runtime.Enable CDP detection of Puppeteer, Playwright and other automation libraries?

To fix this problem, we've created an open-source solution that patches these libraries. This allows you to use their features without being detected. You can find these patches in rebrowser-patches on GitHub and npm.

There are multiple ways how you can use these patches to improve your anti-detection score.

Drop-In Replacement

If you don't want to mess with the patches and all possible errors, there is a drop-in solution for you. These packages have simply applied rebrowser-patches on top of the original code, nothing more.

Puppeteer: rebrowser-puppeteer (source mirror) and rebrowser-puppeteer-core (source mirror)

Playwright (Node.js): rebrowser-playwright (source mirror) and rebrowser-playwright-core (source mirror)

Playwright (Python): rebrowser-playwright (source mirror)

The easiest way to start using them is to install them under the original package names (an npm alias). This way, you don't need to change any source code of your automation. Install only the packages your project already uses:

1
2
3
4
5
# Puppeteer
npm install puppeteer@npm:rebrowser-puppeteer puppeteer-core@npm:rebrowser-puppeteer-core

# Playwright
npm install playwright@npm:rebrowser-playwright playwright-core@npm:rebrowser-playwright-core

npm installs the latest version and saves it in package.json as "puppeteer": "npm:rebrowser-puppeteer@^…". With yarn or pnpm, run yarn add or pnpm add with the same arguments.

Another way is to use the new package names directly: install rebrowser-puppeteer and rebrowser-puppeteer-core (or rebrowser-playwright and rebrowser-playwright-core) instead of the original packages, then replace puppeteer with rebrowser-puppeteer (and so on) in your imports.

For Python, run pip install rebrowser-playwright and import from rebrowser_playwright instead of playwright, e.g. from rebrowser_playwright.sync_api import sync_playwright.

The drop-ins patch the library code only, not the browser. Install a browser the same way as with the original package: rebrowser-puppeteer downloads Chrome on install, rebrowser-playwright needs npx playwright install chromium (or use executablePath / channel: 'chrome' with a Chrome you already have).

The packages follow the version numbers of the original libraries. A fix for a version that is already out ships as X.Y.100, X.Y.101 and so on, so always install the latest version instead of matching the version of the original package.

In each source mirror, every version has its own branch with two commits: the original package, then the patched one. The diff of the second commit is exactly what the patches change.

🚀 That's it! Just visit the rebrowser-bot-detector page and test your patched browser.

Apply Patches Manually

It's pretty simple to add these patches to your software. Just follow the instructions in the README. If you have any trouble applying the patches, feel free to check out the Issues section on GitHub.

We also strongly suggest following this project on GitHub to stay up-to-date. We publish updates from time to time to keep it working with newer versions of these libraries.

Remember: If you don't use these patches, you're almost guaranteed to have poor results on any major website. It's really important to fix this issue on your end.