From 50a6d95fae77b9124458ccd3b423d55c340e6023 Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Mon, 25 May 2020 21:01:41 +0200 Subject: [PATCH] Add ElMundo.es (amp for premium) --- README.md | 1 + background.js | 1 + contentScript.js | 19 +++++++++++++++++++ lp/manifest.json | 2 ++ sites.js | 1 + 5 files changed, 24 insertions(+) diff --git a/README.md b/README.md index d22a3f9..bb1d50b 100644 --- a/README.md +++ b/README.md @@ -205,6 +205,7 @@ Install add-on by downloading xpi-file. [Volkskrant](https://www.volkskrant.nl) - [Vrij Nederland](https://www.vn.nl) ##### Spain +[El Mundo](https://www.elmundo.es) - [El País](https://elpais.com) ##### Sweden [Aftonbladet](https://www.aftonbladet.se) - diff --git a/background.js b/background.js index 405bf74..5864430 100644 --- a/background.js +++ b/background.js @@ -156,6 +156,7 @@ var blockedRegexes = { 'economist.com': /(.+\.tinypass\.com\/.+|economist\.com\/engassets\/_next\/static\/chunks\/framework.+\.js)/, 'elcomercio.pe': /elcomercio\.pe\/pf\/dist\/template\/elcomercio-noticia.+\.js/, 'elmercurio.com': /merreader\.emol\.cl\/assets\/js\/vendor\/modal\.js/, +'elmundo.es': /cdn\.ampproject\.org\/v\d\/amp-access-.+\.js/, 'elpais.com': /.+\.epimg\.net\/js\/.+\/noticia\.min\.js/, 'exame.abril.com.br': /.+\.tinypass\.com\/.+/, 'folha.uol.com.br': /.+\.folha\.uol\.com\.br\/paywall\/js\/.+\/publicidade\.ads\.js/, diff --git a/contentScript.js b/contentScript.js index e7936b6..6836898 100644 --- a/contentScript.js +++ b/contentScript.js @@ -636,6 +636,25 @@ else if (matchDomain('lejdd.fr')) { } } +else if (matchDomain('elmundo.es')) { + let premium = document.querySelector('.ue-c-article__premium'); + window.setTimeout(function () { + if (premium && window.location.href.includes('/www.elmundo.es/')) { + window.location.href = window.location.href.replace('/www.', '/amp.'); + } + }, 500); // Delay (in milliseconds) + if (window.location.href.includes('/amp.elmundo.es/')) { + let paywall = document.querySelector('div[amp-access="authorized!=true"]'); + if (paywall) { + removeDOMElement(paywall); + let div_hidden = document.querySelector('div[amp-access="authorized=true"]'); + if (div_hidden) { + div_hidden.removeAttribute('amp-access-hide'); + } + } + } +} + // General Functions function removeDOMElement(...elements) { for (let element of elements) { diff --git a/lp/manifest.json b/lp/manifest.json index 4564da4..e736843 100644 --- a/lp/manifest.json +++ b/lp/manifest.json @@ -90,6 +90,7 @@ "*://*.economist.com/*", "*://*.elcomercio.pe/*", "*://*.elmercurio.com/*", + "*://*.elmundo.es/*", "*://*.elpais.com/*", "*://*.estadao.com.br/*", "*://*.eurekareport.com.au/*", @@ -236,6 +237,7 @@ "*://*.poool.fr/*", "*://*.tinypass.com/*", "*://*.piano.io/*", + "*://*.ampproject.org/*", "*://*.blueconic.net/*", "*://*.cedsdigital.it/*", "*://*.corriereobjects.it/*", diff --git a/sites.js b/sites.js index 479573e..0cfd0bc 100644 --- a/sites.js +++ b/sites.js @@ -31,6 +31,7 @@ var defaultSites = "Digiday": "digiday.com", "El Comercio": "elcomercio.pe", "El Mercurio": "elmercurio.com", + "El Mundo": "elmundo.es", "El País": "elpais.com", "Encyclopedia Britannica": "britannica.com", "Eureka Report": "eurekareport.com.au",