Last active
April 15, 2016 02:27
-
-
Save davidlwatsonjr/5437928 to your computer and use it in GitHub Desktop.
Remove analytics variables from the current page's query string. This allows for cleaner bookmarking, sharing, saving in Readability, etc. More analytics variables will added as they are found. This is minified as I use it as a bookmarklet.
This file contains 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
(function() { | |
var r = ['utm_source', 'utm_campaign', 'utm_medium', 'utm_content', 'utm_hp_ref', 'wpisrc', 'xrs', 'fb_action_ids', 'fb_action_types', 'fb_source', 'action_object_map', 'mcid', 'rmid', 'rrid', 'CIMID'], | |
e = window.location.search.slice(1), | |
t = e.split('&'), | |
n = '?', | |
i = ''; | |
e: for (p in t) { | |
for (var s = 0; s < r.length; s++) { | |
if (t[p].indexOf(r[s] + '=') === 0) { | |
break e | |
} | |
} | |
n = n + t[p] + '&' | |
} | |
n = n.slice(0, -1); | |
n === '?' && (n = ''); | |
i = window.location.origin + window.location.pathname + n + window.location.hash; | |
i === window.location.href || (window.location = i) | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment