Always Amazon Smiling

3 min read • 12 August, 2020.

{{item( status="released", date="3 May, 2020", info="Always Amazon Smiling has officially launched and is now available on the Chrome Web Store and Firefox Add-on Store. This open-source extension takes all the appropriate requests and supported Amazon sites and redirects them to their Amazon Smile counterparts to help raise money for charities. You can learn more here." )}}

AAS was meant as a "demo" to see how I liked making some browser extensions. Turns out: it's pretty fun and it helps to know what you're doing. Recently, I returned to AAS to give it an update due to a lot of bug reports in my inbox and personal issues I've had with the extension.

In v1.0.0, the biggest change is how links are processed. I've explained what the code does but not exactly why. I might be able to make this more efficient in the future, but, for now, this is a solid start. It starts with fetching the URL you're going to. We're going to have be your query to your browser, as an example. This is then stripped of its protocol. The protocol is essentially the http:// or https:// bit at the start of URLs. In one line, we remove either of the two. Our query now is A check for www. is then done and removes that chunk if the check succeeds. Otherwise, it continues.1

Following this, we temporarily save the domain base and remove it from the chunk. So, in this case, our base is After this, we're left with /studioghibli. We then piece everything back together to form the redirection. The format is as follows: https://smile. followed by our base ( and final chunk (/studioghibli). The final redirect is

The new system is way more efficient, documented, and, overall, smarter than the old method that broke frequently. With this new update, I've also employed measures such as ESlint and JavaScript minification to lower the package size and help milk every bit of performance I can get. This ensures pages load just as fast, even with this slight overhead.


This is because some URLs don't need to start with www. This site, for instance, is, however, you can still come from because of a redirection. 2: In this case, however, it's technically redirected to, because it's a "whitelabelled" URL. It's just bounced a few times on Amazon's part to get there.

I usually blog twice a week, but I take breaks from time-to-time. You can subscribe via RSS.