Skip to content

Instantly share code, notes, and snippets.

@zelbov
Last active May 1, 2023 21:58
Show Gist options
  • Save zelbov/58e9fbbe5157bf61067d2693118dd09a to your computer and use it in GitHub Desktop.
Save zelbov/58e9fbbe5157bf61067d2693118dd09a to your computer and use it in GitHub Desktop.
Discord `localStorage` closure override bypass (puppeteer)
//...
const bypassLocalStorageOverride = (page) => page.evaluateOnNewDocument(() => {
// preserve localStorage as separate var to keep it before any overrides
let __ls = localStorage
// restrict closure overrides to break global context reference to localStorage
Object.defineProperty(window, 'localStorage', { writable: false, configurable: false, value: __ls })
})
@Mxdi
Copy link

Mxdi commented May 31, 2022

Yeah, maybe a gist of how this could actually be of use?

@zelbov
Copy link
Author

zelbov commented Jun 1, 2022

Yeah, maybe a gist of how this could actually be of use?

Function above should be executed passing page as a parameter before any navigation done.

@0xForkh
Copy link

0xForkh commented May 1, 2023

This works great ! Thank you !
Also much better than other solutions I've seen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment