DescriptionI really, really, hate AMP pages.
They serve no useful purpose to me, and are often lacking functionality that I actually use. Also none-to-happy about the number of AMP sites that are hosted directly by Google.
Unfortunately, there still isn't a way to globally opt out of AMP for all sites (and Twitter have now taken to directing links to the AMP version automatically).
The aim of this issue is to create a ruleset for ABP/Ublock Origin which blocks amp.js and other dependancies in the hope that most pages should then react by redirecting you to the canonical URL.
Whilst it'd probably be possible to achieve the same with Greasemonkey (by detecting the canonical and going there instead), that's not really a useful option on mobile
Activity
2018-02-14 14:26:03
Within the response, we can see the callout to ampjs
So to begin with, let's blacklist cdn.ampproject.org in ABP.
Unfortunately, that doesn't help. Though the URL https://cdn.ampproject.org/v0/amp-ad-0.1.js can be blocked in either case, bad enough getting AMP, buggered if they're going to serve me ads at the same time
2018-02-15 12:37:06
Webhook User-Agent
View Commit
2018-02-15 13:55:06
Webhook User-Agent
View Commit
2018-02-15 14:04:34
2018-02-15 14:04:34
2018-02-15 14:04:41
2018-02-15 14:04:47
2018-02-15 14:06:32
Where the canonical isn't available (as it's almost certain there'll be pages which don't declare it) it'll instead inject a link to search (by page title) on DuckDuckGo to try and find the full-fat version of the site.
I've had to host the JS on my CDN as I didn't really want to inject so much javascript into every page, and couldn't load direct from GitHub because they return
Clients should cache for 30 days, and are able to revalidate, so even if lots of people use it, I shouldn't see too much of a change in traffic.
The injected anchor uses SRI so that if someone gains control over my back-end (or manages a successful MITM) they'll need to also get access to the github repo (and convince people to update).
2018-02-15 14:47:04
Webhook User-Agent
View Commit
2018-02-15 15:10:52
One that I am currently aware of is that
There isn't really a good way to address this in all cases, as anywhere not specifying
I assume it isn't possible to have Greasemonkey write values into the browser's view of the returned CSP headers, but even if it is, it's not something I'm willing to consider. That way lies many pains.
So, the conclusion here, is that the script will fail to fire (and generate console log info) on a subset of domains. Over time that subset may well increase if CSP sees an uptake in usage.
It hadn't really occurred to me before that CSP might kill the utility of things like GreaseMonkey/Tampermonkey, but I guess it's probably an obvious/inavoidable casualty. It does look like Tampermonkey has a basic fix for it though - https://github.com/Tampermonkey/tampermonkey/issues/418 though it'll change the way the code is pulled in (still may be worth looking at - https://github.com/Tampermonkey/tampermonkey/issues/472 )
2018-02-15 15:28:21
Amending the Tampermonkey script to use that method seems to work quite well with CSP enabled sites.
Should also shout out an apology to Scott Helme. I've been testing against his site as I know he has a good, robust CSP set up. Unfortunately (in this case), he's also got
The only changes needed are to the greasemonkey hook itself.
One additional benefit of this route, is that Tampermonkey doesn't include a referrer string when fetching the resource, so I'm not going to end up with details of other people's browsing sessions if they decide to use the script.
It also seems to trigger much, much faster so you don't get a partial load of the AMP page before the redirect fires.
Looks like a win to me so far, so I'm going to commit it and call it v1.2
2018-02-15 15:33:04
Webhook User-Agent
View Commit
2018-02-15 15:39:51
2018-02-15 15:47:32
- https://projectsstatic.bentasker.co.uk/MISC/MISC25/bad.html is AMP'd and should redirect to
- https://projectsstatic.bentasker.co.uk/MISC/MISC25/good.html
Both very, very simplistic pages, but the first should trigger the redirect
2018-02-15 15:52:20
There'll no doubt be more work to do in future though, given they're bringing AMP to email - https://techcrunch.com/2018/02/13/amp-for-email-is-a-terrible-idea/ - (though, at that point I may just switch all mail etc away from Google's services and pay someone else not to piss around with my mail).
2018-02-15 15:58:38
2018-02-15 15:58:38
2018-02-15 15:58:38
2018-02-15 15:58:42
2019-06-09 12:34:26
2019-06-09 12:34:26
2019-06-09 12:34:26
2019-06-09 12:34:26
2019-06-09 12:34:26
2019-06-09 12:34:26
2019-06-09 12:34:26
2019-06-09 12:38:17
- MISC-25 becomes FKAMP-1
- MISC-29 becomes FKAMP-2
- MISC-31 becomes FKAMP-3