This project tests how the browser language can be changed with Puppeteer. It implements multiple options to set the language of Chrome and checks each option against BrowserLeaks to see how it affected the JavaScript proeprties and HTTP headers available by the browser. For more information, see my article The Puppeteer Language Experiment on DEV.to.
Clone this repository to your locale machine and install the dependencies with npm. The puppeteer
package automatically downloads Chrome to a temporary folder.
npm install
Then start the test:
npm test
The test will run each option and print its result:
System: darwin/23.1.0, arm64
Language: en-US
Browser: Chrome/125.0.6422.60
Using --lang=de-DE
Internationalization Locale: en-GB
Navigator Language: en-GB
HTTP Accept-Language: en-GB,en-US;q=0.9,en;q=0.8
Using env.LANG=de-DE
Internationalization Locale: en-GB
Navigator Language: en-GB
HTTP Accept-Language: en-GB,en-US;q=0.9,en;q=0.8
Sending HTTP header Accept-Language: de-DE
Internationalization Locale: en-GB
Navigator Language: en-GB
HTTP Accept-Language: de-DE
Overriding navigator.language=de-DE
Internationalization Locale: en-GB
Navigator Language: de-DE
HTTP Accept-Language: en-GB,en-US;q=0.9,en;q=0.8
Using CDP Network.setUserAgentOverride(acceptLanguage: de-DE)
Internationalization Locale: en-GB
Navigator Language: de-DE
HTTP Accept-Language: de-DE
The current implementation uses the locale de-DE
, but this can be changed by the LANG_TEST
constant.
If there are other options, which this experiment doesn't cover yet, please feel free to submit a pull request. Furthermore, if you get different results on another operating system or browser version, please let me know and I will include your results in this repository.