From 49ad372f2aca1b9922d97ddaed07a3a89f9ea9e3 Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Sat, 20 Aug 2022 07:59:08 +0200 Subject: [PATCH] Remove Sanoma Media Finland (fix obsolete) --- README.md | 5 +-- background.js | 7 +--- changelog.txt | 1 + contentScript.js | 105 ----------------------------------------------- manifest.json | 3 -- sites.js | 14 +------ 6 files changed, 5 insertions(+), 130 deletions(-) diff --git a/README.md b/README.md index 6d5c228..d8b7867 100755 --- a/README.md +++ b/README.md @@ -397,12 +397,9 @@ Grouped in options:\ [Berlingske](https://www.berlingske.dk) ##### Finland -Grouped in options:\ -*Sanoma Media Finland* sites like (opt-in to custom sites for unlisted/regional sites)\ -[Aamulehti](https://www.aamulehti.fi) - -[Helsingin Sanomat](https://www.hs.fi) - [Suomen Sotilas](https://suomensotilas.fi) +Grouped in options:\ *Alma Talent* sites like\ [Arvopaperi](https://www.arvopaperi.fi) - [Iltalehti](https://www.iltalehti.fi) - diff --git a/background.js b/background.js index e896834..a48ff2a 100755 --- a/background.js +++ b/background.js @@ -6,7 +6,7 @@ var ext_name = manifestData.name; var ext_version = manifestData.version; const cs_limit_except = ['elespanol.com', 'faz.net', 'nation.africa', 'nationalgeographic.com'].concat(de_westfalen_medien_domains); -const dompurify_sites = ['asiatimes.com', 'bloomberg.com', 'cicero.de', 'hs.fi', 'ilmanifesto.it', 'iltalehti.fi', 'iltirreno.it', 'ipolitics.ca', 'italiaoggi.it', 'lanuovasardegna.it', 'lesechos.fr', 'marianne.net', 'newleftreview.org', 'nzherald.co.nz', 'outlookbusiness.com', 'prospectmagazine.co.uk', 'stratfor.com', 'techinasia.com', 'timesofindia.com', 'valor.globo.com', 'vn.nl'].concat(be_mediahuis_domains, nl_mediahuis_region_domains, no_nhst_media_domains); +const dompurify_sites = ['asiatimes.com', 'bloomberg.com', 'cicero.de', 'ilmanifesto.it', 'iltalehti.fi', 'iltirreno.it', 'ipolitics.ca', 'italiaoggi.it', 'lanuovasardegna.it', 'lesechos.fr', 'marianne.net', 'newleftreview.org', 'nzherald.co.nz', 'outlookbusiness.com', 'prospectmagazine.co.uk', 'stratfor.com', 'techinasia.com', 'timesofindia.com', 'valor.globo.com', 'vn.nl'].concat(be_mediahuis_domains, nl_mediahuis_region_domains, no_nhst_media_domains); var currentTabUrl = ''; var csDone = false; var optin_setcookie = false; @@ -861,11 +861,6 @@ ext_api.webRequest.onBeforeSendHeaders.addListener(function(details) { var es_epiberica_domain = (matchUrlDomain(es_epiberica_custom_domains, details.url) && !matchUrlDomain(es_epiberica_domains, header_referer) && enabledSites.includes('###_es_epiberica')); if (es_epiberica_domain) es_epiberica_domains = customAddRules(es_epiberica_domains, {allow_cookies: 1}, blockedRegexes['epe.es']); - } else if (header_referer_hostname.endsWith('.fi')) { - // set user-agent to GoogleBot for additional Snamoma Media Finland (opt-in to custom sites) - var fi_sanoma_sndp_domain = (matchUrlDomain('sanoma-sndp.fi', details.url) && ['xmlhttprequest'].includes(details.type) && !matchUrlDomain(fi_sanoma_domains, header_referer) && enabledSites.includes('###_fi_sanoma')); - if (fi_sanoma_sndp_domain) - fi_sanoma_domains = customAddRules(fi_sanoma_domains, {allow_cookies: 1}, '', 'googlebot'); } else if (header_referer_hostname.endsWith('.nl')) { // block Evolok for Mediahuis Noord sites (opt-in to custom sites) var nl_mediahuis_noord_domain = (matchUrlDomain('ndcmediagroep.nl', details.url) && ['script'].includes(details.type) && !matchUrlDomain(nl_mediahuis_noord_domains, header_referer) && enabledSites.includes('###_nl_mediahuis_noord')); diff --git a/changelog.txt b/changelog.txt index fcf293e..da4957c 100644 --- a/changelog.txt +++ b/changelog.txt @@ -5,6 +5,7 @@ Post-release Add Nw.de Add Substack custom domains (opt-in to custom sites) Add UOL.com.br +Remove Sanoma Media Finland (fix obsolete) Fix Business Standard (mobile) Fix El Correo & La Voz de Cadiz Fix LaVie.fr diff --git a/contentScript.js b/contentScript.js index 567ece9..576a605 100755 --- a/contentScript.js +++ b/contentScript.js @@ -901,111 +901,6 @@ if (matchDomain(fi_alma_talent_domains)) { } } -else if (matchDomain('hs.fi')) { - let url = window.location.href; - if (!url.includes('https://dynamic.hs.fi')) { - let iframe = document.querySelector('iframe[src^="https://dynamic.hs.fi/a/"]'); - if (iframe && url.includes('.html')) { - window.setTimeout(function () { - window.location.href = iframe.src; - }, 500); - } - } else { - let paywall = document.querySelector('.paywall-container, .paywall-wrapper'); - if (paywall && dompurify_loaded) { - let scripts = document.querySelectorAll('script'); - let json_script; - for (let script of scripts) { - if (script.innerText.includes('window.__NUXT__=')) { - json_script = script; - break; - } - } - let json_text; - if (json_script.innerHTML.includes('paywallComponents:[')) - json_text = json_script.innerHTML.replace(/\r\n/g, '').split('amlData:[')[1].split('metaData')[0].split('paywallComponents:[')[1].slice(0, -4); - let main = document.querySelector('main'); - if (main && json_text) { - let pars = json_text.split('{type:'); - let type, value, slides, src, elem, img, caption, caption_text, par_html, par_text; - let parser = new DOMParser(); - for (let par of pars) { - elem = ''; - type = par.split(',')[0]; - if (['a', 'i'].includes(type)) { // text - value = par.split('value:')[1].split('}')[0].replace(/(^"|"$)/g, ''); - if (!value.includes('

')) - value = '

' + value + '

'; - par_html = parser.parseFromString(DOMPurify.sanitize(value), 'text/html'); - elem = par_html.querySelector('p'); - } else if (['D', 'f', 'j', 'k'].includes(type)) { // quote - if (par.includes('text:') && par.includes(',position:')) { - value = par.split('text:')[1].split(',position:')[0].replace(/(^"|"$)/g, ''); - elem = document.createElement('p'); - elem.innerText = value; - elem.setAttribute('style', 'font-style: italic;'); - } - } else if (['m', 'u'].includes(type)) { // authors - if (!par.includes('text:')) - continue; - value = par.split('text:')[1].split(',role')[0].replace(/(^"|"$)/g, ''); - if (value.length > 1) { - elem = document.createElement('p'); - elem.innerText = value; - } - } else if (['e', 'h', 'y'].includes(type)) { // image - if (!par.includes('src:')) - continue; - src = par.split('src:"')[1].split('",')[0]; - if (!src.startsWith('http')) - src = 'https://arkku.mediadelivery.fi/img/468/' + src; - elem = document.createElement('p'); - img = document.createElement('img'); - img.setAttribute('src', src); - img.setAttribute('style', 'width:468px !important'); - elem.appendChild(img); - if (par.includes('caption:')) { - caption = document.createElement('figcaption'); - caption_text = par.split('caption:')[1].split('",')[0]; - if (caption_text.length) - caption_text = caption_text.slice(1, caption_text.length - 1); - caption.innerText = caption_text; - elem.appendChild(caption); - } - } else if (['p', 'r'].includes(type)) { // slides - slides = par.split('src:'); - elem = document.createElement('p'); - for (let slide of slides) { - if (slide.includes('.jpg')) { - src = slide.split(',')[0].replace(/"/g, ''); - if (!src.startsWith('http')) - src = 'https://arkku.mediadelivery.fi/img/468/' + src; - img = document.createElement('img'); - img.setAttribute('src', src); - img.setAttribute('style', 'width:468px !important'); - elem.appendChild(img); - caption = document.createElement('figcaption'); - caption_text = slide.includes('text:') ? slide.split('text:')[1].split(',"text-style"')[0] : slide.split('caption:')[1].split('",')[0]; - if (caption_text.length) - caption_text = caption_text.slice(1, caption_text.length - 1); - par_html = parser.parseFromString('
' + DOMPurify.sanitize(caption_text) + '
', 'text/html'); - elem.appendChild(par_html.querySelector('div')); - } - } - } else - false;//console.log('type: ' + type + ' par: ' + par); - if (elem) { - elem.setAttribute('class', 'article-body px-16 mb-24'); - main.appendChild(elem); - } - } - main.appendChild(document.createElement('br')); - } - removeDOMElement(paywall); - } - } -} - else if (matchDomain('nyteknik.se')) { // plus code in contentScript_once.js let locked_article = document.querySelector('div.locked-article'); diff --git a/manifest.json b/manifest.json index 008fe22..e221eb2 100755 --- a/manifest.json +++ b/manifest.json @@ -45,7 +45,6 @@ "webRequest", "webRequestBlocking", "*://*.360dx.com/*", - "*://*.aamulehti.fi/*", "*://*.abc.es/*", "*://*.abendblatt.de/*", "*://*.abril.com.br/*", @@ -256,7 +255,6 @@ "*://*.housebeautiful.com/*", "*://*.houstonchronicle.com/*", "*://*.hoy.es/*", - "*://*.hs.fi/*", "*://*.huffingtonpost.it/*", "*://*.humo.be/*", "*://*.ideal.es/*", @@ -678,7 +676,6 @@ "*://*.postmedia.digital/*", "*://*.prcdn.co/*", "*://*.repstatic.it/*", - "*://*.sanoma-sndp.fi/*", "*://*.soy-chile.cl/*", "*://*.static-chmedia.ch/*", "*://*.wallkit.net/*", diff --git a/sites.js b/sites.js index 69c8aa9..68d1309 100755 --- a/sites.js +++ b/sites.js @@ -1468,15 +1468,6 @@ var defaultSites = { domain: "sandiegouniontribune.com", block_regex: /(metering\.platform\.sandiegouniontribune\.com\/v\d\/meter|cdn\.ampproject\.org\/v\d\/amp-(access|subscriptions)-.+\.js)/ }, - "Sanoma Media Finland (+ regional/opt-in to custom sites)": { - domain: "###_fi_sanoma", - group: [ - "aamulehti.fi", - "hs.fi" - ], - allow_cookies: 1, - useragent: "googlebot", - }, "Schleswig-Holsteinischer Zeitungsverlag": { domain: "shz.de", allow_cookies: 1, @@ -2141,7 +2132,7 @@ var nl_mediahuis_region_domains = grouped_sites['###_nl_mediahuis_region']; var no_nhst_media_domains = grouped_sites['###_no_nhst_media']; // (fixed) custom domains (background) -var au_comm_media_domains, au_thewest_domains, ca_gcm_domains, ca_postmedia_domains, ch_media_domains, cl_emol_region_domains, de_funke_medien_domains, de_madsack_domains, es_epiberica_domains, fi_sanoma_domains, medium_custom_domains, nl_mediahuis_noord_domains, substack_custom_domains, usa_gannett_domains, usa_hearst_comm_domains, usa_lee_ent_domains, usa_mcc_domains, usa_mng_domains, usa_townnews_domains; +var au_comm_media_domains, au_thewest_domains, ca_gcm_domains, ca_postmedia_domains, ch_media_domains, cl_emol_region_domains, de_funke_medien_domains, de_madsack_domains, es_epiberica_domains, medium_custom_domains, nl_mediahuis_noord_domains, substack_custom_domains, usa_gannett_domains, usa_hearst_comm_domains, usa_lee_ent_domains, usa_mcc_domains, usa_mng_domains, usa_townnews_domains; var de_madsack_custom_domains = ['aller-zeitung.de', 'dnn.de', 'gnz.de', 'goettinger-tageblatt.de', 'paz-online.de', 'sn-online.de', 'waz-online.de']; var es_epiberica_custom_domains = ['diaridegirona.cat', 'diariocordoba.com', 'diariodeibiza.es', 'elperiodicodearagon.com', 'elperiodicoextremadura.com', 'elperiodicomediterraneo.com', 'emporda.info', 'laopinioncoruna.es', 'laopiniondemalaga.es', 'laopiniondemurcia.es', 'laopiniondezamora.es', 'regio7.cat']; @@ -2155,7 +2146,6 @@ function init_custom_domains() { de_funke_medien_domains = grouped_sites['###_de_funke_medien']; de_madsack_domains = grouped_sites['###_de_madsack']; es_epiberica_domains = grouped_sites['###_es_epiberica']; - fi_sanoma_domains = grouped_sites['###_fi_sanoma']; medium_custom_domains = grouped_sites['###_medium_custom']; nl_mediahuis_noord_domains = []; substack_custom_domains = []; @@ -2170,4 +2160,4 @@ init_custom_domains(); // sites with no fix (background) var nl_dpg_media_nofix_domains = ['ad.nl', 'bd.nl', 'bndestem.nl', 'destentor.nl', 'ed.nl', 'gelderlander.nl', 'hln.be', 'pzc.nl', 'tubantia.nl']; -var nofix_sites = ['africaintelligence.com', 'africaintelligence.fr', 'aftenposten.no', 'bild.de', 'borsen.dk', 'businesstimes.com.sg', 'caixin.com', 'caixinglobal.com', 'caravanmagazine.in', 'cnbc.com', 'courrierinternational.com', 'dn.se', 'elordenmundial.com', 'epw.in', 'expresso.pt', 'ftchinese.com', 'handelsblatt.com', 'hln.be', 'ilsole24ore.com', 'jacobinmag.com', 'jeunesafrique.com', 'kurier.at', 'lavozdegalicia.es', 'leconomiste.com', 'lefigaro.fr', 'lemonde.fr', 'lepoint.fr', 'liberation.fr', 'mediapart.fr', 'milanofinanza.it', 'mondediplo.com', 'moneycontrol.com', 'nieuwsblad.be', 'nknews.org', 'ouest-france.fr', 'politiken.dk', 'publico.pt', 'republic.ru', 'rp-online.de', 'standaard.be', 'statnews.com', 'stern.de', 'straitstimes.com', 'sueddeutsche.de', 'tagesanzeiger.ch', 'tagesspiegel.de', 'the-ken.com', 'theinformation.com', ' themorningcontext.com', 'theparisreview.org', 'thewirechina.com', 'welt.de', 'worldpoliticsreview.com', 'ynet.co.il'].concat(nl_dpg_media_nofix_domains); +var nofix_sites = ['africaintelligence.com', 'africaintelligence.fr', 'aftenposten.no', 'bild.de', 'borsen.dk', 'businesstimes.com.sg', 'caixin.com', 'caixinglobal.com', 'caravanmagazine.in', 'cnbc.com', 'courrierinternational.com', 'dn.se', 'elordenmundial.com', 'epw.in', 'expresso.pt', 'ftchinese.com', 'handelsblatt.com', 'hln.be', 'hs.fi', 'ilsole24ore.com', 'jacobinmag.com', 'jeunesafrique.com', 'kurier.at', 'lavozdegalicia.es', 'leconomiste.com', 'lefigaro.fr', 'lemonde.fr', 'lepoint.fr', 'liberation.fr', 'mediapart.fr', 'milanofinanza.it', 'mondediplo.com', 'moneycontrol.com', 'nieuwsblad.be', 'nknews.org', 'ouest-france.fr', 'politiken.dk', 'publico.pt', 'republic.ru', 'rp-online.de', 'standaard.be', 'statnews.com', 'stern.de', 'straitstimes.com', 'sueddeutsche.de', 'tagesanzeiger.ch', 'tagesspiegel.de', 'the-ken.com', 'theinformation.com', ' themorningcontext.com', 'theparisreview.org', 'thewirechina.com', 'welt.de', 'worldpoliticsreview.com', 'ynet.co.il'].concat(nl_dpg_media_nofix_domains);