Black Lives Matter. Support the Equal Justice Initiative.

Home

This is doamatto.

Always Amazon Smiling Smiles Its Way to v1.0.0

2020/08/12 - Written by doamatto

Always Amazon Smiling (AAS, for short) has smiled its way to v1.0.0 with many performance and bug fixes.


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 http://amazon.co.uk/studioghibli 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 amazon.co.uk/studioghibli. 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 amazon.co.uk. 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 (amazon.co.uk) and final chunk (/studioghibli). The final redirect is https://smile.amazon.co.uk/studioghibli2.

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.

Related links:

  1. This is because some URLs don’t need to start with www. This site, for instance, is doamatto.xyz, however, you can still come from www.doamatto.xyz because of a redirection. 

  2. In this case, however, it’s technically redirected to https://www.amazon.co.uk/stores/page/6DD4F81B-3B1D-4037-8749-B95932B7C959, because it’s a “whitelabelled” URL. It’s just bounced a few times on Amazon’s part to get there. 


Tags: Updates and Other Projects. Subscribe to the Atom feed.