From 858e74ddd401ca04b882c298d2d39cc0a6f4d80f Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Tue, 12 Mar 2024 18:22:08 +0100 Subject: [PATCH] Fix Fast Company (premium) --- changelog.txt | 1 + contentScript.js | 53 ++++++++++++++++++++++++++++++++++++-------- custom/manifest.json | 2 +- manifest.json | 2 +- sites.js | 3 ++- 5 files changed, 49 insertions(+), 12 deletions(-) diff --git a/changelog.txt b/changelog.txt index 21227478..8c8dd2c0 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 Courrier international Add Observador.pt +Fix Fast Company (premium) * v3.5.9.0 (2024-03-10) Add Funke Mediengruppe (fetch from archive.is) diff --git a/contentScript.js b/contentScript.js index 832e15df..8ee286c0 100644 --- a/contentScript.js +++ b/contentScript.js @@ -346,7 +346,7 @@ window.addEventListener('message', function (event) { var overlay = document.querySelector('body.didomi-popup-open'); if (overlay) overlay.classList.remove('didomi-popup-open'); -var ads = document.querySelectorAll('div.OUTBRAIN, div[id^="taboola-"], div.ad-container, div[class*="-ad-container"], div[class*="_ad-container"]'); +var ads = document.querySelectorAll('div.OUTBRAIN, div[id^="taboola-"], div.ad, div.ads, div.ad-container, div[class*="-ad-container"], div[class*="_ad-container"]'); hideDOMElement(...ads); if (!(csDone || csDoneOnce)) { @@ -3294,7 +3294,7 @@ if (matchDomain('abril.com.br')) { let amp_ads = document.querySelectorAll('amp-ad, amp-embed'); hideDOMElement(...amp_ads); } else { - let ads = document.querySelectorAll('div.ads, div[class^="ads-"], div.MGID'); + let ads = document.querySelectorAll('div[class^="ads-"], div.MGID'); hideDOMElement(...ads); } } @@ -3445,7 +3445,7 @@ else if (matchDomain('eltribuno.com')) { else if (matchDomain('em.com.br')) { if (!window.location.pathname.endsWith('/amp.html')) { amp_redirect('.news-blocked-content'); - let ads = document.querySelectorAll('.ads, .containerads'); + let ads = document.querySelectorAll('.containerads'); hideDOMElement(...ads); } else { amp_unhide_subscr_section('amp-ad, amp-embed, amp-fx-flying-carpet'); @@ -4141,6 +4141,41 @@ else if (matchDomain('euobserver.com')) { } else if (matchDomain('fastcompany.com')) { + let paywall = document.querySelector('div.paywall'); + if (paywall && dompurify_loaded) { + removeDOMElement(paywall); + let scripts = document.querySelectorAll('script:not([src]):not([type])'); + let json_script; + for (let script of scripts) { + if (script.text.match(/window\.appState\s=\s/)) { + json_script = script; + break; + } + } + if (json_script) { + try { + let json = JSON.parse(json_script.text.split(/window\.appState\s=\s/)[1].split('};')[0].replace(/:undefined([,}])/g, ':"undefined"$1') + '}'); + if (json) { + let pars_array = json.post.data.post.content; + let article = document.querySelector('article'); + if (pars_array.length && article) { + article.innerHTML = ''; + article.classList.remove('post__article--lock'); + let parser = new DOMParser(); + for (let par_array of pars_array) { + for (let par of par_array) { + let content_new = parser.parseFromString('
' + DOMPurify.sanitize(par, dompurify_options) + '
', 'text/html'); + let elem = content_new.querySelector('div'); + article.appendChild(elem); + } + } + } + } + } catch (err) { + console.log(err); + } + } + } let ads = document.querySelectorAll('div[class*="ad-wrapper"]'); hideDOMElement(...ads); } @@ -4931,7 +4966,7 @@ else if (matchDomain('seekingalpha.com')) { else if (matchDomain(sg_sph_media_domains)) { let url = window.location.href; getArchive(url, 'div#nocx_paywall_area', '', 'main#content'); - let ads = document.querySelectorAll('div.ads, div[id^="dfp-ad-"], div.cx_paywall_placeholder'); + let ads = document.querySelectorAll('div[id^="dfp-ad-"], div.cx_paywall_placeholder'); hideDOMElement(...ads); } @@ -4948,7 +4983,7 @@ else if (matchDomain('slideshare.net')) { } else if (matchDomain('sltrib.com')) { - let ads = document.querySelectorAll('.ad, div.stickyAd, div[class^="sltrib_medrec"]'); + let ads = document.querySelectorAll('div.stickyAd, div[class^="sltrib_medrec"]'); hideDOMElement(...ads); } @@ -5317,7 +5352,7 @@ else if (matchDomain('theglobeandmail.com')) { else if (matchDomain(['thehindu.com', 'thehindubusinessline.com'])) { if (!window.location.pathname.endsWith('/amp/')) { let counter = document.querySelector('#test'); - let ads = document.querySelectorAll('.ad, .article-ad, .dfp-ad'); + let ads = document.querySelectorAll('.article-ad, .dfp-ad'); hideDOMElement(counter, ...ads); } else { let ads = document.querySelectorAll('amp-ad, amp-embed, [class^="height"], [class^="advt"], [id^="piano"]'); @@ -5974,7 +6009,7 @@ else if (matchDomain('washingtonpost.com')) { } else if (matchDomain('winnipegfreepress.com')) { - let ads = document.querySelectorAll('.billboard-ad-space, .ad, .article-ad, .fixed-sky'); + let ads = document.querySelectorAll('.billboard-ad-space, .article-ad, .fixed-sky'); hideDOMElement(...ads); } @@ -6506,7 +6541,7 @@ function amp_redirect(paywall_sel, paywall_action = '', amp_url = '') { } } -function amp_unhide_subscr_section(amp_ads_sel = 'amp-ad, .ad', replace_iframes = true, amp_iframe_link = false, source = '') { +function amp_unhide_subscr_section(amp_ads_sel = 'amp-ad', replace_iframes = true, amp_iframe_link = false, source = '') { let preview = document.querySelectorAll('[subscriptions-section="content-not-granted"]'); removeDOMElement(...preview); let subscr_section = document.querySelectorAll('[subscriptions-section="content"]'); @@ -6518,7 +6553,7 @@ function amp_unhide_subscr_section(amp_ads_sel = 'amp-ad, .ad', replace_iframes amp_iframes_replace(amp_iframe_link, source); } -function amp_unhide_access_hide(amp_access = '', amp_access_not = '', amp_ads_sel = 'amp-ad, .ad', replace_iframes = true, amp_iframe_link = false, source = '') { +function amp_unhide_access_hide(amp_access = '', amp_access_not = '', amp_ads_sel = 'amp-ad', replace_iframes = true, amp_iframe_link = false, source = '') { let access_hide = document.querySelectorAll('[amp-access' + amp_access + '][amp-access-hide]:not([amp-access="error"], [amp-access^="message"], .piano)'); for (let elem of access_hide) elem.removeAttribute('amp-access-hide'); diff --git a/custom/manifest.json b/custom/manifest.json index 2750f0aa..655c7d87 100644 --- a/custom/manifest.json +++ b/custom/manifest.json @@ -51,5 +51,5 @@ "webRequestBlocking", "*://*/*" ], - "version": "3.5.9.2" + "version": "3.5.9.3" } diff --git a/manifest.json b/manifest.json index 303d7afc..4f6379de 100644 --- a/manifest.json +++ b/manifest.json @@ -857,5 +857,5 @@ "*://archive.vn/*", "*://webcache.googleusercontent.com/*" ], - "version": "3.5.9.2" + "version": "3.5.9.3" } diff --git a/sites.js b/sites.js index adf336ea..fc25eb63 100644 --- a/sites.js +++ b/sites.js @@ -734,7 +734,8 @@ var defaultSites = { "Fast Company": { domain: "fastcompany.com", allow_cookies: 1, - block_regex: /(\.tinypass\.com\/|\.fastcompany\.com\/script\.js)/ + block_regex: /(\.tinypass\.com\/|\.fastcompany\.com\/script\.js)/, + cs_dompurify: 1 }, "Field & Stream": { domain: "fieldandstream.com",