Skip to content

Instantly share code, notes, and snippets.

@rudiedirkx
Last active May 14, 2024 04:12
Show Gist options
  • Save rudiedirkx/fd568b08d7bffd6bd372 to your computer and use it in GitHub Desktop.
Save rudiedirkx/fd568b08d7bffd6bd372 to your computer and use it in GitHub Desktop.
Detect pushState and replaceState
var _wr = function(type) {
var orig = history[type];
return function() {
var rv = orig.apply(this, arguments);
var e = new Event(type);
e.arguments = arguments;
window.dispatchEvent(e);
return rv;
};
};
history.pushState = _wr('pushState');
history.replaceState = _wr('replaceState');
window.addEventListener('replaceState', function(e) {
if ( location.href.match(/[&?]ref_=/) ) {
console.warn('THOSE FUCKERS GAVE ME A ?_ref AGAIN!');
}
});
@necrogoru
Copy link

Nice!

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