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('