Created
January 21, 2021 08:16
-
-
Save x3388638/91d3b70ccc4d9419155df95b96683844 to your computer and use it in GitHub Desktop.
Log all pushState and replaceState events in console
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
// ==UserScript== | |
// @name HistoryLogger | |
// @namespace 2yc.tw | |
// @version 0.1 | |
// @description Log all pushState and replaceState events in console | |
// @author YY | |
// @match *://*/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
const _pushState = window.history.pushState.bind(window.history); | |
const _replaceState = window.history.replaceState.bind(window.history); | |
window.history.pushState = (...args) => { | |
console.groupCollapsed('[PUSH_STATE]'); | |
console.log(JSON.stringify(args, null, 4)); | |
console.groupCollapsed('trace stack'); | |
console.trace(); | |
console.groupEnd(); | |
console.groupEnd(); | |
_pushState(...args); | |
}; | |
window.history.replaceState = (...args) => { | |
console.groupCollapsed('[REPLACE_STATE]'); | |
console.log(JSON.stringify(args, null, 4)); | |
console.groupCollapsed('trace stack'); | |
console.trace(); | |
console.groupEnd(); | |
console.groupEnd(); | |
_replaceState(...args); | |
}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment