From ef80a04a7e766dde1674fe4ab85cf0ba6c0c5882 Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Thu, 21 Apr 2022 22:08:25 +0200 Subject: [PATCH] Fix The Spectator UK (amp-redirect) --- changelog.txt | 1 + contentScript.js | 23 +++++++++++++---------- custom/manifest.json | 2 +- manifest.json | 2 +- sites_updated.json | 9 --------- 5 files changed, 16 insertions(+), 21 deletions(-) diff --git a/changelog.txt b/changelog.txt index 0d5abfd..6364029 100644 --- a/changelog.txt +++ b/changelog.txt @@ -10,6 +10,7 @@ Add Podium Runner Add Rock and Ice Fix El Pais (amp/video) Fix Fortune (magazine) +Fix The Spectator UK (amp-redirect) * v2.6.5.0 (2022-04-18) Add Aftonbladet.se diff --git a/contentScript.js b/contentScript.js index daf2b42..36848cf 100755 --- a/contentScript.js +++ b/contentScript.js @@ -2035,16 +2035,19 @@ else if (matchDomain('prospectmagazine.co.uk')) { } else if (matchDomain('spectator.co.uk')) { - let url = window.location.href.split('?')[0]; - if (url.match(/\/amp(\/)?$/)) { - let paywall = document.querySelectorAll('div[amp-access^="p.show"'); - let not_logged_in = document.querySelector('div[amp-access*="NOT loggedIn"]'); - removeDOMElement(...paywall, not_logged_in) - } else { - let premium = document.querySelector('.HardPayWallContainer-module__overlay'); - removeDOMElement(premium); - if (premium) - window.location.href = url + '/amp'; + if (window.location.pathname.match(/\/amp(\/)?$/)) { + let banners = document.querySelectorAll('div[amp-access^="p.show"], div[amp-access*="NOT loggedIn"]'); + removeDOMElement(...banners); + } else if (window.location.pathname.startsWith('/article/')) { + let paywall = document.querySelector('.HardPayWallContainer-module__overlay'); + let body_par = document.querySelector('p[class^="ContentPageBodyParagraph"]'); + let amphtml = document.querySelector('link[rel="amphtml"]'); + if ((paywall || !body_par) && amphtml) { + removeDOMElement(paywall); + window.setTimeout(function () { + window.location.href = amphtml.href; + }, 500); + } } } diff --git a/custom/manifest.json b/custom/manifest.json index c02b317..2fea137 100644 --- a/custom/manifest.json +++ b/custom/manifest.json @@ -42,5 +42,5 @@ "webRequestBlocking", "" ], - "version": "2.6.5.3" + "version": "2.6.5.4" } diff --git a/manifest.json b/manifest.json index 96d1ff5..d0e40bb 100755 --- a/manifest.json +++ b/manifest.json @@ -660,5 +660,5 @@ "*://*.wsj.net/*", "*://webcache.googleusercontent.com/*" ], - "version": "2.6.5.3" + "version": "2.6.5.4" } diff --git a/sites_updated.json b/sites_updated.json index f24e520..cd82d87 100644 --- a/sites_updated.json +++ b/sites_updated.json @@ -16,11 +16,6 @@ "allow_cookies": 1, "block_regex": "\\.amazonaws\\.com\\/s3fs-public\\/js\\/js_.+\\.js" }, - "Berliner Zeitung": { - "domain": "berliner-zeitung.de", - "allow_cookies": 1, - "block_regex": "cdn\\.ampproject\\.org\\/v\\d\\/amp-(ad|fx-flying-carpet|subscriptions)-.+\\.js" - }, "Better Nutrition": { "domain": "betternutrition.com", "group_rule": "###_gr_usa_outside_mag_domains" @@ -39,10 +34,6 @@ "domain": "investorschronicle.co.uk", "referer": "google" }, - "Nürnberger Nachrichten": { - "domain": "nn.de", - "block_regex": "(cdn\\.cxense\\.com\\/|\\.piano\\.io\\/)" - }, "Outlook India": { "domain": "outlookindia.com", "allow_cookies": 1,