Replace WWW in URL

I would like to automatically replace the "www" for all Amazon URLs with "smile" in Chrome

Amazon will ONLY make a contribution to the non-profit organization associated with your Amazon account when purchases are made from a SMILE URL.

For example, instead of using this standard WWW URL:
https://www.amazon.com/Culligan-Certified-WHR-140-Replacement-Cartridge/dp/B0006VVN1I/

I would need to purchase the product from its SMILE URL:
https://smile.amazon.com/Culligan-Certified-WHR-140-Replacement-Cartridge/dp/B0006VVN1I/

I require assistance executing this logic in Keyboard Maestro:

If %ChromeURL% contains www.amazon.com
Set variable (amazonURL) with %ChromeURL%
Modify amazonURL ("replace" www with "smile")
Replace %ChromeURL% with amazonURL

You've pretty much got it.

image

Some changes I made:

  1. Use a Local Variables instead of a global since you don't need the variable later.
  2. Search for "www." to make sure we are getting the "www" that we want.

Questions?

Many Thanks - works like a charm

I merely made a small change - instead of searching for and replacing "www." I used "www.amazon.com" instead — Was there a reason why you did not include the domain to make the queries more specific?

No reason. Your solution is better.

1 Like

Iron - Sharpens - Iron

2 Likes