From f0b5887de08be7de86a52e463d583b903e7bf87b Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Sat, 10 Oct 2020 12:15:28 +0200 Subject: [PATCH] Fix-update NzHerald Plus fix-update Challenges.fr (timing) --- background.js | 1 - changelog.txt | 3 +++ contentScript.js | 68 +++++++++++++++++++++++++++++++++++++++--------- lp/manifest.json | 2 +- manifest.json | 2 +- 5 files changed, 60 insertions(+), 16 deletions(-) diff --git a/background.js b/background.js index e3500c1..40d4707 100644 --- a/background.js +++ b/background.js @@ -214,7 +214,6 @@ var blockedRegexes = { 'newyorker.com': /.+\.newyorker\.com\/verso\/static\/presenter-articles.+\.js/, 'nknews.org': /.+\.nknews\.org\/wp-content\/plugins\/leaky-paywall-ajax\/js\/leaky-paywall-ajax\.js/, 'nytimes.com': /(.+meter-svc\.nytimes\.com\/meter\.js.+|.+mwcm\.nyt\.com\/.+\.js)/, -'nzherald.co.nz': /nzherald\.co\.nz\/.+\/headjs\/.+\.js/, 'repubblica.it': /scripts\.repubblica\.it\/pw\/pw\.js.+/, 'rollingstone.com': /cdn\.cxense\.com/, 'sacbee.com': /cdn\.ampproject\.org\/v\d\/amp-subscriptions-.+\.js/, diff --git a/changelog.txt b/changelog.txt index 965ec07..d4602cb 100644 --- a/changelog.txt +++ b/changelog.txt @@ -4,7 +4,10 @@ Changelog Bypass Paywalls Clean - Firefox Post-release Remove BusinessTimes.com.sg (obsolete) Fix-update Bloomberg (overlay) +Fix-update Challenges.fr (timing) +Fix-update NzHerald Fix-update Toronto Star (map-snippet/footer) +Fix-update WaPo (paywall-script) * v1.8.9.0 (2020-10-04) Add Hannoversche Allgemeine Zeitung diff --git a/contentScript.js b/contentScript.js index d6c5e00..7de45a5 100644 --- a/contentScript.js +++ b/contentScript.js @@ -200,20 +200,64 @@ else if (matchDomain("the-american-interest.com")) { } else if (matchDomain("nzherald.co.nz")) { - let article_content = document.getElementById('article-content'); + let article_content = document.querySelector('.article__content'); if (article_content) { - let premium = document.querySelector('.premium-sub'); - removeDOMElement(premium); - article_content.classList.remove('premium-content'); - article_content.classList.add('full-content'); - removeClassesByPrefix(article_content, 'QUnW'); - let elems = article_content.querySelectorAll("p, span, h2, div"); - for (let elem of elems){ - removeClassesByPrefix(elem, 'QUnW'); - elem.classList.remove("ellipsis"); - elem.removeAttribute('style'); + let article_offer = document.querySelector('.article-offer'); + if (article_offer) { + let scripts = document.querySelectorAll('script'); + let json_script; + for (let script of scripts) { + if (script.innerText.includes('Fusion.globalContent')) + json_script = script; + continue; + } + let first_pars = article_content.querySelectorAll('p[class=""], div[class="article__raw-html__top"]'); + removeDOMElement(...first_pars); + if (json_script) { + let json_text = json_script.innerHTML.split('Fusion.globalContent=')[1].split(';Fusion.globalContentConfig')[0]; + let json_pars = JSON.parse(json_text).elements; + let par_dom; + let article_action_bar = document.querySelector('.article__action-bar:not([data-ref-group="author"])'); + for (let par of json_pars) { + par_dom = document.createElement('div'); + par_dom.setAttribute('style', 'margin: 10px; font-size: 1.1rem'); + if (par.type === 'text') { + par_dom.innerHTML = par.content; + } else if (par.type === 'raw_html') { + if (par.subtype) + par_dom.innerHTML = par.content; + else { + let raw_html = document.querySelector('div.article__raw-html'); + if (raw_html) { + raw_html.setAttribute('class', 'article__raw-html'); + raw_html.removeAttribute('style'); + } + par_dom = raw_html; + } + } else if (par.type === 'header') { + par_dom.innerHTML = '

' + par.content + '

'; + } else if (par.type === 'image') { + par_dom.innerHTML = '' + par.caption; + } else if (par.type === 'video') { + let video = document.querySelector('figure > div.video-outer'); + if (video) { + video.parentElement.setAttribute('class', 'figure'); + video.parentElement.removeAttribute('style'); + } + par_dom = video.parentElement; + } else + console.log(par); + if (article_action_bar) + article_action_bar.parentNode.insertBefore(par_dom, article_action_bar); + else + article_content.appendChild(par_dom); + } + } + removeDOMElement(article_offer); } } + let premium_toaster = document.querySelector('#premium-toaster'); + removeDOMElement(premium_toaster); } else if (matchDomain(["parool.nl", "trouw.nl", "volkskrant.nl", "humo.be", "demorgen.be"])) { @@ -634,7 +678,6 @@ else if (matchDomain('ladepeche.fr')) { } else if (matchDomain('challenges.fr')) { - document.addEventListener('DOMContentLoaded', () => { const amorce = document.querySelector('.user-paying-amorce'); if (amorce) amorce.setAttribute('style', 'display:none !important'); @@ -643,7 +686,6 @@ else if (matchDomain('challenges.fr')) { content.setAttribute('style', 'display: block !important'); const paywall = document.querySelector('.temp-paywall'); removeDOMElement(paywall); - }); } else if (matchDomain('barrons.com')) { diff --git a/lp/manifest.json b/lp/manifest.json index 96d9622..5e8ddb2 100644 --- a/lp/manifest.json +++ b/lp/manifest.json @@ -317,5 +317,5 @@ "webRequest", "webRequestBlocking" ], - "version": "1.8.9.3" + "version": "1.8.9.4" } \ No newline at end of file diff --git a/manifest.json b/manifest.json index 16c7a24..93dc9d4 100644 --- a/manifest.json +++ b/manifest.json @@ -40,5 +40,5 @@ "webRequest", "webRequestBlocking" ], - "version": "1.8.9.3" + "version": "1.8.9.4" } \ No newline at end of file