Skip to content

Instantly share code, notes, and snippets.

@omisolaidowu
Last active February 22, 2024 05:22
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/0f4e002902d98c8908575828bc945946 to your computer and use it in GitHub Desktop.
Save omisolaidowu/0f4e002902d98c8908575828bc945946 to your computer and use it in GitHub Desktop.
Patching
(async () => {
// ...
// 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 navigatorhardwareConcurrency to return a custom value (8 CPU cores)
Object.defineProperty(navigator, 'hardwareConcurrency', {
value: 8
});
});
await browser.close();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment