Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save revskill10/a75160d68a53dbccbc9eb4a93c7cd9ff to your computer and use it in GitHub Desktop.
Save revskill10/a75160d68a53dbccbc9eb4a93c7cd9ff 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!');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment