From cf40936a9f764241ebbf6374f05217a4d22d0f29 Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Mon, 23 Nov 2020 18:12:40 +0100 Subject: [PATCH] =?UTF-8?q?Add=20El=20Peri=C3=B3dico=20(Spain)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 3 ++- background.js | 5 ++++- changelog.txt | 1 + contentScript.js | 24 ++++++++++++++++++++++++ manifest.json | 5 +++-- sites.js | 1 + 6 files changed, 35 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 2e944f2..5b4fe70 100644 --- a/README.md +++ b/README.md @@ -244,7 +244,8 @@ Visit the [Chrome repository](https://gitlab.com/magnolia1234/bypass-paywalls-ch [La Verdad](https://www.laverdad.es) - [Sur](https://www.diariosur.es) [El Mundo](https://www.elmundo.es) - -[El País](https://elpais.com) +[El País](https://elpais.com) - +[El Periódico](https://www.elperiodico.com) ##### Sweden [Aftonbladet](https://www.aftonbladet.se) - diff --git a/background.js b/background.js index fa8ce21..c733371 100644 --- a/background.js +++ b/background.js @@ -39,6 +39,7 @@ var allow_cookies_default = [ 'elmercurio.com', 'elmundo.es', 'elpais.com', + 'elperiodico.com', 'eurekareport.com.au', 'faz.net', 'financialpost.com', @@ -192,6 +193,7 @@ var blockedRegexes = { 'elmercurio.com': /(elmercurio\.com\/.+\/js\/modal\.js|merreader\.emol\.cl\/assets\/js\/(vendor\/modal|merPramV\d)\.js|staticmer(\d)?\.emol\.cl\/js\/.+\/(modal|PramModal\.min)\.js)/, 'elmundo.es': /cdn\.ampproject\.org\/v\d\/amp-access-.+\.js/, 'elpais.com': /.+\.epimg\.net\/js\/.+\/noticia\.min\.js/, + 'elperiodico.com': /cdn\.ampproject\.org\/v\d\/amp-(access|consent)-.+\.js/, 'estadao.com.br': /acesso\.estadao\.com\.br\/paywall\/.+\/pw\.js/, 'estrellavalpo.cl': /(.+\.mercuriovalpo\.cl\/impresa\/.+\/assets\/(vendor|\d)\.js|pram\.pasedigital\.cl\/API\/User\/Status\?)/, 'exame.abril.com.br': /cdn\.tinypass\.com\/.+/, @@ -686,6 +688,7 @@ ext_api.webRequest.onBeforeSendHeaders.addListener(function(details) { let au_swm_site = (header_referer && urlHost(header_referer).endsWith('com.au') && details.url.includes('https://s.thewest.com.au/')); let es_grupo_vocento_site = (matchUrlDomain('cdn.ampproject.org', details.url) && matchUrlDomain(es_grupo_vocento_domains, header_referer) && isSiteEnabled({url: header_referer})); let sz_amp_site = (matchUrlDomain('cdn.ampproject.org', details.url) && matchUrlDomain('sueddeutsche.de', header_referer) && isSiteEnabled({url: header_referer})); + if (!isSiteEnabled(details) && !inkl_site && !bloomberg_site && !au_nc_amp_site && !au_apn_site && !au_swm_site && !es_grupo_vocento_site && !sz_amp_site) { return; } @@ -768,7 +771,7 @@ ext_api.webRequest.onBeforeSendHeaders.addListener(function(details) { if (tabId !== -1) { ext_api.tabs.get(tabId, function (currentTab) { - if ((currentTab && isSiteEnabled(currentTab)) || medium_custom_domain || au_apn_site || au_swm_site || es_grupo_vocento_site || sz_amp_site) { + if ((currentTab && isSiteEnabled(currentTab)) || medium_custom_domain || au_apn_site || au_swm_site) { ext_api.tabs.executeScript(tabId, { file: 'contentScript.js', runAt: 'document_start' diff --git a/changelog.txt b/changelog.txt index 68e83a9..675e501 100644 --- a/changelog.txt +++ b/changelog.txt @@ -2,6 +2,7 @@ Changelog Bypass Paywalls Clean - Firefox Post-release +Add El Periodico (Spain) Add Grupo Vocento (Spain, regional daily) Fix-update Corriere Della Sera (redirect preview) Update block general paywall script (Pelcro) diff --git a/contentScript.js b/contentScript.js index 74bf8e1..614b529 100644 --- a/contentScript.js +++ b/contentScript.js @@ -1111,6 +1111,9 @@ else if (matchDomain("sueddeutsche.de")) { let paragraph_hidden = document.querySelectorAll('.paragraph--hidden'); for (let par_hidden of paragraph_hidden) par_hidden.classList.remove('paragraph--hidden'); + let paragraph_dynamic = document.querySelector('.paragraph--dynamic'); + if (paragraph_dynamic) + paragraph_dynamic.classList.remove('paragraph--dynamic'); let amp_offerpage = document.querySelector('.amp-offerpage'); removeDOMElement(amp_offerpage); } @@ -1666,6 +1669,27 @@ else if (matchDomain("corriere.it")) { } } +else if (matchDomain("elperiodico.com")) { + let url = window.location.href; + if (!url.includes('amp.elperiodico.com')) { + let paywall = document.querySelector('.ep-masPeriodico-info-login'); + if (paywall) { + window.setTimeout(function () { + window.location.href = url.replace('www.', 'amp.'); + }, 500); // Delay (in milliseconds) + } + } else { + let not_logged = document.querySelector('.ep-masPeriodico-info-login'); + if (not_logged) { + let non_subscr_section = document.querySelector('div[amp-access="NOT logged"]'); + removeDOMElement(not_logged, non_subscr_section); + let subscr_section = document.querySelector('div[amp-access="logged"]'); + if (subscr_section) + subscr_section.removeAttribute('amp-access-hide'); + } + } +} + // General Functions function removeDOMElement(...elements) { for (let element of elements) { diff --git a/manifest.json b/manifest.json index c1503ee..575103d 100644 --- a/manifest.json +++ b/manifest.json @@ -114,6 +114,7 @@ "*://*.elmundo.es/*", "*://*.elnortedecastilla.es/*", "*://*.elpais.com/*", + "*://*.elperiodico.com/*", "*://*.estadao.com.br/*", "*://*.estrellavalpo.cl/*", "*://*.eurekareport.com.au/*", @@ -328,6 +329,7 @@ "*://*.blueconic.net/*", "*://*.matheranalytics.com/*", "*://*.onecount.net/*", + "*://*.pelcro.com/*", "*://*.piano.io/*", "*://*.poool.fr/*", "*://*.qiota.com/*", @@ -350,10 +352,9 @@ "*://*.mppglobal.com/*", "*://*.nyt.com/*", "*://*.pasedigital.cl/*", - "*://*.pelcro.com/*", "*://*.rcsobjects.it/*", "*://*.repstatic.it/*", "*://*.userzoom.com/*" ], - "version": "1.9.6.3" + "version": "1.9.6.4" } \ No newline at end of file diff --git a/sites.js b/sites.js index 4632cbe..584fb33 100644 --- a/sites.js +++ b/sites.js @@ -48,6 +48,7 @@ var defaultSites = "El Mercurio de Valparaíso": "mercuriovalpo.cl", "El Mundo": "elmundo.es", "El País": "elpais.com", + "El Periódico": "elperiodico.com", "Encyclopedia Britannica": "britannica.com", "Eureka Report": "eurekareport.com.au", "Exame": "exame.abril.com.br",