From 137fcd525c65e7cc835a7992ae7ffbd04301ebc2 Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Thu, 21 Mar 2024 12:04:35 +0100 Subject: [PATCH] Fix Haaretz Group (anti-adblocker) --- changelog.txt | 1 + contentScript.js | 20 ++++++++++++++++++-- custom/manifest.json | 2 +- manifest.json | 2 +- sites.js | 2 +- sites_updated.json | 13 +++++++++++++ 6 files changed, 35 insertions(+), 5 deletions(-) diff --git a/changelog.txt b/changelog.txt index 50b3a73..b113dc5 100644 --- a/changelog.txt +++ b/changelog.txt @@ -6,6 +6,7 @@ Post-release Add Blick.ch (Ringier Gruppe) Add CNN (regwall) Fix Expresso.pt (json) +Fix Haaretz Group (anti-adblocker) Fix Newsweek.pl (css) Fix The Athletic (scroll) diff --git a/contentScript.js b/contentScript.js index 6c48073..7bd4475 100644 --- a/contentScript.js +++ b/contentScript.js @@ -4341,6 +4341,15 @@ else if (matchDomain(['haaretz.co.il', 'haaretz.com', 'themarker.com'])) { let article_sel = 'div[data-test="articleBody"], ' + body_wrapper_sel; let article_link_sel = 'article header, main.article-page p, ' + article_sel; if (window.location.pathname.includes('/.')) { + let page_script = document.querySelector('script[src*="/page-"]'); + if (page_script) { + let disabled_items = document.querySelectorAll('section[data-testid="zoidberg-list"], section#comments-section'); + hideDOMElement(...disabled_items); + let noprint = document.querySelectorAll('div.no-print'); + for (let elem of noprint) + if (!elem.hasChildNodes()) + hideDOMElement(elem); + } func_post = function () { let article_link = document.querySelector(article_link_sel); if (article_link) { @@ -4372,6 +4381,13 @@ else if (matchDomain(['haaretz.co.il', 'haaretz.com', 'themarker.com'])) { let inert_links = document.querySelectorAll('article[inert]'); for (let elem of inert_links) elem.removeAttribute('inert'); + } else if (window.location.pathname === '/error') { + window.setTimeout(function () { + let params = new URL(window.location).searchParams; + let path = params.get('path'); + if (path) + window.location.pathname = path; + }, 500); } } @@ -6404,7 +6420,7 @@ function clearPaywall(paywall, paywall_action) { function getGoogleWebcache(url, paywall_sel, paywall_action = '', selector, selector_source = selector) { let url_cache = 'https://webcache.googleusercontent.com/search?q=cache:' + url.split(/[#\?]/)[0]; let paywall = document.querySelectorAll(paywall_sel); - if (paywall.length) { + if (paywall.length && dompurify_loaded) { clearPaywall(paywall, paywall_action); csDoneOnce = true; replaceDomElementExt(url_cache, true, false, selector, '', selector_source); @@ -6414,7 +6430,7 @@ function getGoogleWebcache(url, paywall_sel, paywall_action = '', selector, sele function getArchive(url, paywall_sel, paywall_action = '', selector, text_fail = '', selector_source = selector, selector_archive = selector) { let url_archive = 'https://' + archiveRandomDomain() + '/' + url.split(/[#\?]/)[0]; let paywall = document.querySelectorAll(paywall_sel); - if (paywall.length) { + if (paywall.length && dompurify_loaded) { clearPaywall(paywall, paywall_action); csDoneOnce = true; replaceDomElementExt(url_archive, true, false, selector, text_fail, selector_source, selector_archive); diff --git a/custom/manifest.json b/custom/manifest.json index 2414ba0..04fb130 100644 --- a/custom/manifest.json +++ b/custom/manifest.json @@ -51,5 +51,5 @@ "webRequestBlocking", "*://*/*" ], - "version": "3.6.0.3" + "version": "3.6.0.4" } diff --git a/manifest.json b/manifest.json index 2614ab6..cc1e8b4 100644 --- a/manifest.json +++ b/manifest.json @@ -862,5 +862,5 @@ "*://archive.vn/*", "*://webcache.googleusercontent.com/*" ], - "version": "3.6.0.3" + "version": "3.6.0.4" } diff --git a/sites.js b/sites.js index f37fb42..2c4684f 100644 --- a/sites.js +++ b/sites.js @@ -1108,7 +1108,7 @@ var defaultSites = { "themarker.com" ], allow_cookies: 1, - block_regex: /\.co(m|\.il)\/.+\/magazine\/page-.+\.js/, + block_regex: "{domain}\\/.+\\/page-.+\\.js", cs_dompurify: 1, useragent_custom: "Mozilla/5.0 (Java) outbrain" }, diff --git a/sites_updated.json b/sites_updated.json index 706cde2..99ae4d3 100644 --- a/sites_updated.json +++ b/sites_updated.json @@ -30,6 +30,19 @@ "ld_archive_is": "div#paywall-container|article", "upd_version": "3.5.8.3" }, + "Haaretz Group": { + "domain": "###_il_haaretz_group", + "group": [ + "haaretz.co.il", + "haaretz.com", + "themarker.com" + ], + "allow_cookies": 1, + "block_regex": "{domain}\\/.+\\/page-.+\\.js", + "cs_dompurify": 1, + "useragent_custom": "Mozilla/5.0 (Java) outbrain", + "upd_version": "3.6.0.4" + }, "Hearst Communications (newspapers)": { "domain": "###_usa_hearst_comm", "group": [