3 ms·
While I don't take the author's hard stance, I do hate gratuitous query params that result in links that are thousands of characters long. I use this bookmarkl
by hamdingers 5mo ago
While I don't take the author's hard stance, I do hate gratuitous query params that result in links that are thousands of characters long.
I use this bookmarklet to strip query params before sharing a link:
javascript:(()=>navigator.clipboard.writeText(location.origin+location.pathname))();
- kittikitti 5mo agoThis 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.
- susam 5mo agoThis 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)})();
- hamdingers 5mo agoWe have different goals. I do this to strip unnecessary junk off of product page links I'm going to share, and your version now does nothing to (for example) Amazon PDP links. I understand it doesn't work for every kind of link and that's fine. If I did want to support paginated/search pages, I would allowlist only `p` and `q` rather than specifically blocking one type of analytics.
- susam 5mo agoYes, that's fair. Indeed my so called improvement requires continual maintenance to add new parameters to the blocklist, which somewhat defeats what is perhaps the main purpose: convenience. While it is clear that your solution works well for you and would probably work for me too for most types of 'bad' URLs, I am noting down an allowlist based solution for my own satisfaction and future reference: javascript:(()=>{const u=new URL(location.href);[...u.searchParams.keys()].forEach(k=>{if(!['p','q'].includes(k)){u.searchParams.delete(k)}});navigator.clipboard.writeText(u.href)})(); Tested with the following URL: https://duckduckgo.com/?ia=web&origin=funnel_home_website&t=h_&q=hello+world&chip-select=search The bookmarklet copies this cleaned version of the URL: https://duckduckgo.com/?q=hello+world