Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name UTM Stripper
- // @namespace lehollandaisvolant.net
- // @description Remove UTM_ url parametes.
- // @include *utm_source=*
- // @include *utm_medium=*
- // @include *utm_term=*
- // @include *utm_content=*
- // @include *utm_campaign=*
- // @version 1
- // ==/UserScript==
- (function () {
- var sp = window.location.search.replace(/^\?/, '').split('&'),
- sk = [
- ];
- for (var i = 0; i < sp.length; i++) {
- if (!/^(?:utm_source|utm_medium|utm_term|utm_content|utm_campaign)$/i.test(sp[i].split('=') [0])) {
- sk.push(sp[i]);
- }
- }
- var newurl = window.location.protocol + '//' + window.location.host
- + window.location.pathname + (sk.length ? '?' + sk.join('&') : '')
- + window.location.hash;
- if (newurl != window.location.href) {
- (!!(window.history && window.history.pushState)
- ? window.history.pushState(null, null, newurl)
- : window.location.replace(newurl)
- );
- }
- }) ();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement