I tried this:
puppeteer.launch({
To hide that info for all website, you must use combination of different settings. This is not limited to,
Because every website will have their own method of finding out. Just changing timezone does not mean the website will think you are from somewhere else.
However, the following code worked perfectly for me.
const puppeteer = require('puppeteer');
async function timeZoneChecker({ timeZone }) {
// all kind of config to pass to browser
const launchConfig = {};
if (timeZone) {
launchConfig.env = {
TZ: timeZone,
...process.env,
};
}
const browser = await puppeteer.launch(launchConfig);
const page = await browser.newPage();
await page.goto('https://whoer.net/');
const detectedTimezone = await page.$eval('.ico-timesystem', e => e.parentNode.innerText);
await page.screenshot({ path: `screenshots/timeZone_${timeZone.replace('/', '-')}.png`, fullPage: true });
await browser.close();
return { timeZone, detectedTimezone };
}
Promise.all([
timeZoneChecker({ timeZone: 'Australia/Melbourne' }),
timeZoneChecker({ timeZone: 'Asia/Singapore' }),
]).then(console.log);
Result:
➜ change-timezone node app/timezone.js
[ { timeZone: 'Australia/Melbourne',
detectedTimezone: 'Sun Oct 28 2018 22:44:35 GMT+1100 (Australian Eastern Daylight Time)' },
{ timeZone: 'Asia/Singapore',
detectedTimezone: 'Sun Oct 28 2018 19:44:36 GMT+0800 (Singapore Standard Time)' } ]
According to the Puppeteer documentation, you can use page.emulateTimezone():
page.emulateTimezone()
timezoneId
<?string> Changes the timezone of the page. See ICU’s metaZones.txt for a list of supported timezone IDs. Passingnull
disables timezone emulation.returns: <Promise>
For example:
await page.emulateTimezone('America/Chicago');