Created
October 20, 2021 19:43
-
-
Save mendes5/eaad8b70060f1e82a24c2d02c2f6ad4f to your computer and use it in GitHub Desktop.
Hook into history and location functions to execute the debugger to debug unexpected URL changes
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 _pushState = window.history.pushState.bind(window.history); | |
| window.history.pushState = (...args) => {debugger; return _pushState(...args)}; | |
| const _replaceState = window.history.replaceState.bind(window.history); | |
| window.history.replaceState = (...args) => {debugger; return _replaceState(...args)}; | |
| const _replace = window.location.replace.bind(window.location); | |
| window.location.replace = (...args) => {debugger; return _replace(...args)}; | |
| const _reload = window.location.reload.bind(window.location); | |
| window.location.reload = (...args) => {debugger; return _reload(...args)}; | |
| // TODO:: hook window.location getters and setters as well |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment