Skip to content

Instantly share code, notes, and snippets.

@omisolaidowu
Last active February 22, 2024 05:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save omisolaidowu/62393bbd3c3d31320e3a52e384d9eef9 to your computer and use it in GitHub Desktop.
Save omisolaidowu/62393bbd3c3d31320e3a52e384d9eef9 to your computer and use it in GitHub Desktop.
Full code memory
// import the required libraries
const puppeteer = require('puppeteer-extra');
const StealthPlugin = require('puppeteer-extra-plugin-stealth');
// tie Puppeteer Extra to the Stealth plugin
puppeteer.use(StealthPlugin());
(async () => {
// start the browser in non-headless mode
const browser = await puppeteer.launch({ headless: false });
const page = await browser.newPage();
// patch the navigator.deviceMemory and navigator.hardwareConcurrency properties
await page.evaluateOnNewDocument(() => {
// redefine navigator.deviceMemory to return a custom value (16GB RAM)
Object.defineProperty(navigator, 'deviceMemory', {
value: 16
});
// redefine navigator.hardwareConcurrency to return a custom value (8 CPU cores)
Object.defineProperty(navigator, 'hardwareConcurrency', {
value: 8
});
});
await page.goto('https://abrahamjuliot.github.io/creepjs/');
// use setTimeout to wait for the page to load for easy navigation
await new Promise(resolve => setTimeout(resolve, 100000));
await browser.close();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment