From 3834b8c9e0bcc5f3208c0506b9be433a9967ed40 Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Tue, 6 Oct 2020 18:57:13 +0200 Subject: [PATCH] Fix-update Toronto Star (map-snippet) --- changelog.txt | 1 + contentScript.js | 39 +++++++++++++++++++++++++++++++++++---- lp/manifest.json | 2 +- manifest.json | 2 +- 4 files changed, 38 insertions(+), 6 deletions(-) diff --git a/changelog.txt b/changelog.txt index 57984dca..df0a23d3 100644 --- a/changelog.txt +++ b/changelog.txt @@ -3,6 +3,7 @@ Changelog Bypass Paywalls Clean - Firefox Post-release Fix-update Bloomberg (overlay) +Fix-update Toronto Star (map-snippet) * v1.8.9.0 (2020-10-04) Add Hannoversche Allgemeine Zeitung diff --git a/contentScript.js b/contentScript.js index e1d94336..b6409fe8 100644 --- a/contentScript.js +++ b/contentScript.js @@ -425,10 +425,40 @@ else if (matchDomain("techinasia.com")) { else if (matchDomain("thestar.com")) { let paywall = document.querySelector('.basic-paywall-new'); - removeDOMElement(paywall); - let tbcs = document.querySelectorAll('.text-block-container'); - for (let tbc of tbcs) { - tbc.removeAttribute('style'); + if (paywall) { + removeDOMElement(paywall); + let tbcs = document.querySelectorAll('.text-block-container'); + for (let tbc of tbcs) { + tbc.removeAttribute('style'); + } + if (document.head.innerText.includes('window.__PRELOADED_STATE__')) { + let html = document.head.outerHTML; + let split1 = html.split('window.__PRELOADED_STATE__ =')[1]; + let state = split1.split('//-->')[0].trim(); + let json = JSON.parse(state); + if (json) { + let body = json.body; + let par_append_text, par_append; + for (let elem of body) { + if (elem.isParagraph) { + par_append_text = parseHtmlEntities(elem.text); + } else if (elem.snippet) { + let parser = new DOMParser(); + let article_html = parser.parseFromString('
' + elem.snippet + '
', 'text/html'); + let article_snippet = article_html.querySelector('div#bpc'); + let pars = document.querySelectorAll('div.c-article-body__content > p'); + for (let par of pars) { + if (par.innerText.includes(par_append_text)) { + par_append = par; + continue; + } + } + if (article_snippet && par_append) + par_append.appendChild(article_snippet); + } + } + } + } } } @@ -649,6 +679,7 @@ else if (matchDomain('faz.net')) { str = str.replace(/If\n\nSG/g, "IfSG"); str = str.replace(/m\n\nRNA/g, "mNRA"); str = str.replace(/St\n\nVO/g, "StVO"); + str = str.replace(/Berl\n\nHG/g, "BerlHG"); str = str.replace(/De\n\n([A-Z])/g, "De$1"); str = str.replace(/La\n\n([A-Z])/g, "La$1"); str = str.replace(/Le\n\n([A-Z])/g, "Le$1"); diff --git a/lp/manifest.json b/lp/manifest.json index f16f1c65..06d9f394 100644 --- a/lp/manifest.json +++ b/lp/manifest.json @@ -318,5 +318,5 @@ "webRequest", "webRequestBlocking" ], - "version": "1.8.9.1" + "version": "1.8.9.2" } \ No newline at end of file diff --git a/manifest.json b/manifest.json index ec8fa9f9..bc347b10 100644 --- a/manifest.json +++ b/manifest.json @@ -40,5 +40,5 @@ "webRequest", "webRequestBlocking" ], - "version": "1.8.9.1" + "version": "1.8.9.2" } \ No newline at end of file