Last active
May 1, 2023 21:58
-
-
Save zelbov/58e9fbbe5157bf61067d2693118dd09a to your computer and use it in GitHub Desktop.
Discord `localStorage` closure override bypass (puppeteer)
This file contains hidden or 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
//... | |
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 }) | |
}) |
Yeah, maybe a gist of how this could actually be of use?
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.
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
how do i actually use this?