From 38090e0879e5268afe9489237b367cd232fcffb2 Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Sun, 2 Aug 2020 12:35:09 +0200 Subject: [PATCH] Add NoordhollandsDagblad.nl --- README.md | 1 + background.js | 1 + contentScript.js | 55 ++++++++++++++++++++++++++++++++++++++++++++++++ lp/manifest.json | 1 + sites.js | 1 + 5 files changed, 59 insertions(+) diff --git a/README.md b/README.md index ee3771e..bd0931a 100644 --- a/README.md +++ b/README.md @@ -219,6 +219,7 @@ Install add-on by downloading xpi-file. [Humo.be](https://www.humo.be) - [Knack.be](https://www.knack.be) - [Leeuwarder Courant](https://www.lc.nl) - +[Noordhollands Dagblad](https://www.noordhollandsdagblad.nl) - [NRC Handelsblad](https://www.nrc.nl) - [Parool](https://www.parool.nl) - [Telegraaf](https://www.telegraaf.nl) - diff --git a/background.js b/background.js index d91eec1..0bc3c10 100644 --- a/background.js +++ b/background.js @@ -50,6 +50,7 @@ var allow_cookies = [ 'nationalgeographic.com', 'nationalreview.com', 'newrepublic.com', +'noordhollandsdagblad.nl', 'nytimes.com', 'nzz.ch', 'parool.nl', diff --git a/contentScript.js b/contentScript.js index 0547dbb..0877a55 100644 --- a/contentScript.js +++ b/contentScript.js @@ -898,6 +898,61 @@ else if (matchDomain("fd.nl")) { }); } +else if (matchDomain("noordhollandsdagblad.nl")) { + window.setTimeout(function () { + let close_button = document.querySelector('button[data-testid="button-close"]'); + if (close_button) + close_button.click(); + let premium = document.querySelector('div.common-components-plus_pluslabel--container'); + if (premium) { + let hidden_article = document.querySelector('div[data-auth-body="article"]'); + if (hidden_article) + hidden_article.removeAttribute('style'); + let paywall = document.querySelector('div[data-auth-root="paywall"]'); + removeDOMElement(paywall); + let auth_body = document.querySelector('div[data-auth-body="article"]'); + if (auth_body) { + let auth_body_par_count = auth_body.querySelectorAll('p'); + if (auth_body_par_count.length == 1) { + let url = window.location.href; + let html = document.documentElement.outerHTML; + let split1 = html.split('window["__PRELOADED_STATE_GRAPH__')[1]; + let split2 = split1.split('')[0].trim(); + let split3 = split2.split('"body":')[1]; + let state = split3.split('},"')[0] + '}'; + try { + let data = JSON.parse(state); + let article = data.json; + auth_body.innerHTML = ''; + var par_styled = ''; + for (let par of article) { + for (let key in par) { + par_styled = par[key]; + if (key === 'subhead') + par_styled = '' + par_styled + ''; + else if (key === 'twitter') + par_styled = '' + par_styled + ''; + else if (key === 'youtube') + par_styled = ''; + else if (key === 'image') { + par_styled = ''; + par_styled += par[key].caption ? '
' + par_styled + '
'; + } + } + } catch (err) { + console.warn('unable to parse noordhollands dagblad text'); + console.warn(err); + } + } + } + } + }, 500); // Delay (in milliseconds) +} + // General Functions function removeDOMElement(...elements) { for (let element of elements) { diff --git a/lp/manifest.json b/lp/manifest.json index 94498dc..9fd48ad 100644 --- a/lp/manifest.json +++ b/lp/manifest.json @@ -168,6 +168,7 @@ "*://*.newstatesman.com/*", "*://*.newsweek.com/*", "*://*.newyorker.com/*", + "*://*.noordhollandsdagblad.nl/*", "*://*.northerndailyleader.com.au/*", "*://*.nrc.nl/*", "*://*.ntnews.com.au/*", diff --git a/sites.js b/sites.js index 0e78c74..73e68f8 100644 --- a/sites.js +++ b/sites.js @@ -109,6 +109,7 @@ var defaultSites = "New Zealand Herald": "nzherald.co.nz", "Newsweek": "newsweek.com", "Nikkei Asian Review": "asia.nikkei.com", + "Noordhollands Dagblad": "noordhollandsdagblad.nl", "NRC Handelsblad": "nrc.nl", "O Estado de S. Paulo": "estadao.com.br", "O Globo": "globo.com",