From 6c1bf39ed59c48d66aca397b32c6b2a895a3182e Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Sat, 4 Sep 2021 11:23:58 +0200 Subject: [PATCH] Fix shz.de & svz.de --- changelog.txt | 1 + contentScript.js | 42 +++++++++++++++++++-------------------- manifest.json | 2 +- options/options_custom.js | 2 +- 4 files changed, 24 insertions(+), 23 deletions(-) diff --git a/changelog.txt b/changelog.txt index bd146211..548cef31 100644 --- a/changelog.txt +++ b/changelog.txt @@ -7,6 +7,7 @@ Fix Estadao.com.br Fix Handelsblatt (only non-premium articles) Fix ilFattoQuotidiano.it Fix NzHerald +Fix shz.de & svz.de * v2.3.5.0 (2021-08-29) Add Forbes diff --git a/contentScript.js b/contentScript.js index 42ab17d6..953f7bbf 100644 --- a/contentScript.js +++ b/contentScript.js @@ -51,7 +51,7 @@ if (ext_api.runtime && (matchDomain(['belfasttelegraph.co.uk', 'independent.ie'] if (!cookieExists('subscriber')) setCookie('subscriber', '{"subscriptionStatus": true}', domain, '/', 14); if (hostname.includes('amp.')) { - let subscriber = document.querySelector('section[amp-access="subscriber"]'); + let subscriber = document.querySelector('section[amp-access="subscriber"][amp-access-hide]'); if (subscriber) subscriber.removeAttribute('amp-access-hide'); let not_subscriber = document.querySelector('section[amp-access="NOT subscriber"]'); @@ -131,11 +131,11 @@ else { let header_ads = document.querySelector('.header_ads-container'); removeDOMElement(header_ads); if (window.location.hostname.startsWith('amp.')) { - let div_hidden_all = document.querySelectorAll('div[amp-access="access AND subscriber"]'); - for (let div_hidden of div_hidden_all) - div_hidden.removeAttribute('amp-access-hide'); + let div_hidden = document.querySelectorAll('div[amp-access="access AND subscriber"][amp-access-hide]'); + for (let elem of div_hidden) + elem.removeAttribute('amp-access-hide'); } else if (window.location.href.includes('?amp')) { - let div_hidden = document.querySelector('div[amp-access="subscriber AND status=\'logged-in\'"]'); + let div_hidden = document.querySelector('div[amp-access="subscriber AND status=\'logged-in\'"][amp-access-hide]'); if (div_hidden) div_hidden.removeAttribute('amp-access-hide'); } @@ -504,15 +504,15 @@ else if (matchDomain('kurier.at')) { else if (matchDomain(['noz.de', 'nwzonline.de', 'shz.de', 'svz.de'])) { let url = window.location.href; - let paywall = document.querySelector('.paywall, .story--premium__container'); if (url.includes('?amp') || url.includes('-amp.html')) { - let subscriber = document.querySelector('div[amp-access="NOT data.reduced"]'); - if (subscriber) - subscriber.removeAttribute('amp-access-hide'); + let subscriber = document.querySelectorAll('div[amp-access="NOT data.reduced"][amp-access-hide]'); + for (let elem of subscriber) + elem.removeAttribute('amp-access-hide'); let non_subscriber = document.querySelector('div[amp-access="data.reduced"]'); let amp_ads = document.querySelectorAll('amp-ad, amp-embed, #flying-carpet-wrapper'); removeDOMElement(non_subscriber, ...amp_ads); } else { + let paywall = document.querySelector('.paywall, .story--premium__container'); let amphtml = document.querySelector('link[rel="amphtml"]'); if (paywall && amphtml) { removeDOMElement(paywall); @@ -609,7 +609,7 @@ if (matchDomain('cmjornal.pt')) { window.location.href = amphtml.href; } } else { - let section_hidden = document.querySelectorAll('section[amp-access="subscriber"]'); + let section_hidden = document.querySelectorAll('section[amp-access="subscriber"][amp-access-hide]'); for (let elem of section_hidden) elem.removeAttribute('amp-access-hide'); let not_subscriber = document.querySelector('section[amp-access="NOT subscriber"]'); @@ -645,7 +645,7 @@ else if (domain = matchDomain(es_unidad_domains)) { let paywall = document.querySelector('div[amp-access="authorized!=true"]'); if (paywall) { removeDOMElement(paywall); - let div_hidden = document.querySelector('div[amp-access="authorized=true"]'); + let div_hidden = document.querySelector('div[amp-access="authorized=true"][amp-access-hide]'); if (div_hidden) { div_hidden.removeAttribute('amp-access-hide'); } @@ -659,7 +659,7 @@ 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"]'); + let paywall = document.querySelectorAll('div[amp-access="success"][amp-access-hide]'); for (let elem of paywall) elem.removeAttribute('amp-access-hide'); let amp_ads = document.querySelectorAll('amp-ad'); @@ -692,7 +692,7 @@ else if (matchDomain('elperiodico.com')) { if (not_logged) { let non_subscr_section = document.querySelector('div[amp-access="NOT logged"]'); removeDOMElement(not_logged, non_subscr_section); - let subscr_section = document.querySelector('div[amp-access="logged"]'); + let subscr_section = document.querySelector('div[amp-access="logged"][amp-access-hide]'); if (subscr_section) subscr_section.removeAttribute('amp-access-hide'); } @@ -1113,7 +1113,7 @@ else if (domain = matchDomain(it_repubblica_domains)) { removeDOMElement(preview); } } else { - paywall = document.querySelector('div[amp-access="showContent"]'); + paywall = document.querySelector('div[amp-access="showContent"][amp-access-hide]'); if (paywall) paywall.removeAttribute('amp-access-hide'); } @@ -1476,7 +1476,7 @@ else if (matchDomain('telegraph.co.uk')) { if (paywall) { let truncated_content = document.querySelector('.truncated-content'); removeDOMElement(paywall, truncated_content); - let subscr_section = document.querySelector('.notAccessibleForFree'); + let subscr_section = document.querySelector('.notAccessibleForFree[amp-access-hide]'); if (subscr_section) subscr_section.removeAttribute('amp-access-hide'); } @@ -2356,9 +2356,9 @@ else if (matchDomain('sandiegouniontribune.com')) { } else if (matchDomain('scmp.com') && window.location.href.includes('/amp.')) { - let div_hidden_all = document.querySelectorAll('div.article-body[amp-access][amp-access-hide]'); - for (let div_hidden of div_hidden_all) - div_hidden.removeAttribute('amp-access-hide'); + let div_hidden = document.querySelectorAll('div.article-body[amp-access][amp-access-hide]'); + for (let elem of div_hidden) + elem.removeAttribute('amp-access-hide'); let default_meters = document.querySelectorAll('div.default-meter, div#archive-article-meter'); let adverts = document.querySelectorAll('amp-ad, div.ad-banner, div.advert-fly-carpet-container, div.inline-advert'); removeDOMElement(...default_meters, ...adverts); @@ -2384,9 +2384,9 @@ else if (matchDomain('seekingalpha.com')) { window.location.href = url.replace('seekingalpha.com/', 'seekingalpha.com/amp/'); }, 500); // Delay (in milliseconds) } else if (url.includes('/amp/')) { - let div_hidden_all = document.querySelectorAll('[amp-access*="premium_access OR"]'); - for (let div_hidden of div_hidden_all) - div_hidden.removeAttribute('amp-access-hide'); + let div_hidden = document.querySelectorAll('[amp-access*="premium_access OR"][amp-access-hide]'); + for (let elem of div_hidden) + elem.removeAttribute('amp-access-hide'); let paywall = document.querySelector('[class*="paywall-container"]'); if (paywall) paywall.setAttribute('style', 'display:none;'); diff --git a/manifest.json b/manifest.json index 2385311e..f01022d6 100644 --- a/manifest.json +++ b/manifest.json @@ -553,5 +553,5 @@ "*://*.wallkit.net/*", "*://*.wsj.net/*" ], - "version": "2.3.5.3" + "version": "2.3.5.4" } \ No newline at end of file diff --git a/options/options_custom.js b/options/options_custom.js index 4408622c..4fc715c5 100644 --- a/options/options_custom.js +++ b/options/options_custom.js @@ -109,7 +109,7 @@ function add_options() { } if (title && sites_custom[title]['domain']) { - sites_custom[title]['domain'] = sites_custom[title]['domain'].replace('www.', '').toLowerCase(); + sites_custom[title]['domain'] = sites_custom[title]['domain'].replace(/(http(s)?:\/\/(www\.)?|^www\.|\/$)/g, '').toLowerCase(); // add new site to local storage ext_api.storage.local.get({