Skip to content

Instantly share code, notes, and snippets.

@jarp0l
Created November 22, 2025 18:01
Show Gist options
  • Select an option

  • Save jarp0l/be9d0287c8982d59759ebb09d831a450 to your computer and use it in GitHub Desktop.

Select an option

Save jarp0l/be9d0287c8982d59759ebb09d831a450 to your computer and use it in GitHub Desktop.
Strip UTM parameters from all links on techopsexamples.com
// ==UserScript==
// @name UTM Cleaner
// @namespace https://gist.github.com/jarp0l
// @version 1.0.0
// @description Strip UTM parameters from all links on page
// @author jarp0l
// @match https://www.techopsexamples.com/*
// @match http://www.techopsexamples.com/*
// @run-at document-end
// @updateURL https://gist.github.com/jarp0l/raw/techopsexamples-utm-cleaner.user.js
// @downloadURL https://gist.github.com/jarp0l/raw/techopsexamples-utm-cleaner.user.js
// @grant none
// ==/UserScript==
(function() {
const clean = url => {
try {
const u = new URL(url);
[...u.searchParams.keys()].forEach(k => {
if (k.toLowerCase().startsWith('utm_')) u.searchParams.delete(k);
});
return u.toString();
} catch(e) {
return url;
}
};
const process = () => {
document.querySelectorAll('a[href]').forEach(a => {
const c = clean(a.href);
if (c !== a.href) a.href = c;
});
};
process();
const obs = new MutationObserver(() => process());
obs.observe(document.body, { childList: true, subtree: true });
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment