Skip to content

Instantly share code, notes, and snippets.

@alllex
Created April 16, 2021 11:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alllex/ae1e8c522cdc9a140d03666cf464de8f to your computer and use it in GitHub Desktop.
Save alllex/ae1e8c522cdc9a140d03666cf464de8f to your computer and use it in GitHub Desktop.
A bookmarketlet, that remote any query parameters starting with `utm_` from the current URL.
javascript:
(function () {
const oldSearch = window.location.search;
let newSearch =
oldSearch.replace(/&?utm_[^=]*?=[^&]*?(?:&|$)/ig, "");
if (newSearch === "?") {
newSearch = "";
}
window.location.href =
window.location.protocol + "//" +
window.location.host +
window.location.pathname +
window.location.hash +
newSearch;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment