From 069ee386731a5b6533fc6f5d30b91ee2559119d8 Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Sun, 16 May 2021 17:37:08 +0200 Subject: [PATCH] Fix-update Repubblica.it --- changelog.txt | 1 + contentScript.js | 25 ++++++++++++++++--------- manifest.json | 2 +- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/changelog.txt b/changelog.txt index 4eddd9f..5ed5ba5 100644 --- a/changelog.txt +++ b/changelog.txt @@ -9,6 +9,7 @@ Fix-update Crain's Chicago Business Fix-update GenomeWeb sites Fix-update Knack.be Fix-update LeScienze.it +Fix-update Repubblica.it Fix-update South China Morning Post (amp) * v2.2.0.0 (2021-05-09) diff --git a/contentScript.js b/contentScript.js index b292d99..fd13ee9 100644 --- a/contentScript.js +++ b/contentScript.js @@ -1066,15 +1066,22 @@ else if (domain = matchDomain(it_repubblica_domains)) { let url = window.location.href; if (!url.includes('/amp/')) { let premium = document.querySelector('.paywall-adagio, #paywall'); - removeDOMElement(premium); - window.setTimeout(function () { - let amphtml = document.querySelector('link[rel="amphtml"]'); - if (premium && amphtml && (['lastampa.it', 'repubblica.it'].includes(domain))) - window.location.href = amphtml.href; - let article_body = document.querySelector('div#article-body[style]'); - if (article_body) - article_body.removeAttribute('style'); - }, 500); // Delay (in milliseconds) + if (premium) { + removeDOMElement(premium); + if (['lastampa.it', 'repubblica.it'].includes(domain)) { + let amphtml = document.querySelector('link[rel="amphtml"]'); + if (!amphtml) + amphtml = {href: url.split('?')[0] + 'amp'}; + if (amphtml) + window.location.href = amphtml.href; + } else { + window.setTimeout(function () { + let article_body = document.querySelector('div#article-body[style]'); + if (article_body) + article_body.removeAttribute('style'); + }, 1000); // Delay (in milliseconds) + } + } } else { let paywall; if (['lastampa.it', 'repubblica.it'].includes(domain)) { diff --git a/manifest.json b/manifest.json index fc3c3d8..3910770 100644 --- a/manifest.json +++ b/manifest.json @@ -515,5 +515,5 @@ "*://*.wallkit.net/*", "*://*.wsj.net/*" ], - "version": "2.2.0.8" + "version": "2.2.0.9" } \ No newline at end of file