From 8f49d5b59338cadd56fda0778fe274cdeb15d814 Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Sat, 21 Nov 2020 19:21:08 +0100 Subject: [PATCH] Add Grupo Vocento (Spain, regional daily) --- README.md | 10 +++++++++- background.js | 17 ++++++++++++++--- changelog.txt | 1 + contentScript.js | 24 ++++++++++++++++++++++++ manifest.json | 20 ++++++++++++++------ sites.js | 1 + 6 files changed, 63 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 71f98f5..7ed50c3 100755 --- a/README.md +++ b/README.md @@ -272,7 +272,15 @@ Visit the [Firefox repository](https://gitlab.com/magnolia1234/bypass-paywalls-f [Republic.ru](https://republic.ru) ##### Spain -[ABC](https://www.abc.es) - +[ABC](https://www.abc.es) and regional sites from Grupo Vocento (grouped in options) like +[Diario Vasco](https://www.diariovasco.com) - +[El Correo](https://www.elcorreo.com) - +[El Diario Montañés](https://www.eldiariomontanes.es) - +[El Norte de Castilla](https://www.elnortedecastilla.es) - +[Hoy](https://www.hoy.es) - +[La Rioja](https://www.larioja.com) - +[La Verdad](https://www.laverdad.es) - +[Sur](https://www.diariosur.es) [El Mundo](https://www.elmundo.es) - [El País](https://elpais.com) diff --git a/background.js b/background.js index 37ebe65..49ef55b 100755 --- a/background.js +++ b/background.js @@ -277,8 +277,10 @@ const ad_region_domains = ['bd.nl', 'ed.nl', 'tubantia.nl', 'bndestem.nl', 'pzc. const au_comm_media_domains = ['bendigoadvertiser.com.au', 'bordermail.com.au', 'canberratimes.com.au', 'centralwesterndaily.com.au', 'dailyadvertiser.com.au', 'dailyliberal.com.au', 'examiner.com.au', 'illawarramercury.com.au', 'newcastleherald.com.au', 'northerndailyleader.com.au', 'portnews.com.au', 'standard.net.au', 'theadvocate.com.au', 'thecourier.com.au', 'westernadvocate.com.au']; const au_news_corp_domains = ['adelaidenow.com.au', 'cairnspost.com.au', 'couriermail.com.au', 'dailytelegraph.com.au', 'geelongadvertiser.com.au', 'goldcoastbulletin.com.au', 'heraldsun.com.au', 'ntnews.com.au', 'theaustralian.com.au', 'themercury.com.au', 'townsvillebulletin.com.au', 'weeklytimesnow.com.au']; const au_prov_news_domains = ['news-mail.com.au', 'frasercoastchronicle.com.au', 'gladstoneobserver.com.au', 'dailyexaminer.com.au', 'dailymercury.com.au', 'themorningbulletin.com.au', 'sunshinecoastdaily.com.au', 'gympietimes.com.au', 'northernstar.com.au', 'qt.com.au', 'thechronicle.com.au', 'warwickdailynews.com.au']; +const es_grupo_vocento_domains = ['diariosur.es', 'diariovasco.com', 'elcorreo.com', 'eldiariomontanes.es', 'elnortedecastilla.es', 'hoy.es', 'larioja.com', 'laverdad.es']; const ilmessaggero_domains = ['corriereadriatico.it', 'ilgazzettino.it', 'ilmattino.it', 'quotidianodipuglia.it']; const nymag_domains = ['grubstreet.com', 'thecut.com', 'vulture.com']; +// pg_domains has only grouped remove_cookies_select_drop rules const pg_domains = ['parool.nl', 'trouw.nl', 'volkskrant.nl', 'humo.be', 'demorgen.be']; const userAgentDesktopG = "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" @@ -290,7 +292,7 @@ const userAgentMobileB = "Chrome/80.0.3987.92 Mobile Safari/537.36 (compatible; var enabledSites = []; var disabledSites = []; var defaultSites_grouped_domains = Object.values(defaultSites); -var defaultSites_domains = defaultSites_grouped_domains.concat(ad_region_domains, au_comm_media_domains, au_news_corp_domains, au_prov_news_domains, nymag_domains, ilmessaggero_domains); +var defaultSites_domains = defaultSites_grouped_domains.concat(ad_region_domains, au_comm_media_domains, au_news_corp_domains, au_prov_news_domains, es_grupo_vocento_domains, ilmessaggero_domains, nymag_domains); var customSites = {}; var customSites_domains = []; @@ -320,6 +322,10 @@ function add_grouped_sites(init_rules) { allow_cookies.push(domain); use_google_bot.push(domain); } + for (let domain of es_grupo_vocento_domains) { + allow_cookies.push(domain); + blockedRegexes[domain] = /cdn\.ampproject\.org\/v\d\/amp-access-.+\.js/; + } for (let domain of ilmessaggero_domains) blockedRegexes[domain] = /utils\.cedsdigital\.it\/js\/PaywallMeter\.js/; for (let domain of pg_domains) @@ -341,6 +347,10 @@ function add_grouped_sites(init_rules) { enabledSites = enabledSites.concat(au_prov_news_domains); else disabledSites = disabledSites.concat(au_prov_news_domains); + if (enabledSites.includes('###_es_grupo_vocento')) + enabledSites = enabledSites.concat(es_grupo_vocento_domains); + else + disabledSites = disabledSites.concat(es_grupo_vocento_domains); if (enabledSites.includes('ilmessaggero.it')) enabledSites = enabledSites.concat(ilmessaggero_domains); else @@ -674,8 +684,9 @@ ext_api.webRequest.onBeforeSendHeaders.addListener(function(details) { let au_nc_amp_site = (matchUrlDomain('cdn.ampproject.org', details.url) && matchUrlDomain(au_news_corp_domains, header_referer) && isSiteEnabled({url: header_referer})); let au_apn_site = (header_referer && (urlHost(header_referer).endsWith('com.au') || urlHost(header_referer).endsWith('net.au')) && details.url.includes('https://media.apnarm.net.au/')); 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 && !sz_amp_site) { + 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; } @@ -757,7 +768,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 || sz_amp_site) { + if ((currentTab && isSiteEnabled(currentTab)) || medium_custom_domain || au_apn_site || au_swm_site || es_grupo_vocento_site || sz_amp_site) { ext_api.tabs.executeScript(tabId, { file: 'contentScript.js', runAt: 'document_start' diff --git a/changelog.txt b/changelog.txt index d84524c..d1e2f5e 100644 --- a/changelog.txt +++ b/changelog.txt @@ -2,6 +2,7 @@ Changelog Bypass Paywalls Clean - Chrome Post-release +Add Grupo Vocento (Spain, regional daily) Update block general paywall script (Pelcro) Update grouped sites (init rules) diff --git a/contentScript.js b/contentScript.js index 092deed..34d9165 100755 --- a/contentScript.js +++ b/contentScript.js @@ -4,6 +4,8 @@ var domain; // clean local storage of sites (with an exemption for hold-list) var arr_localstorage_hold = ['elmundo.es', 'kurier.at', 'nknews.org', 'nrz.de', 'seekingalpha.com', 'sfchronicle.com', 'thehindu.com', 'thetimes.co.uk', 'waz.de', 'wp.de', 'wr.de']; +var es_grupo_vocento_domains = ['diariosur.es', 'diariovasco.com', 'elcorreo.com', 'eldiariomontanes.es', 'elnortedecastilla.es', 'hoy.es', 'larioja.com', 'laverdad.es']; +arr_localstorage_hold = arr_localstorage_hold.concat(es_grupo_vocento_domains); if (!matchDomain(arr_localstorage_hold)){ window.localStorage.clear(); } @@ -1633,6 +1635,28 @@ else if (matchDomain("latercera.com")) { removeDOMElement(subscr_banner); } +else if (matchDomain(es_grupo_vocento_domains)) { + let url = window.location.href; + let content_exclusive_bg = document.querySelector('.content-exclusive-bg '); + let amphtml = document.querySelector('link[rel="amphtml"]'); + if (content_exclusive_bg && amphtml) { + window.setTimeout(function () { + window.location.href = url.replace('.html', '_amp.html'); + }, 500); // Delay (in milliseconds) + } else if (url.includes('_amp.html')) { + let voc_advers = document.querySelectorAll('.voc-adver, amp-embed'); + removeDOMElement(...voc_advers); + let container_wall_exclusive = document.querySelector('.container-wall-exclusive'); + if (container_wall_exclusive) { + let non_subscr_section = document.querySelector('[amp-access="result!=\'ALLOW_ACCESS\'"]'); + removeDOMElement(container_wall_exclusive, non_subscr_section); + let subscr_section = document.querySelector('[amp-access="result=\'ALLOW_ACCESS\'"]'); + 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 01fafed..4be7d26 100644 --- a/manifest.json +++ b/manifest.json @@ -26,6 +26,10 @@ ], "permissions": [ "cookies", + "storage", + "tabs", + "webRequest", + "webRequestBlocking", "*://*.abc.es/*", "*://*.ad.nl/*", "*://*.adelaidenow.com.au/*", @@ -82,6 +86,8 @@ "*://*.destentor.nl/*", "*://*.deutsche-wirtschafts-nachrichten.de/*", "*://*.df.cl/*", + "*://*.diariosur.es/*", + "*://*.diariovasco.com/*", "*://*.digiday.com/*", "*://*.dn.se/*", "*://*.dvhn.nl/*", @@ -89,8 +95,11 @@ "*://*.ed.nl/*", "*://*.editorialedomani.it/*", "*://*.elcomercio.pe/*", + "*://*.elcorreo.com/*", + "*://*.eldiariomontanes.es/*", "*://*.elmercurio.com/*", "*://*.elmundo.es/*", + "*://*.elnortedecastilla.es/*", "*://*.elpais.com/*", "*://*.estadao.com.br/*", "*://*.estrellavalpo.cl/*", @@ -132,6 +141,7 @@ "*://*.hbrtaiwan.com/*", "*://*.heraldsun.com.au/*", "*://*.historyextra.com/*", + "*://*.hoy.es/*", "*://*.hs.fi/*", "*://*.humo.be/*", "*://*.ilfattoquotidiano.it/*", @@ -155,10 +165,12 @@ "*://*.labusinessjournal.com/*", "*://*.ladepeche.fr/*", "*://*.lanacion.com.ar/*", + "*://*.larioja.com/*", "*://*.lasegunda.com/*", "*://*.lastampa.it/*", "*://*.latercera.com/*", "*://*.latimes.com/*", + "*://*.laverdad.es/*", "*://*.lc.nl/*", "*://*.lecho.be/*", "*://*.ledevoir.com/*", @@ -329,11 +341,7 @@ "*://*.pelcro.com/*", "*://*.rcsobjects.it/*", "*://*.repstatic.it/*", - "*://*.userzoom.com/*", - "storage", - "tabs", - "webRequest", - "webRequestBlocking" + "*://*.userzoom.com/*" ], - "version": "1.9.6.1" + "version": "1.9.6.2" } \ No newline at end of file diff --git a/sites.js b/sites.js index 8d932b1..4632cbe 100644 --- a/sites.js +++ b/sites.js @@ -68,6 +68,7 @@ var defaultSites = "Glassdoor": "glassdoor.com", "Globes": "globes.co.il", "Groene Amsterdammer": "groene.nl", + "Grupo Vocento (Spain, regional daily)": "###_es_grupo_vocento", "Haaretz English": "haaretz.com", "Haaretz": "haaretz.co.il", "Handelsblatt": "handelsblatt.com",