Background
At Kameleo, we dedicate significant resources to ensuring our browsers remain undetectable, even when controlled by automation frameworks such as Selenium, Puppeteer, and Playwright. We excel in this area, and Kameleo is the only solution that can pass through the Brotector anti-bot system using stock Playwright.
Recently, however, an unexpected issue has surfaced. A Playwright update in September 2024 introduced a change that makes Playwright-detection possible.
- For NodeJS users this change was introduced in version 1.46.1
- For Python users this change was introduced in version 1.47
This issue is also referred to as the PWinitScript leak. Many bot detection systems have already started using this method to prevent automated browsing and data collection. These detection systems protect popular web scraping target sites, such as those in the travel industry, including Choice Hotels.
Detection Method
With the introduction of Playwright 1.46.1, the following JavaScript snippet can now successfully detect the presence of Playwright:
const keys = ["__pwInitScripts", "__playwright__binding__"];
var key;
for (key of keys){
if((globalThis[key] !== undefined) && !this[key]){
this[key] = true;
this.log({detection:"PWinitScript", data:{"value":globalThis[key]}, score:1, type:key});
}
}
This detection vulnerability was introduced in the following Playwright commit: https://github.com/microsoft/playwright/commit/c9e673c6dca746384338ab6bb0cf63c7e7caa9b2#diff-087773eea292da9db5a3f27de8f1a2940cdb895383ad750c3cd8e01772a35b40R909-R924
Recommendation
Currently, there is no direct fix available. As a temporary solution, we recommend using Playwright version 1.46.0 instead of the latest release. Some users have suggested porting to Puppeteer as an alternative.
Since no fix has been provided since September 2024—and given that Playwright is primarily a testing tool rather than an anti-detection solution—it is unlikely that this issue will be resolved by Playwright itself. Therefore, we will likely start working on our own solution soon to ensure continued undetectability.
Stay tuned for further updates, and feel free to reach out to our support team if you have any questions.