An Automatic URL Decrufter for Defined Hosts

A while back, a friend and I were discussing the amount of cruft in many URLs. As an example, here's a URL from a recent Monoprice email newsletter. Note: I changed a few of the characters so these URLs will not work; they're for demonstration purposes only.

http://enews.emails.monoprice.com/q/LLMxJBmP1xo0XEpHXEE5PmLbqHbNxpVsuheZcOJcm9iZ0Bnc3lmZnN3ZWIuY29tw4gZyWuu1KtfpSL58gax3zGue2fhqQ

If you load that in your browser, here's what you'll see in the URL bar:

https://www.monoprice.com/product?p_id=11297&trk_msg=8OLJJ72Q87O4PCIC9HC71NL7VS&trk_contact=T3KPNYKTNJTD6NU53HNJCDD7T4&trk_sid=FGHVB9JP6L3MVLERLES7DLEGEG&trk_link=9HBDB7KBCAEKT949P8P8JQG5J4&cl=res&utm_source=email&utm_medium=email&utm_term=View+product+recommended+for+you&utm_campaign=210902_thursday

But everything after the "p_id..." bit is simply tracking information; this is the actual URL:

https://www.monoprice.com/product?p_id=11297

You may not wish to share all that tracking information with companies every time you click one of their URLs. Enter the URL Decrufter, which works whenever you copy a URL—it checks the domain to see if it's one you want to decruft, and if so, cleans it up and opens it in your browser (and puts it on the clipboard).

I posted a very rough version of this a couple weeks back, but it's now a much more refined solution (up to version five now), and ready to use without any required editing. Here's the full macro, along with the various sub-macros I use (for ease of maintenance and readability, mainly):

URL_Decrufter_Macros.zip (20.7 KB)

The thing may look intimidating, but much of what's there are just simple sub-macros to do one thing. As a result, the main macro is basically just a bunch of calls to other macros. (I've tested, and there's a barely-measurable difference in execution time when done this way.)

Macro steps that contain areas you may have to (or want to) edit are colored green, comments are marked in yellow, and I clear all the variables that are used after each run with one exception—there's now a history variable that I use to keep track of previously-cleaned URLs, so they're not cleaned again if you copy them (say from your browser's URL bar) in the future.

There's now a complete (if basic) set of instructions in the main macro, and this version will "just work" out of the box—you should only need to edit to add domains to filter, which can either be really simple (one word added to one macro) or much tougher—see the instructions for more details.

I'd love your feedback, and if you have domains that you'd like to see filtered, feel free to contact me with the copied URL and I'll try to get them in the macro.

-rob.

4 Likes