-
-
Save omisolaidowu/62393bbd3c3d31320e3a52e384d9eef9 to your computer and use it in GitHub Desktop.
Full code memory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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