Exclusive: Bypass AMP Links with DeAMPify by João Dias
Back in late 2015, Google introduced the Accelerated Mobile Pages (AMP) Project to revolutionize the speed at which mobile web users consume web content. Since then, numerous web outlets (including our very own Portal) have incorporated AMP so that users on limited or slower data connections can quickly access their content. While some people have qualms with the way Google is pushing AMP on publishers, others lament the forcing of this new standard onto their mobile devices. For those users on fast connections, loading an AMP page versus the original page shows no significant difference in speed, but still results in less content being displayed on screen. However, unless the particular mobile app you were using has an option to disable loading a page in its AMP version, the only way to retrieve the original URL is to manually do so – adding 2 extra taps. Thanks to an idea I pitched to the AutoApps developer, João Dias, there’s finally a way to completely bypass AMP links.
The app is called DeAMPify and it is really, really fast at its job. Here is a sample screen recording I made. Note how short the time is between when I tap on DeAMPify to open the URL and how long after the original URL is opened in the browser.
How it works
The application registers itself as the default URL handler for AMP-style URLs. When the user chooses to open a link in DeAMPify (or selects it as the default handler, bypassing the dialog), the application scrapes the HTML source code of the AMP page to look for the original URL of the article. Once it finds the original URL, it takes that URL and passes it along to the default browser app. The process is very, very fast even though technically you are still downloading the HTML source of the AMP page, but on fast enough connections it makes little to no difference as the AMP pages are relatively tiny amounts of data to parse. To the end user, though, the result is that AMP links are completely bypassed and instead opened in the default app for that URL, whether it be your browser or another app such as the official Reddit app or XDA Labs.
In a little more detail, the app is specifically scraping the AMP page for the “canonical” (original) document by looking for the HTML link tag as such:
<link rel="canonical" href="https://www.example.com/url/to/canonical/document.html">
Every AMP page has this exact tag embedded in its HTML source as a part of the official specification. This is what allows AMP pages to detect and show the end user the original URL in the first place, but we can take advantage of this embedded link to bypass the need to ever show the user the mobile-optimized page. This method beats every other redirection tool we’ve found online, which simply attempted to retrieve the original content URL by performing a regex operation on the AMP URL. Since there’s no consistent URL scheme for AMP pages, that method would fail for many, many odd pages. But this won’t.
One caveat that we discovered when making this app is that the canonical link is not embedded in the HTML source when the source is retrieved through a mobile user agent, so instead DeAMPify operates as a desktop browser user agent. This is not something that ever makes a difference to the end user (you), but it’s interesting to note for anyone wondering how this app works.
Bypass AMP Links with DeAMPify
On to the actual app itself. DeAMPify does a tad bit more than just bypass AMP links. I mean, that’s 95% of what the app is there for, but it wouldn’t be fun if it only did that, no? To make the app a bit more useful, Mr. Dias added a few extra features to the app (although to access them, both require an in-app purchase):
- URL Exceptions: blacklist URLs which you always want to open the AMP page for, can use regex for this operation
- Tasker integration: choose when the bypass AMP service is running
The Tasker integration is the part that I’m sure many users would find useful, as with this you can automatically bypass AMP links only when connected to your home WiFi, for instance. The URL exceptions can be useful if there’s one or two particular sites that you always want to load AMP links for, but personally I haven’t really been using that feature.
DeAMPify is now available in the Google Play Store starting today. For those users who have hated the expansion of AMP pages everywhere on the web, you finally have a solution to say no to AMP. DeAMPify your web today!
Mr. Dias has generously offered to give away 15 promotional codes to unlock the pro version of DeAMPify. Leave a comment below with a link to your XDA-Developers forum profile and you may be randomly selected to receive a promotional code through a private message on the forums! Be sure to check your private messages for the code!
All the promotional codes have been given out, thanks for participating!