Skip to content

Instantly share code, notes, and snippets.

@rudiedirkx
Last active July 25, 2025 16:54
Show Gist options
  • Select an option

  • Save rudiedirkx/fd568b08d7bffd6bd372 to your computer and use it in GitHub Desktop.

Select an option

Save rudiedirkx/fd568b08d7bffd6bd372 to your computer and use it in GitHub Desktop.

Revisions

  1. rudiedirkx revised this gist Jun 15, 2023. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion detect-history-state.js
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,8 @@ var _wr = function(type) {
    return rv;
    };
    };
    history.pushState = _wr('pushState'), history.replaceState = _wr('replaceState');
    history.pushState = _wr('pushState');
    history.replaceState = _wr('replaceState');



  2. rudiedirkx created this gist Sep 4, 2014.
    19 changes: 19 additions & 0 deletions detect-history-state.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    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!');
    }
    });