From 742fd68b2dcc236924edbd1f1f7031ba50a0262f Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Mon, 25 Jan 2021 20:24:46 +0100 Subject: [PATCH] Fix-update El Pais (premium/images) --- changelog.txt | 1 + contentScript.js | 59 ++++++++++++++++-------------------------------- 2 files changed, 21 insertions(+), 39 deletions(-) diff --git a/changelog.txt b/changelog.txt index eb93cdd..7464b93 100644 --- a/changelog.txt +++ b/changelog.txt @@ -2,6 +2,7 @@ Changelog Bypass Paywalls Clean - Firefox Post-release +Fix-update El Pais (premium/images) * v2.0.5.0 (2021-01-24) Add Ambito (Argentina) diff --git a/contentScript.js b/contentScript.js index 60bafcb..5a28bb0 100644 --- a/contentScript.js +++ b/contentScript.js @@ -128,12 +128,13 @@ else if (window.location.hostname.endsWith(".com.au") || window.location.hostnam window.setTimeout(function () { let breach_screen = document.querySelector('div[data-testid*="BreachScreen"]'); if (breach_screen) { - let scripts = document.querySelectorAll('script'); + let scripts = document.querySelectorAll('script:not([src], [type])'); let json_script; for (let script of scripts) { - if (script.innerText.includes('window.PAGE_DATA =')) + if (script.innerText.includes('window.PAGE_DATA =')) { json_script = script; - continue; + break; + } } if (json_script) { let json_text = json_script.innerHTML.split('window.PAGE_DATA =')[1].split(' span'); if (first_span) first_span.removeAttribute('class'); - removeDOMElement(article_offer); - csDone = true; } } let premium_toaster = document.querySelector('#premium-toaster'); @@ -1416,39 +1417,19 @@ else if (matchDomain(de_madsack_domains)) { else if (matchDomain("elpais.com")) { let url = window.location.href; + let login_register = document.querySelector('.login_register'); if (url.includes('.amp.html') || url.includes('?outputType=amp')) { let paywall = document.querySelectorAll('div[amp-access="success"]'); for (let elem of paywall) elem.removeAttribute('amp-access-hide'); let amp_ads = document.querySelectorAll('amp-ad'); - removeDOMElement(...amp_ads); - } - let login_register = document.querySelector('.login_register'); - if (login_register) { - let scripts = document.querySelectorAll('script'); - let json_script; - for (let script of scripts) { - if (script.innerText.includes('Fusion.globalContent')) - json_script = script; - continue; + removeDOMElement(login_register, ...amp_ads); + } else { + let amphtml = document.querySelector('link[rel="amphtml"]'); + if (login_register && amphtml) { + removeDOMElement(login_register); + window.location.href = amphtml.href; } - if (json_script) { - let json_text = json_script.innerHTML.split('Fusion.globalContent=')[1].split(';Fusion.globalContentConfig')[0]; - let json_article = JSON.parse(json_text).content_elements; - let article_body_par = document.querySelector('div.article_body > p'); - if (article_body_par) { - article_body_par.innerText = ''; - let parser = new DOMParser(); - let par_text, par_html; - for (let par of json_article) { - par_html = parser.parseFromString('
' + par.content + '