upvote
This corrupts a URL like:

  https://example.com/?p=20&utm_source=spam
to:

  https://example.com/
when in fact we want the following:

  https://example.com/?p=20
A possible improvement can be:

  javascript:(()=>{const u=new URL(location.href);[...u.searchParams.keys()].forEach(k=>{if(k.startsWith('utm_')){u.searchParams.delete(k)}});navigator.clipboard.writeText(u.href)})();
reply
This is great! I love one-liners that are readable like this. This made me wonder if there are any extensions that run a script on every page load for a web browser. I'm currently experimenting with userscript managers and plan on including your code as an additional security measure against tracking.
reply