# popclip
name: Remove Tracking
requirements: [url]
javascript: popclip.pasteText(popclip.input.text.replace(/\?.*/, ''))
description: Remove tracking code from the selected URL.
I haven’t tried it in PopClip (I’m on mobile) but the (\?.*) appears to successfully capture anything following a ? in the URL. As it stands, it captures anything following a ? at all, even if it isn’t a URL. But if you only use it on URLs, it should work
I als added a line requirements: [url] which constrains the extension to only appear when the selection contains a web URL.
Worth noting that this removes the entire query part of the URL, not just tracking codes. But makign it target tracking specifically would be significantly more complicated!
Wonderful — thanks! And thanks for making PopClip so easy to customize. Nice touch making it work on URLs only.
I’m gradually making all my bookmarklets into PopClip snippets; that’s way I can use whichever is most useful in the moment. Will post here if they’re useful beyond my own workflows.
Hi @tf2
Thank you very much for that idea to shorten URLs from tracking.
My question as an amateur: How can I add that functionality to Popclip?
Will there be an additional Popclip Extension or do I have to create that myself?
(Sorry for being so naive!)
With PopClip running on your Mac, use your mouse/trackpad to select the text of the snippet, including the first and last lines. PopClip should appear, with an addition item showing the name of the snippet. Click on that and it’ll install.
In other words, PopClip itself turns the text of the snippet into a new PopClip extension.
Brilliant, they are indeed. I guess I’d need the ‘show in finder’ or similar option installed. It’d be useful (for the future) if they could be sync’ed in iCloud and therefore safely backed up automatically?
So this is coming late, but I’m just learning about this awesome new extension snippet stuff.
Regarding your URL snippet, which is amazing, how do you trigger Popclips to copy it? Do you have to always copy a link, then paste it somewhere, then highlight it to trigger Popclip?
Is there a way to trigger a Popclip action just by right-clicking on the link?
Glad you are enjoying the snippets! I introduced them only a few months ago as a kind of “soft launch” experimental feature, while I make sure they work right and figure out how to explain them. Honestly, they have gone better than I imagined and I’ve been pleasantly surprised how well they have been received. It’s been great to see people sharing snippets and helping figure out ways to do things.
So as for URLs, PopClip right now only works on URLs that are in view in the selected plain text, for example, that you might select in the address bar.
Or as as you say, paste somewhere else.
However….
PopClip does have the ability theoretically, to look at the HTML behind the selection, and I so hope to have it working directly on Web page links in future. At least, in some form.
It makes PopClip a little less snappy and response in browsers when it is getting the HTML, so it doesn’t do it at the moment. Is a tricky one to figure out the right balance of compromises in the UI to do it.
I suspect it may require an extra click to “X-ray” the links. Anyway, I’m rambling