Fix Telegraaf.nl

This commit is contained in:
magnolia1234 2020-03-29 13:38:26 +02:00 committed by GitHub
parent 6f3679dcdf
commit 84aa5aa881

View file

@ -54,12 +54,40 @@ else if (matchDomain("americanbanker.com")) {
}
else if (matchDomain('telegraaf.nl')) {
setTimeout(function () {
const paywall = document.getElementById('TEMPRORARY_METERING_ID');
if (paywall) {
window.location.reload(true);
if (window.location.href.startsWith('https://www.telegraaf.nl/error?ref=/')) {
window.location.href = window.location.href.split('&')[0].replace('error?ref=/', '');
}
let article_wrapper = document.querySelector('.ArticlePageWrapper__uid');
let spotx_banner = document.querySelector('.ArticleBodyBlocks__inlineArticleSpotXBanner');
let paywall = document.querySelector('.PopupBackdrop__block');
removeDOMElement(spotx_banner, paywall);
let premium = document.querySelector('.PremiumLabelWithLine__body');
let article_id = article_wrapper ? article_wrapper.innerText : '123';
let article_body_done = document.querySelector('#articleBody' + article_id);
if (premium && !article_body_done) {
let article_body_old = document.querySelector('[id^=articleBody]');
removeDOMElement(article_body_old);
let json = document.querySelector('script[type="application/ld+json"][data-react-helmet="true"]');
if (json) {
json_text = JSON.parse(json.text).articleBody;
let article_body = document.querySelector('section.TextArticlePage__bodyText');
if (article_body) {
let div_main = document.createElement("div");
div_main.setAttribute('id', 'articleBody' + article_id);
let div_elem = document.createElement("div");
div_elem.setAttribute('data-element', 'articleBodyBlocks');
let text_array = json_text.split('\n\n');
text_array.forEach(p_text => {
let p_div = document.createElement("p");
p_div.setAttribute('class', 'ArticleBodyBlocks__paragraph ArticleBodyBlocks__paragraph--nieuws');
p_div.innerText = p_text;
div_elem.appendChild(p_div);
});
div_main.appendChild(div_elem);
article_body.appendChild(div_main);
}
}
}, 1000); // Delay (in milliseconds)
}
}
else if (matchDomain('ad.nl')) {