Skip to content

Instantly share code, notes, and snippets.

@rudiedirkx
Last active April 5, 2024 18:01
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • 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