From 4702da24c5e75b5a02cd295e9e8845f60eaab61f Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Sun, 4 Sep 2022 09:12:52 +0200 Subject: [PATCH] Fix The Globe and Mail (images) --- background.js | 8 +++----- changelog.txt | 1 + contentScript.js | 28 ++++++++++++---------------- custom/manifest.json | 2 +- manifest.json | 2 +- sites.js | 6 +----- 6 files changed, 19 insertions(+), 28 deletions(-) diff --git a/background.js b/background.js index 33aa090..e06ab08 100755 --- a/background.js +++ b/background.js @@ -21,6 +21,7 @@ var restrictions = { 'economictimes.com': /\.economictimes\.com($|\/($|(__assets|prime)(\/.+)?|.+\.cms))/, 'elespanol.com': /^((?!\/cronicaglobal\.elespanol\.com\/).)*$/, 'espn.com': /^((?!espn\.com\/watch).)*$/, + 'esquire.com': /^((?!\/classic\.esquire\.com\/).)*$/, 'faz.net': /^((?!\.faz\.net\/aktuell\/(\?switchfaznet)?$).)*$/, 'lastampa.it': /^((?!\/video\.lastampa\.it\/).)*$/, 'nytimes.com': /^((?!\/timesmachine\.nytimes\.com\/).)*$/, @@ -291,8 +292,6 @@ function set_rules(sites, sites_updated, sites_custom) { } } } - if (enabledSites.includes('#options_optin_tgam_premium')) - blockedRegexes['theglobeandmail.com'] = /smartwall\.theglobeandmail\.com\//; use_random_ip = Object.keys(random_ip); change_headers = use_google_bot.concat(use_bing_bot, use_facebook_referer, use_google_referer, use_twitter_referer, use_random_ip); disableJavascriptOnListedSites(); @@ -653,14 +652,13 @@ ext_api.webRequest.onHeadersReceived.addListener(function (details) { ['blocking', 'responseHeaders']); // block inline script -var block_js_inline = ["*://*.crusoe.uol.com.br/*", "*://*.elpais.com/*", "*://*.nautil.us/*", "*://*.theglobeandmail.com/*"]; +var block_js_inline = ["*://*.crusoe.uol.com.br/*", "*://*.elpais.com/*", "*://*.nautil.us/*"]; if (block_js_inline.length) ext_api.webRequest.onHeadersReceived.addListener(function (details) { let url_path = details.url.split('?')[0]; let excluded = (matchUrlDomain('crusoe.uol.com.br', details.url) && (optin_setcookie || !url_path.match(/\.br\/(diario|edicoes)\/.+/))) || (matchUrlDomain('elpais.com', details.url) && (url_path.includes('/elpais.com') || !url_path.includes('.html'))) - || (matchUrlDomain('nautil.us', details.url) && !details.url.match(/((\w)+(\-)+){3,}/)) - || (matchUrlDomain('theglobeandmail.com', details.url) && (!enabledSites.includes('#options_optin_tgam_premium') || !details.url.includes('?rel=premium'))); + || (matchUrlDomain('nautil.us', details.url) && !details.url.match(/((\w)+(\-)+){3,}/)); if (!isSiteEnabled(details) || excluded) return; var headers = details.responseHeaders; diff --git a/changelog.txt b/changelog.txt index 738072f..28ac69f 100644 --- a/changelog.txt +++ b/changelog.txt @@ -8,6 +8,7 @@ Add Popular Science Remove Dark Reading (no paywall) Fix Australian Community Media (overlay) Fix L'Opinion.fr +Fix The Globe and Mail (images) Fix The Toronto Star Fix WSJ (mobile layout) diff --git a/contentScript.js b/contentScript.js index a226ec8..2a2e280 100755 --- a/contentScript.js +++ b/contentScript.js @@ -3190,12 +3190,12 @@ else if (matchDomain('nationalgeographic.com')) { } else if (matchDomain('nationalreview.com')) { - let url = window.location.href.split('?')[0]; - if (!url.includes('/amp/')) { - let continue_reading = document.querySelector('div.continue-reading'); - if (continue_reading) { - removeDOMElement(continue_reading); - window.location.href = url + 'amp'; + if (!window.location.pathname.endsWith('/amp/')) { + let paywall = document.querySelector('div.continue-reading'); + let amphtml = document.querySelector('link[rel="amphtml"]'); + if (paywall && amphtml) { + removeDOMElement(paywall); + window.location.href = amphtml.href; } } let adverts = document.querySelectorAll('amp-ad, .ad-unit--center, amp-connatix-player'); @@ -3711,16 +3711,12 @@ else if (matchDomain('thediplomat.com')) { } else if (matchDomain('theglobeandmail.com')) { - let paywall = document.querySelector('div.c-paywall'); - if (paywall) { - removeDOMElement(paywall); - let url = window.location.href.split('?')[0]; - window.location.href = url + '?rel=premium'; - } else { - let article_body_subscribed = document.querySelector('.c-article-body--subscribed'); - if (article_body_subscribed) - article_body_subscribed.removeAttribute('class'); - } + let article_body_subscribed = document.querySelector('.c-article-body--subscribed'); + if (article_body_subscribed) + article_body_subscribed.removeAttribute('class'); + let lazy_images = document.querySelectorAll('img.lazyimage[src^="data:image/"][data-src]'); + for (let elem of lazy_images) + elem.src = elem.getAttribute('data-src'); let banners = document.querySelectorAll('div.c-ad, div#subscription-pencil-area, div.marketing-container-wrapper'); removeDOMElement(...banners); } diff --git a/custom/manifest.json b/custom/manifest.json index 6af764c..dc8b70c 100644 --- a/custom/manifest.json +++ b/custom/manifest.json @@ -43,5 +43,5 @@ "webRequestBlocking", "" ], - "version": "2.8.2.6" + "version": "2.8.2.7" } diff --git a/manifest.json b/manifest.json index b4d8323..bbcbea9 100755 --- a/manifest.json +++ b/manifest.json @@ -690,5 +690,5 @@ "*://gcm.omerlocdn.com/*", "*://webcache.googleusercontent.com/*" ], - "version": "2.8.2.6" + "version": "2.8.2.7" } diff --git a/sites.js b/sites.js index b03119b..eef157a 100755 --- a/sites.js +++ b/sites.js @@ -1230,8 +1230,7 @@ var defaultSites = { "National Review": { domain: "nationalreview.com", allow_cookies: 1, - block_regex: /(\.blueconic\.net\/|\.nationalreview\.com\/script\.js|cdn\.ampproject\.org\/v\d\/amp-access-.+\.js)/, - useragent: "googlebot" + block_regex: /(\.blueconic\.net\/|cdn\.ampproject\.org\/v\d\/amp-access-.+\.js)/ }, "Nautilus": { domain: "nautil.us", @@ -2091,9 +2090,6 @@ var defaultSites = { "The Wall Street Journal - no Googlebot (http error 500)": { domain: "#options_disable_gb_wsj" }, - "The Globe and Mail premium-only (or when empty sections)": { - domain: "#options_optin_tgam_premium" - }, } if (typeof browser === 'object') {