Clean Amazon URL

Hey everyone,

I would love a macro that takes an Amazon URL and removes its name and tracking parameters - for example:

Original URL

https://www.amazon.com/Logitech-Calling-Noise-Canceling-Correction-Microsoft/dp/B01N5UOYC4/ref=sr_1_3?crid=15BN0HFR1TCDC&keywords=logitech%2B960-001105&qid=1650730397&sprefix=logitech%2B960-001105%2Caps%2C89&sr=8-3&th=1

Clean URL (name and tracking parameters removed)

https://www.amazon.com/dp/B01N5UOYC4

Any ideas how to do this are greatly appreciated.

Thank you.

There are a number of ways to do this, but the approach I've used in the past with something like this is to use a Third Party Plug In Action to do the heavy lifting.

The plug in is called Split and you can download it from the Plug In Actions category of this forum; find it here:

Once you've installed it you can easily split out the bits from the URL and reassemble them. Here is a demo macro for you to use as a basis for your own solution.

Test Clean Amazon URL.kmmacros (3.8 KB)

Click to see image of macro

This does depend entirely on the format of the Amazon URL being consistent, so if it isn't you'll have to modify this approach. Good luck!

I've had some version of this in my set of URL-handling macros for a while, and I don't remember it ever failing me.

Clean Amazon Link.kmmacros (3.1 KB)

View macro

If you install it, it will appear in the Temporary group and will be enabled.

It acts on the URL of the frontmost browser tab and puts the clean result on the clipboard. The browser itself does not have to be the active application, nor does the original URL have to be on the clipboard before you run the macro. At present, I believe the browsers for which this works are limited to Safari and Chrome. See the wiki for info on the FrontBrowserURL token.

1 Like

This is perfect - thank you!

How can I move this macro out of the Temporary group?

Thanks again!

Either

  • drag it from the middle column into whatever group you like in the left column; or
  • cut, switch to the group you want to move it into, and paste.

I've been informed by @ccstone that what I said about its enabled/disabled state may be wrong, but I'm guesing you already have that figured out.