From 6759422cd2cb1043786867a51b9a7523b6b6d002 Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Mon, 7 Mar 2022 22:56:06 +0100 Subject: [PATCH] Fix LesEchos.fr (investir) --- changelog.txt | 1 + contentScript.js | 104 +++++++++++++++++++++++++-------------------- manifest.json | 2 +- sites.js | 2 +- sites_updated.json | 9 ++++ 5 files changed, 71 insertions(+), 47 deletions(-) diff --git a/changelog.txt b/changelog.txt index a730493b..e58c9733 100644 --- a/changelog.txt +++ b/changelog.txt @@ -2,6 +2,7 @@ Changelog Bypass Paywalls Clean - Firefox Post-release +Fix LesEchos.fr (investir) Fix NHST Media Group * v2.5.9.0 (2022-03-06) diff --git a/contentScript.js b/contentScript.js index 47cc39b4..32f3a230 100644 --- a/contentScript.js +++ b/contentScript.js @@ -33,7 +33,7 @@ var usa_mng_domains = ['denverpost.com', 'eastbaytimes.com', 'mercurynews.com' var usa_tribune_domains = ['baltimoresun.com', 'chicagotribune.com', 'courant.com', 'dailypress.com', 'mcall.com', 'nydailynews.com', 'orlandosentinel.com', 'pilotonline.com', 'sun-sentinel.com']; // clean local storage of sites (with an exemption for hold-list) -var arr_localstorage_hold = ['abc.es', 'allgaeuer-zeitung.de', 'augsburger-allgemeine.de', 'barrons.com', 'businessoffashion.com', 'challenges.fr', 'charliehebdo.fr', 'cmjornal.pt', 'corriere.it', 'eldiario.es', 'elespanol.com', 'elle.fr', 'elpais.com', 'elperiodico.com', 'estadao.com.br', 'forbes.com', 'fortune.com', 'freiepresse.de', 'ilfoglio.it', 'inc42.com', 'kurier.at', 'lanouvellerepublique.fr', 'nknews.org', 'nytimes.com', 'scmp.com', 'seekingalpha.com', 'telegraph.co.uk', 'thehindu.com', 'thetimes.co.uk', 'wsj.com'].concat(de_funke_media_domains, es_epiberica_domains, es_grupo_vocento_domains, es_unidad_domains, fr_groupe_ebra_domains, fr_groupe_la_depeche_domains, fr_groupe_nice_matin_domains, it_quotidiano_domains, no_nhst_media_domains, usa_hearst_comm_domains); +var arr_localstorage_hold = ['abc.es', 'allgaeuer-zeitung.de', 'augsburger-allgemeine.de', 'barrons.com', 'businessoffashion.com', 'challenges.fr', 'charliehebdo.fr', 'cmjornal.pt', 'corriere.it', 'eldiario.es', 'elespanol.com', 'elle.fr', 'elpais.com', 'elperiodico.com', 'estadao.com.br', 'forbes.com', 'fortune.com', 'freiepresse.de', 'ilfoglio.it', 'inc42.com', 'kurier.at', 'lanouvellerepublique.fr', 'lesechos.fr', 'nknews.org', 'nytimes.com', 'scmp.com', 'seekingalpha.com', 'telegraph.co.uk', 'thehindu.com', 'thetimes.co.uk', 'wsj.com'].concat(de_funke_media_domains, es_epiberica_domains, es_grupo_vocento_domains, es_unidad_domains, fr_groupe_ebra_domains, fr_groupe_la_depeche_domains, fr_groupe_nice_matin_domains, it_quotidiano_domains, no_nhst_media_domains, usa_hearst_comm_domains); if (!matchDomain(arr_localstorage_hold)) { window.localStorage.clear(); } @@ -1346,54 +1346,68 @@ else if (matchDomain('lequipe.fr')) { } } -else if (matchDomain('lesechos.fr') && window.location.href.match(/-\d{6,}/)) { - window.setTimeout(function () { - let abo_banner = document.querySelector('div[class*="pgxf3b-2"]'); - let ad_blocks = document.querySelectorAll('[class*="jzxvkd"'); - for (let ad_block of ad_blocks) - ad_block.setAttribute('style', 'display:none'); - if (abo_banner && dompurify_loaded) { - removeDOMElement(abo_banner); - let url = window.location.href; - let html = document.documentElement.outerHTML; - let state; - let split1 = html.split('window.__CONFIG__=')[1]; - let split2 = split1.split('')[0].trim(); - if (split2.includes('; window.__DATA__=')) { - state = split2.split('; window.__DATA__=')[1].split('; window.__')[0].trim(); - } else - state = split2.substr(0, split2.length - 1); - try { - let data = JSON.parse(state); - let data_article = data.article ? data.article : data.pageProps; - let article = data_article.data.stripes[0].mainContent[0].data.description; - let url_loaded = data_article.data.path; - if (url_loaded && !url.replace(/%20/g, '').includes(url_loaded)) - ext_api.runtime.sendMessage({request: 'refreshCurrentTab'}); - let paywallNode = document.querySelector('.post-paywall'); - if (paywallNode) { - let contentNode = document.createElement('div'); - let parser = new DOMParser(); - let article_html = parser.parseFromString('
' + DOMPurify.sanitize(article) + '
', 'text/html'); - let article_par = article_html.querySelector('div'); - if (article_par) { - contentNode.appendChild(article_par); - contentNode.className = paywallNode.className; - paywallNode.parentNode.insertBefore(contentNode, paywallNode); - removeDOMElement(paywallNode); - let paywallLastChildNode = document.querySelector('.post-paywall > :last-child'); - if (paywallLastChildNode) { - paywallLastChildNode.setAttribute('style', 'height: auto !important; overflow: hidden !important; max-height: none !important;'); +else if (matchDomain('lesechos.fr') && window.location.href.match(/\d{6,}/)) { + if (matchDomain('investir.lesechos.fr')) { + if (!window.location.href.includes('/amp/')) { + let paywall = document.querySelector('div.bloc-paywall'); + let amphtml = document.querySelector('link[rel="amphtml"]'); + if (paywall && amphtml) { + removeDOMElement(paywall); + window.location.href = amphtml.href; + } + } else { + let amp_ads = document.querySelectorAll('amp-ad'); + removeDOMElement(...amp_ads); + } + } else { + window.setTimeout(function () { + let abo_banner = document.querySelector('div[class*="pgxf3b-2"]'); + let ad_blocks = document.querySelectorAll('[class*="jzxvkd"'); + for (let ad_block of ad_blocks) + ad_block.setAttribute('style', 'display:none'); + if (abo_banner && dompurify_loaded) { + removeDOMElement(abo_banner); + let url = window.location.href; + let html = document.documentElement.outerHTML; + let state; + let split1 = html.split('window.__CONFIG__=')[1]; + let split2 = split1.split('')[0].trim(); + if (split2.includes('; window.__DATA__=')) { + state = split2.split('; window.__DATA__=')[1].split('; window.__')[0].trim(); + } else + state = split2.substr(0, split2.length - 1); + try { + let data = JSON.parse(state); + let data_article = data.article ? data.article : data.pageProps; + let article = data_article.data.stripes[0].mainContent[0].data.description; + let url_loaded = data_article.data.path; + if (url_loaded && !url.replace(/%20/g, '').includes(url_loaded)) + ext_api.runtime.sendMessage({request: 'refreshCurrentTab'}); + let paywallNode = document.querySelector('.post-paywall'); + if (paywallNode) { + let contentNode = document.createElement('div'); + let parser = new DOMParser(); + let article_html = parser.parseFromString('
' + DOMPurify.sanitize(article) + '
', 'text/html'); + let article_par = article_html.querySelector('div'); + if (article_par) { + contentNode.appendChild(article_par); + contentNode.className = paywallNode.className; + paywallNode.parentNode.insertBefore(contentNode, paywallNode); + removeDOMElement(paywallNode); + let paywallLastChildNode = document.querySelector('.post-paywall > :last-child'); + if (paywallLastChildNode) { + paywallLastChildNode.setAttribute('style', 'height: auto !important; overflow: hidden !important; max-height: none !important;'); + } } } + let styleElem = document.head.appendChild(document.createElement('style')); + styleElem.innerHTML = ".post-paywall::after {height: auto !important;}"; + } catch (err) { + ext_api.runtime.sendMessage({request: 'refreshCurrentTab'}); } - let styleElem = document.head.appendChild(document.createElement('style')); - styleElem.innerHTML = ".post-paywall::after {height: auto !important;}"; - } catch (err) { - ext_api.runtime.sendMessage({request: 'refreshCurrentTab'}); } - } - }, 500); // Delay (in milliseconds) + }, 500); // Delay (in milliseconds) + } } else if (matchDomain('lesinrocks.com')) { diff --git a/manifest.json b/manifest.json index afac1671..25a3674a 100644 --- a/manifest.json +++ b/manifest.json @@ -631,5 +631,5 @@ "*://*.wallkit.net/*", "*://*.wsj.net/*" ], - "version": "2.5.9.1" + "version": "2.5.9.2" } diff --git a/sites.js b/sites.js index 69cc5f25..97eabd2d 100644 --- a/sites.js +++ b/sites.js @@ -955,7 +955,7 @@ var defaultSites = { "Les Échos": { domain: "lesechos.fr", allow_cookies: 1, - block_regex: /\.tinypass\.com\// + block_regex: /(\.tinypass\.com\/|cdn\.ampproject\.org\/v\d\/amp-(access|ad|analytics)-.+\.js)/ }, "Les Inrockuptibles": { domain: "lesinrocks.com", diff --git a/sites_updated.json b/sites_updated.json index 6efceee5..ca469519 100644 --- a/sites_updated.json +++ b/sites_updated.json @@ -33,6 +33,15 @@ "allow_cookies": 1, "block_regex": "(\\.piano\\.io\\/|cdn\\.cxense\\.com\\/|cdn\\.ampproject\\.org\\/v\\d\\/amp-(access|analytics)-.+\\.js)" }, + "Les Échos": { + "domain": "lesechos.fr", + "allow_cookies": 1, + "block_regex": "(\\.tinypass\\.com\\/|cdn\\.ampproject\\.org\\/v\\d\\/amp-(access|ad|analytics)-.+\\.js)", + "amp_redirect": { + "paywall": ".bloc-paywall" + }, + "amp_unhide": 1 + }, "RugbyPass": { "domain": "rugbypass.com", "allow_cookies": 1,