KeepOnSmiling: A Safari Extension for Amazon Smile
If you happen to be in the miniscule intersection of people who 1) use Amazon Smile and 2) use the Safari web browser, you may be interested in a little (I mean, tiny) Safari extension I created, which I’m referring to as “KeepOnSmiling”.
Amazon Smile is a program whereby Amazon will donate a tiny portion of every purchase you make to a charity of your choosing — in our case, we support our local school. The only catch (if you can call it that) is that you have to remember to visit Amazon at smile.amazon.com instead of plain amazon.com. Me, I’m terrible at remembering things of greater consequence than this, so I went looking for a Safari extension to “remember” for me.
There are similar extensions for Chrome and Firefox, but the only one I found for Safari waited for the whole page to load before performing the redirect. In practice, this meant I would frequently be already beginning to type my query into Amazon’s search field when the page would reload. A minor annoyance in the grand scheme of things, but a fixable one.
So, I set out to write my own extension, which was straightforward enough. It’s not much more than three lines of JavaScript (and one of those a brace!) that modify the window (tab) location hostname, triggering a re-request. Luckily for my purposes, this seems to happen before the page is loaded, avoiding the problematic page reload.
In my admittedly self-serving testing, this appears to be working exactly as desired. Hopefully it may be of some use to others as well, so I’m making the extension and code available on GitHub. If there’s enough interest, I may even submit it to the Safari Extensions Gallery.