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.
How to Use It?
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 and rebrowser-puppeteer-core
Playwright: rebrowser-playwright and rebrowser-playwright-core
The easiest way to start using it is to fix your package.json
to use new packages but keep the old name as an alias. This way, you don't need to change any source code of your automation. Here is how to do that:
- 1. Open
package.json
and replace"puppeteer": "^23.3.1"
and"puppeteer-core": "^23.3.1"
with"puppeteer": "npm:rebrowser-puppeteer@^23.3.1"
and"puppeteer-core": "npm:rebrowser-puppeteer-core@^23.3.1"
. - 2. Run
npm install
(oryarn install
)
Another way is to actually use new packages instead of the original one. Here are the steps you need to follow:
- 1. Open
package.json
and replacepuppeteer
andpuppeteer-core
withrebrowser-puppeteer
andrebrowser-puppeteer-core
. Don't change versions of the packages, just replace the names. - 2. Run
npm install
(oryarn install
) - 3. Find and replace in your scripts any mentions of
puppeteer
andpuppeteer-core
withrebrowser-puppeteer
andrebrowser-puppeteer-core
🚀 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.