From 049a188119452f335e3bbaa6126b504a999e0c1d Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Sat, 23 Mar 2024 11:57:15 +0100 Subject: [PATCH] Add Newslaundry Fix The Quint (json) --- README.md | 1 + changelog.txt | 2 ++ contentScript.js | 70 ++++++++++++++++++++++++++++++-------------- custom/manifest.json | 2 +- manifest.json | 3 +- sites.js | 10 +++++-- sites_updated.json | 6 ++++ 7 files changed, 68 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 48aaac9..ef49a4b 100644 --- a/README.md +++ b/README.md @@ -938,6 +938,7 @@ Grouped in options:\ [Live Law](https://www.livelaw.in) - [LiveMint](https://www.livemint.com) - [Mid-Day](https://www.mid-day.com) - +[Newslaundry](https://www.newslaundry.com) - [Outlook](https://www.outlookindia.com) - [Outlook Business](https://www.outlookbusiness.com) - [Swarajyamag](https://swarajyamag.com) - diff --git a/changelog.txt b/changelog.txt index 33a56e7..4959020 100644 --- a/changelog.txt +++ b/changelog.txt @@ -5,6 +5,7 @@ Updates (install signed xpi-file): https://gitlab.com/magnolia1234/bypass-paywal Post-release Add Blick.ch (Ringier Gruppe) Add CNN (regwall) +Add Newslaundry Fix Bar and Bench (json) Fix Clarin (js) Fix Expresso.pt (json) @@ -12,6 +13,7 @@ Fix Haaretz Group (anti-adblocker) Fix Newsweek.pl (css) Fix The Athletic (scroll) Fix The News Minute (json) +Fix The Quint (json) Fix WSJ (disable bot/referer) * v3.6.0.0 (2024-03-17) diff --git a/contentScript.js b/contentScript.js index 0baf730..a17b084 100644 --- a/contentScript.js +++ b/contentScript.js @@ -4269,6 +4269,8 @@ else if (matchDomain('forbes.com')) { header_nofix(header); } } + let ads = document.querySelectorAll('fbs-ad'); + hideDOMElement(...ads); } else if (matchDomain('foreignaffairs.com')) { @@ -4815,6 +4817,29 @@ else if (matchDomain('newsday.com')) { } } +else if (matchDomain('newslaundry.com')) { + let paywall = document.querySelector('div > div > img[alt^="paywall"]'); + if (paywall && dompurify_loaded) { + let banner = document.querySelector('div.FrsvM'); + removeDOMElement(paywall.parentNode.parentNode, banner); + let json_script = getArticleJsonScript(); + if (json_script) { + let json = JSON.parse(json_script.text); + if (json) { + let json_text = parseHtmlEntities(json.articleBody); + let article = document.querySelector('div.story-element-text'); + if (json_text && article) { + let parser = new DOMParser(); + let doc = parser.parseFromString('
' + DOMPurify.sanitize(json_text) + '
', 'text/html'); + let article_new = doc.querySelector('div'); + article.innerHTML = ''; + article.appendChild(article_new); + } + } + } + } +} + else if (matchDomain('newsweek.com')) { let ads = document.querySelectorAll('div#topad, div[id^="dfp-ad-"]'); hideDOMElement(...ads); @@ -5617,29 +5642,26 @@ else if (matchDomain('thepointmag.com')) { } else if (matchDomain('thequint.com')) { - let paywall = document.querySelector('div#paywall-widget'); - if (paywall) { - removeDOMElement(paywall); - let json_script = getArticleJsonScript(); - if (json_script) { - let json = JSON.parse(json_script.text); - if (json) { - let json_text = breakText(parseHtmlEntities(json.articleBody)); + let lock = document.querySelector('div > img[alt^="lock"]'); + if (lock && dompurify_loaded) { + lock.removeAttribute('alt'); + window.setTimeout(function () { + let paywall = document.querySelector('div#paywall-widget'); + if (paywall) { + removeDOMElement(paywall); let article = document.querySelector('div.story-element'); - if (json_text && article) { - let article_new = document.createElement('p'); - article_new.innerText = json_text; - article.innerHTML = ''; - article.appendChild(article_new); + if (article) { + let article_new = getArticleQuintype(); + if (article_new && article.parentNode) + article.parentNode.replaceChild(article_new, article); } } - } else - refreshCurrentTab(); - let body_hidden = document.querySelector('div#story-body-wrapper'); - if (body_hidden) { - body_hidden.removeAttribute('class'); - body_hidden.removeAttribute('style'); - } + let body_hidden = document.querySelector('div#story-body-wrapper'); + if (body_hidden) { + body_hidden.removeAttribute('class'); + body_hidden.removeAttribute('style'); + } + }, 4000); function thequint_unhide(node) { node.removeAttribute('style'); } @@ -6758,7 +6780,7 @@ function getArticleQuintype() { let story_elements = par['story-elements']; for (let elem of story_elements) { let par_elem; - if (elem.type === 'text' && elem.text && dompurify_loaded) { + if (['text', 'title'].includes(elem.type) && elem.text) { let doc = parser.parseFromString('
' + DOMPurify.sanitize(elem.text, dompurify_options) + '
', 'text/html'); par_elem = doc.querySelector('div'); } else if (elem.type === 'image') { @@ -6769,7 +6791,11 @@ function getArticleQuintype() { par_elem.appendChild(img); if (elem.title) { let caption = document.createElement('figcaption'); - caption.innerText = elem.title; + if (elem.title.includes('' + DOMPurify.sanitize(elem.title, dompurify_options) + '', 'text/html'); + caption.appendChild(doc.querySelector('div')); + } else + caption.innerText = elem.title; par_elem.appendChild(caption); } } diff --git a/custom/manifest.json b/custom/manifest.json index a3e7cf1..b5e6b42 100644 --- a/custom/manifest.json +++ b/custom/manifest.json @@ -51,5 +51,5 @@ "webRequestBlocking", "*://*/*" ], - "version": "3.6.0.7" + "version": "3.6.0.8" } diff --git a/manifest.json b/manifest.json index 8ec7866..e6c580a 100644 --- a/manifest.json +++ b/manifest.json @@ -505,6 +505,7 @@ "*://*.news-press.com/*", "*://*.newscientist.com/*", "*://*.newsday.com/*", + "*://*.newslaundry.com/*", "*://*.newsobserver.com/*", "*://*.newstatesman.com/*", "*://*.newsweek.com/*", @@ -862,5 +863,5 @@ "*://archive.vn/*", "*://webcache.googleusercontent.com/*" ], - "version": "3.6.0.7" + "version": "3.6.0.8" } diff --git a/sites.js b/sites.js index b61ad00..3b0aed7 100644 --- a/sites.js +++ b/sites.js @@ -1804,6 +1804,11 @@ var defaultSites = { allow_cookies: 1, block_regex: /(loader-cdn\.azureedge\.net\/|js\.matheranalytics\.com\/|cdn\.ampproject\.org\/v\d\/amp-access-.+\.js)/ }, + "Newslaundry": { + domain: "newslaundry.com", + allow_cookies: 1, + cs_dompurify: 1 + }, "Newsquest Media Group (UK; opt-in to custom sites)": { domain: "###_uk_newsquest", group: [], @@ -2618,7 +2623,8 @@ var defaultSites = { }, "The Quint": { domain: "thequint.com", - allow_cookies: 1 + allow_cookies: 1, + cs_dompurify: 1 }, "The Salt Lake Tribune": { domain: "sltrib.com", @@ -3127,4 +3133,4 @@ var fr_indigo_nofix_domains = ['africaintelligence.com', 'africaintelligence.fr' var fr_jamg_nofix_domains = ['africabusinessplus.com', 'jeuneafrique.com', 'theafricareport.com']; var it_gedi_nofix_domains = ['gelocal.it', 'limesonline.com']; var nl_mediahuis_region_nofix_domains = ['gooieneemlander.nl', 'haarlemsdagblad.nl', 'ijmuidercourant.nl', 'leidschdagblad.nl', 'noordhollandsdagblad.nl']; -var nofix_sites = ['11freunde.de', 'aamulehti.fi', 'aftenposten.no', 'aftonbladet.se', 'allgaeuer-zeitung.de', 'americanscientist.org', 'arkansasonline.com', 'asahi.com', 'asiatimes.com', 'aviationweek.com', 'badische-zeitung.de', 'bhaskar.com', 'bloomberglaw.com', 'bloombergtax.com', 'bnef.com', 'bnn.de', 'borsen.dk', 'businessdesk.co.nz', 'businessinsider.de', 'businessinsider.jp', 'businesslive.co.za', 'businesstimes.com.sg', 'caixin.com', 'caixinglobal.com', 'caravanmagazine.in', 'catalyst-journal.com', 'chegg.com', 'codesports.com.au', 'compactmag.com', 'coursehero.com', 'deutsche-wirtschafts-nachrichten.de', 'die-glocke.de', 'dn.no', 'dn.se', 'elordenmundial.com', 'entrepreneur.com', 'epw.in', 'ewmagazine.nl', 'falter.at', 'finance.si', 'franc-tireur.fr', 'ftchinese.com', 'ftchineselive.com', 'gamestar.de', 'geo.de', 'golem.de', 'gp.se', 'gva.be', 'handelsblatt.com', 'hbrarabic.com', 'hbrchina.org', 'hbrfrance.fr', 'heise.de', 'hs.fi', 'information.dk', 'investors.com', 'iltalehti.fi', 'jacobin.com', 'jungefreiheit.de', 'kleinezeitung.at', 'krone.at', 'laverita.info', 'lavie.fr', 'lavozdegalicia.es', 'law360.co.uk', 'law360.com', 'le1hebdo.fr', 'leconomiste.com', 'lefigaro.fr', 'lefilmfrancais.com', 'lemonde.fr', 'lequipe.fr', 'lesjours.fr', 'letemps.ch', 'liberation.fr', 'libertiesjournal.com', 'lr-online.de', 'main-echo.de', 'mainpost.de', 'manager-magazin.de', 'medianama.com', 'mediapart.fr', 'milanofinanza.it', 'mittelbayerische.de', 'monde-diplomatique.fr', 'mondediplo.com', 'money.it', 'moneycontrol.com', 'moodys.com', 'morningstar.com', 'motorsport.com', 'moz.de', 'nachrichten.at', 'nationaljournal.com', 'nature.com', 'nbr.co.nz', 'newcriterion.com', 'news24.com', 'newslaundry.com', 'nn.de', 'nwzonline.de', 'on3.com', 'ouest-france.fr', 'philonomist.com', 'pnp.de', 'politicopro.com', 'politiken.dk', 'pressreader.com', 'publico.pt', 'puck.news', 'quillette.com', 'rbc.ru', 'republic.ru', 'rheinpfalz.de', 'risk.net', 'rnz.de', 'saechsische.de', 'sciencedirect.com', 'springer.com', 'statnews.com', 'stern.de', 'stimme.de', 'streetinsider.com', 'substack.com', 'svd.se', 'swp.de', 'taxation.co.uk', 'taxjournal.com', 'the-ken.com', 'theinformation.com', 'theinitium.com', 'themorningcontext.com', 'theparisreview.org', 'thestar.com.my', 'thewirechina.com', 'timeslive.co.za', 'usine-digitale.fr', 'weltwoche.ch', 'weltwoche.de', 'wissenschaft.de', 'worldpoliticsreview.com', 'wz.de', 'zaobao.com.sg'].concat(de_funke_medien_nofix_domains, de_rp_aachen_medien_nofix_domains, de_westfalen_medien_nofix_domains, fr_be_groupe_rossel_nofix_domains, fr_groupe_ebra_nofix_domains, fr_indigo_nofix_domains, fr_jamg_nofix_domains, it_gedi_nofix_domains, nl_mediahuis_region_nofix_domains); +var nofix_sites = ['11freunde.de', 'aamulehti.fi', 'aftenposten.no', 'aftonbladet.se', 'allgaeuer-zeitung.de', 'americanscientist.org', 'arkansasonline.com', 'asahi.com', 'asiatimes.com', 'aviationweek.com', 'badische-zeitung.de', 'bhaskar.com', 'bloomberglaw.com', 'bloombergtax.com', 'bnef.com', 'bnn.de', 'borsen.dk', 'businessdesk.co.nz', 'businessinsider.de', 'businessinsider.jp', 'businesslive.co.za', 'businesstimes.com.sg', 'caixin.com', 'caixinglobal.com', 'caravanmagazine.in', 'catalyst-journal.com', 'chegg.com', 'codesports.com.au', 'compactmag.com', 'coursehero.com', 'deutsche-wirtschafts-nachrichten.de', 'die-glocke.de', 'dn.no', 'dn.se', 'elordenmundial.com', 'entrepreneur.com', 'epw.in', 'ewmagazine.nl', 'falter.at', 'finance.si', 'franc-tireur.fr', 'ftchinese.com', 'ftchineselive.com', 'gamestar.de', 'geo.de', 'golem.de', 'gp.se', 'gva.be', 'handelsblatt.com', 'hbrarabic.com', 'hbrchina.org', 'hbrfrance.fr', 'heise.de', 'hs.fi', 'information.dk', 'investors.com', 'iltalehti.fi', 'jacobin.com', 'jungefreiheit.de', 'kleinezeitung.at', 'krone.at', 'laverita.info', 'lavie.fr', 'lavozdegalicia.es', 'law360.co.uk', 'law360.com', 'le1hebdo.fr', 'leconomiste.com', 'lefigaro.fr', 'lefilmfrancais.com', 'lemonde.fr', 'lequipe.fr', 'lesjours.fr', 'letemps.ch', 'liberation.fr', 'libertiesjournal.com', 'lr-online.de', 'main-echo.de', 'mainpost.de', 'manager-magazin.de', 'medianama.com', 'mediapart.fr', 'milanofinanza.it', 'mittelbayerische.de', 'monde-diplomatique.fr', 'mondediplo.com', 'money.it', 'moneycontrol.com', 'moodys.com', 'morningstar.com', 'motorsport.com', 'moz.de', 'nachrichten.at', 'nationaljournal.com', 'nature.com', 'nbr.co.nz', 'newcriterion.com', 'news24.com', 'nn.de', 'nwzonline.de', 'on3.com', 'ouest-france.fr', 'philonomist.com', 'pnp.de', 'politicopro.com', 'politiken.dk', 'pressreader.com', 'publico.pt', 'puck.news', 'quillette.com', 'rbc.ru', 'republic.ru', 'rheinpfalz.de', 'risk.net', 'rnz.de', 'saechsische.de', 'sciencedirect.com', 'springer.com', 'statnews.com', 'stern.de', 'stimme.de', 'streetinsider.com', 'substack.com', 'svd.se', 'swp.de', 'taxation.co.uk', 'taxjournal.com', 'the-ken.com', 'theinformation.com', 'theinitium.com', 'themorningcontext.com', 'theparisreview.org', 'thestar.com.my', 'thewirechina.com', 'timeslive.co.za', 'usine-digitale.fr', 'weltwoche.ch', 'weltwoche.de', 'wissenschaft.de', 'worldpoliticsreview.com', 'wz.de', 'zaobao.com.sg'].concat(de_funke_medien_nofix_domains, de_rp_aachen_medien_nofix_domains, de_westfalen_medien_nofix_domains, fr_be_groupe_rossel_nofix_domains, fr_groupe_ebra_nofix_domains, fr_indigo_nofix_domains, fr_jamg_nofix_domains, it_gedi_nofix_domains, nl_mediahuis_region_nofix_domains); diff --git a/sites_updated.json b/sites_updated.json index be22d58..dc24930 100644 --- a/sites_updated.json +++ b/sites_updated.json @@ -111,6 +111,12 @@ "block_regex": "\\.{domain}\\/thenewsbar\\/config", "upd_version": "3.5.8.6" }, + "Newslaundry": { + "domain": "newslaundry.com", + "allow_cookies": 1, + "ld_json": "div.FrsvM|div.story-element-text", + "upd_version": "3.6.0.8" + }, "Observador.pt": { "domain": "observador.pt", "allow_cookies": 1,