3 min read • 12 August, 2020.
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 https://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.
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.