Last active
July 13, 2020 15:42
-
-
Save umer936/fb9b7ea892386f37cb4d26154533f518 to your computer and use it in GitHub Desktop.
Javascript bookmarklet to strip tracking tags in URLs for better bookmarking
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
javascript: void | |
function() { | |
var url = location.search; | |
if (url) { | |
var each = url.slice(1).split("&"); | |
console.log("Stripping query parameters:", each); | |
var leave = each.filter(function(url) { | |
return "utm_" !== url.substr(0, 4) && | |
"mc_" !== url.substr(0, 3) && | |
"ct" !== url.substr(0, 2) && | |
"_hsenc" !== url.substr(0, 6) && | |
"_hsmi" !== url.substr(0, 5) && | |
"mkt_tok" !== url.substr(0, 7) && | |
"mbid" !== url.substr(0, 4) | |
}); | |
if (leave.length !== each.length) { | |
var i = leave.join("&"); | |
i && (i = "?" + i); | |
var a = location.href.replace(url, i); | |
history.replaceState({}, document.title, a) | |
} | |
} | |
}(); |
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
javascript:!function(){var t=location.search;if(t){var r=t.slice(1).split("&");console.log("Stripping query parameters:",r);var s=r.filter(function(t){return"utm_"!==t.substr(0,4)&&"mc_"!==t.substr(0,3)&&"ct"!==t.substr(0,2)&&"_hsenc"!==t.substr(0,6)&&"_hsmi"!==t.substr(0,5)&&"mkt_tok"!==t.substr(0,7)&&"mbid"!==t.substr(0,4)});if(s.length!==r.length){var e=s.join("&");e&&(e="?"+e);var i=location.href.replace(t,e);history.replaceState({},document.title,i)}}}(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment