From 68e75972267a118f54ef692cc42fdf4f9d1282f0 Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Sun, 29 May 2022 15:52:54 +0200 Subject: [PATCH] Fix El Mercurio (+ regional/opt-in to custom sites) --- README.md | 4 +--- background.js | 14 ++++++++++++-- changelog.txt | 1 + contentScript.js | 2 +- manifest.json | 3 +-- sites.js | 10 +--------- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index c14fd8f..f8340b5 100644 --- a/README.md +++ b/README.md @@ -740,9 +740,7 @@ Grouped in options:\ [Valor Econômico](https://valor.globo.com)* ##### Chile [Diario Financiero](https://www.df.cl) - -[El Mercurio](https://digital.elmercurio.com) - -[El Mercurio de Valparaíso](https://www.mercuriovalpo.cl) - -[La Estrella de Valparaíso](https://www.estrellavalpo.cl) - +[El Mercurio (+ regional/opt-in to custom sites)](https://digital.elmercurio.com) - [La Segunda](https://digital.lasegunda.com) - [La Tercera](https://www.latercera.com) ##### Colombia diff --git a/background.js b/background.js index 0c90b49..9e461d0 100644 --- a/background.js +++ b/background.js @@ -750,8 +750,11 @@ ext_api.webRequest.onBeforeSendHeaders.addListener(function(details) { let custom_domain = urlHost(header_referer).replace(/^(www|m|account|amp|edition|eu)\./, ''); if (custom_allow_cookies && !allow_cookies.includes(custom_domain)) allow_cookies.push(custom_domain); - if (custom_block_regex) + if (custom_block_regex) { + if ((typeof custom_block_regex === 'string') && custom_block_regex.includes('{domain}')) + custom_block_regex = new RegExp(custom_block_regex.replace('{domain}', custom_domain.replace(/\./g, '\\.'))); blockedRegexes[custom_domain] = custom_block_regex; + } if (custom_useragent) { if (custom_useragent === 'googlebot') { if (!use_google_bot.includes(custom_domain)) @@ -803,6 +806,13 @@ ext_api.webRequest.onBeforeSendHeaders.addListener(function(details) { var ch_media_domain = (matchUrlDomain('static-chmedia.ch', details.url) && ['script'].includes(details.type) && !matchUrlDomain(ch_media_domains, header_referer) && enabledSites.includes('nzz.ch')); if (ch_media_domain) ch_media_domains = customAddRules(ch_media_domains, true, blockedRegexes['nzz.ch'], 'googlebot'); + } else if (header_referer_hostname.endsWith('.cl')) { + // block scripts for regional El Mercurio sites (opt-in to custom sites) + var cl_emol_region_domains = []; + var cl_emol_region_domain = (matchUrlDomain('impresa.soy-chile.cl', details.url) && ['xmlhttprequest'].includes(details.type) && !matchUrlDomain(cl_emol_region_domains, header_referer) && enabledSites.includes('elmercurio.com')); + if (cl_emol_region_domain) { + cl_emol_region_domains = customAddRules(cl_emol_region_domains, false, "(\\.{domain}\\/impresa\\/.+\\/assets\\/(vendor|\\d)\\.js|pram\\.pasedigital\\.cl\\/API\\/User\\/Status\\?)"); + } } else if (header_referer_hostname.endsWith('.de')) { // set googlebot-useragent for additional Funke sites (opt-in to custom sites) var de_funke_medien_domains = grouped_sites['###_de_funke_medien']; @@ -1093,7 +1103,7 @@ if (matchUrlDomain(change_headers, details.url) && !['font', 'image', 'styleshee } } }); - } else { //mercuriovalpo.cl, estrellavalpo.cl, lequipe.fr + } else { //El Mercurio Regionales, lequipe.fr ext_api.tabs.query({ active: true, currentWindow: true diff --git a/changelog.txt b/changelog.txt index 649a99d..b418fbc 100644 --- a/changelog.txt +++ b/changelog.txt @@ -8,6 +8,7 @@ Add Het Belang van Limburg Add Het Nieuwsblad Add SlideShare Remove Scribd (fix obsolete) +Fix El Mercurio (+ regional/opt-in to custom sites) Fix Telegraaf.nl * v2.7.0.0 (2022-05-22) diff --git a/contentScript.js b/contentScript.js index ef370b4..f919442 100644 --- a/contentScript.js +++ b/contentScript.js @@ -2352,7 +2352,7 @@ else if (matchDomain('lasegunda.com')) { } } -else if (matchDomain(["mercuriovalpo.cl", "estrellavalpo.cl"])) { +else if (window.location.hostname.endsWith('.cl') && document.querySelector('meta[property="og:image"][content*="://impresa.soy-chile.cl/"]')) { let content = document.querySelector('div.content'); if (content) content.setAttribute('id', 'content_new'); diff --git a/manifest.json b/manifest.json index ea6043c..484c4ca 100644 --- a/manifest.json +++ b/manifest.json @@ -207,7 +207,6 @@ "*://*.esprit.presse.fr/*", "*://*.esquire.com/*", "*://*.estadao.com.br/*", - "*://*.estrellavalpo.cl/*", "*://*.estrepublicain.fr/*", "*://*.euobserver.com/*", "*://*.eurekareport.com.au/*", @@ -389,7 +388,6 @@ "*://*.medium.com/*", "*://*.mediuutiset.fi/*", "*://*.menshealth.com/*", - "*://*.mercuriovalpo.cl/*", "*://*.mercurynews.com/*", "*://*.mexiconewsdaily.com/*", "*://*.miamiherald.com/*", @@ -677,6 +675,7 @@ "*://*.prcdn.co/*", "*://*.repstatic.it/*", "*://*.sanoma-sndp.fi/*", + "*://*.soy-chile.cl/*", "*://*.static-chmedia.ch/*", "*://*.wallkit.net/*", "*://*.wsj.net/*", diff --git a/sites.js b/sites.js index 7d39c32..b4ceb3b 100644 --- a/sites.js +++ b/sites.js @@ -384,16 +384,12 @@ var defaultSites = { allow_cookies: 1, block_regex: /(\.tinypass\.com\/|cdn\.cxense\.com\/|cdn\.ampproject\.org\/v\d\/amp-subscriptions-.+\.js)/ }, - "El Mercurio": { + "El Mercurio (+ regional/opt-in to custom sites)": { domain: "elmercurio.com", allow_cookies: 1, block_regex: /\.(elmercurio\.com|emol\.cl)\/(.+\/)?js\/(.+\/)?(modal|merPramV\d|PramModal\.min)\.js/, useragent: "googlebot" }, - "El Mercurio de Valparaíso": { - domain: "mercuriovalpo.cl", - block_regex: /(.+\.mercuriovalpo\.cl\/impresa\/.+\/assets\/(vendor|\d)\.js|pram\.pasedigital\.cl\/API\/User\/Status\?)/ - }, "El Mundo": { domain: "elmundo.es", group_rule: "###_gr_es_unidad_domains" @@ -916,10 +912,6 @@ var defaultSites = { allow_cookies: 1, block_regex: /(\.la-croix\.com\/build\/lacroix\/article.+\.js|cdn\.ampproject\.org\/v\d\/amp-access-.+\.js)/ }, - "La Estrella de Valparaíso": { - domain: "estrellavalpo.cl", - block_regex: /(\.mercuriovalpo\.cl\/impresa\/.+\/assets\/(vendor|\d)\.js|pram\.pasedigital\.cl\/API\/User\/Status\?)/ - }, "La Libre.be": { domain: "lalibre.be", allow_cookies: 1,