From a3be79876383488d11ee46dacd446efe199aab81 Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Thu, 8 Dec 2022 18:08:28 +0100 Subject: [PATCH] Fix Substack (redundant text) Plus fix NzHerald (premium) --- changelog.txt | 1 + contentScript.js | 26 ++++++++++++++++++-------- manifest.json | 2 +- sites.js | 4 +--- 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/changelog.txt b/changelog.txt index ec57b190..11fd3274 100644 --- a/changelog.txt +++ b/changelog.txt @@ -6,6 +6,7 @@ Remove Law360 (fix obsolete) Fix Business Standard (images) Fix DN.no (images) Fix Noz.de (no amp) +Fix Substack (redundant text) Fix The Athletic (regwall) Update custom flex sites (identify on dom) diff --git a/contentScript.js b/contentScript.js index 4af286a1..49171bc3 100644 --- a/contentScript.js +++ b/contentScript.js @@ -3520,13 +3520,14 @@ else if (matchDomain('nytimes.com')) { else if (matchDomain('nzherald.co.nz')) { // plus code in contentScript_once.js (timing) let article_content = document.querySelector('.article__content'); - if (article_content) { - let premium = document.querySelector('span.ellipsis'); - if (premium && dompurify_loaded) { - premium.classList.remove('ellipsis'); - let article_offer = document.querySelector('.article-offer'); + if (article_content) {//redundant + let article_offer = document.querySelector('.article-offer'); + if (article_offer && dompurify_loaded) { removeDOMElement(article_offer); - let css_selector = article_content.querySelectorAll('p[style]')[1].getAttribute('class'); + let premium = document.querySelector('span.ellipsis'); + if (premium) + premium.classList.remove('ellipsis'); + let css_selector = article_content.querySelectorAll('p[style][class]')[1].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); @@ -3546,7 +3547,8 @@ else if (matchDomain('nzherald.co.nz')) { } } let premium_toaster = document.querySelector('#premium-toaster'); - removeDOMElement(premium_toaster); + let ads = document.querySelectorAll('.ad'); + removeDOMElement(premium_toaster, ...ads); } else if (matchDomain('outlookbusiness.com')) { @@ -4293,8 +4295,9 @@ else if (matchDomain('wsj.com')) { else if (matchDomain('substack.com') || document.querySelector('script[src^="https://substackcdn.com/min/main.bundle.js"]')) { let paywall = document.querySelector('div.paywall:not(.modal-paywall)'); + let article_sel = 'div.available-content'; if (paywall) { - let article = document.querySelector('div.available-content'); + let article = document.querySelector(article_sel); if (article) { let msg = document.createElement('div'); msg.innerText = 'BPC > no fix !'; @@ -4302,6 +4305,13 @@ else if (matchDomain('substack.com') || document.querySelector('script[src^="htt article.insertBefore(msg, article.firstChild); } csDoneOnce = true; + } else { + let lock = document.querySelector('path.lock-body'); + let paywall_content_sel = 'div.paywall-content'; + let redundant_sel = lock ? article_sel : paywall_content_sel; + let redundant_elem = document.querySelector(redundant_sel); + removeDOMElement(redundant_elem); + waitDOMElement(redundant_sel, 'DIV', removeDOMElement, true); } } diff --git a/manifest.json b/manifest.json index 0c6db94b..46cbc0b2 100644 --- a/manifest.json +++ b/manifest.json @@ -718,5 +718,5 @@ "*://*.wallkit.net/*", "*://webcache.googleusercontent.com/*" ], - "version": "2.9.6.4" + "version": "2.9.6.5" } diff --git a/sites.js b/sites.js index 6b654dce..12a775b0 100644 --- a/sites.js +++ b/sites.js @@ -1361,9 +1361,7 @@ var defaultSites = { }, "New Zealand Herald": { domain: "nzherald.co.nz", - allow_cookies: 1, - block_regex: /\.nzherald\.co\.nz\/pf\/resources\/(dist\/)?scripts\/(prebid|global-ad-script|tracking\/.+)\.js/, - useragent: "bingbot" + allow_cookies: 1 }, "Newsday": { domain: "newsday.com",