From d0742f9e25c01026cc2ca2e8e4520be39350f00f Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Sat, 10 Oct 2020 17:56:48 +0200 Subject: [PATCH] Fix-update2 NzHerald (proper) --- contentScript.js | 63 ++++++++++++------------------------------------ 1 file changed, 16 insertions(+), 47 deletions(-) diff --git a/contentScript.js b/contentScript.js index 7de45a5..3c9af1f 100644 --- a/contentScript.js +++ b/contentScript.js @@ -204,55 +204,23 @@ else if (matchDomain("nzherald.co.nz")) { if (article_content) { 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 css_selector = article_content.querySelectorAll('p')[5].getAttribute('class'); + let hidden_not_pars = article_content.querySelectorAll('.' + css_selector + ':not(p)'); + for (let hidden_not_par of hidden_not_pars) { + hidden_not_par.classList.remove(css_selector); + hidden_not_par.removeAttribute('style'); } - 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 = '