diff --git a/background.js b/background.js index 72a0172a..b156ba9b 100644 --- a/background.js +++ b/background.js @@ -6,7 +6,7 @@ var ext_name = manifestData.name; var ext_version = manifestData.version; const cs_limit_except = ['elespanol.com', 'faz.net', 'nation.africa', 'nationalgeographic.com'].concat(de_westfalen_medien_domains); -const dompurify_sites = ['asiatimes.com', 'bloomberg.com', 'cicero.de', 'ilmanifesto.it', 'iltalehti.fi', 'iltirreno.it', 'ipolitics.ca', 'italiaoggi.it', 'lanuovasardegna.it', 'lesechos.fr', 'marianne.net', 'newleftreview.org', 'newscientist.com', 'nzherald.co.nz', 'outlookbusiness.com', 'prospectmagazine.co.uk', 'stratfor.com', 'techinasia.com', 'timesofindia.com', 'valor.globo.com', 'vn.nl'].concat(be_mediahuis_domains, nl_mediahuis_region_domains, no_nhst_media_domains); +const dompurify_sites = ['asiatimes.com', 'bloomberg.com', 'cicero.de', 'ilmanifesto.it', 'iltalehti.fi', 'iltirreno.it', 'ipolitics.ca', 'italiaoggi.it', 'lanuovasardegna.it', 'lesechos.fr', 'marianne.net', 'newleftreview.org', 'newscientist.com', 'nzherald.co.nz', 'outlookbusiness.com', 'prospectmagazine.co.uk', 'spectator.co.uk', 'stratfor.com', 'techinasia.com', 'timesofindia.com', 'valor.globo.com', 'vn.nl'].concat(be_mediahuis_domains, nl_mediahuis_region_domains, no_nhst_media_domains); var currentTabUrl = ''; var csDone = false; var optin_setcookie = false; @@ -24,6 +24,7 @@ var restrictions = { 'esquire.com': /^((?!\/classic\.esquire\.com\/).)*$/, 'faz.net': /^((?!\.faz\.net\/aktuell\/(\?switchfaznet)?$).)*$/, 'lastampa.it': /^((?!\/video\.lastampa\.it\/).)*$/, + 'lequipe.fr': /^((?!\.lequipe\.fr\/.+\/les-notes\/).)*$/, 'nytimes.com': /^((?!\/timesmachine\.nytimes\.com\/).)*$/, 'science.org': /^((?!\.science\.org\/doi\/).)*$/, 'timesofindia.com': /\.timesofindia\.com($|\/($|toi-plus(\/.+)?|.+\.cms))/, diff --git a/changelog.txt b/changelog.txt index 491e0a6e..b88637cc 100644 --- a/changelog.txt +++ b/changelog.txt @@ -7,6 +7,7 @@ Add BusinessPost.ie Add Private Equity News Fix Esprit.presse.fr Fix Gruppo GEDI.it (login) +Fix The Spectator UK (no amp) * v2.8.4.0 (2022-09-11) Add PEI Media sites (opt-in to custom sites) diff --git a/contentScript.js b/contentScript.js index 44aa08be..df00c780 100644 --- a/contentScript.js +++ b/contentScript.js @@ -1292,7 +1292,7 @@ else if (matchDomain('leparisien.fr')) { else if (matchDomain('lequipe.fr')) { let paywall = document.querySelectorAll('.Paywall, .Article__paywall'); - if (paywall.length) { + if (window.location.pathname.includes('/Article/') && paywall.length) { let scripts = document.querySelectorAll('script:not([src], [type])'); let json_script; for (let script of scripts) { @@ -2175,18 +2175,26 @@ else if (matchDomain('prospectmagazine.co.uk')) { } else if (matchDomain('spectator.co.uk')) { - 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'); + if (window.location.pathname.startsWith('/article/')) { 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); + if (!body_par && dompurify_loaded) { + csDoneOnce = true; + let url = window.location.href; + fetch(url) + .then(response => { + if (response.ok) { + response.text().then(html => { + let parser = new DOMParser(); + let doc = parser.parseFromString('
' + DOMPurify.sanitize(html) + '
', 'text/html'); + let article = document.querySelector('main > div'); + let article_new = doc.querySelector('main > div'); + if (article_new) { + if (article) + article.appendChild(article_new); + } + }) + } + }) } } } @@ -4004,6 +4012,8 @@ else if ((domain = matchDomain(usa_lee_ent_domains)) || document.querySelector(' elem.removeAttribute('style'); elem.removeAttribute('class'); } + let banners = document.querySelectorAll('div.subscription-required, div.redacted-overlay, div.tnt-ads-container'); + removeDOMElement(...banners); } } diff --git a/manifest.json b/manifest.json index b87208f9..d26086d1 100644 --- a/manifest.json +++ b/manifest.json @@ -705,5 +705,5 @@ "*://gcm.omerlocdn.com/*", "*://webcache.googleusercontent.com/*" ], - "version": "2.8.4.3" + "version": "2.8.4.4" }