-
-
Save cowboy/983747 to your computer and use it in GitHub Desktop.
userscript: Drop the UTM params from a URL when the page loads
This file contains hidden or 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 UTM param stripper | |
// @author Paul Irish | |
// @namespace http://github.com/paulirish | |
// @description Drop the UTM params from a URL when the page loads. | |
// @extra Cuz you know they're all ugly n shit. | |
// @include http://* | |
// ==/UserScript== | |
// save this as utmstrip.user.js and drag it into Chrome or Firebug (with greasemonkey) | |
var oldUrl = location.href; | |
var newUrl = oldUrl.replace(/\?([^#]*)/, function(_, search) { | |
search = search.split('&').filter(function(v) { | |
return !/^utm_/.test(v); | |
}).join('&'); | |
return search ? '?' + search : ''; | |
}); | |
if ( newUrl != oldUrl ) { | |
window.history.replaceState({}, '', newUrl); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment