From e444baaa52fad8d466109194cf22c1d952ee3a2b Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Fri, 4 Feb 2022 08:50:55 +0100 Subject: [PATCH] Fix WaPo --- background.js | 8 +++++--- changelog.txt | 1 + contentScript.js | 4 ++++ manifest.json | 2 +- sites.js | 2 +- sites_updated.json | 21 +++++---------------- 6 files changed, 17 insertions(+), 21 deletions(-) diff --git a/background.js b/background.js index 9e78608..6e6e7cb 100644 --- a/background.js +++ b/background.js @@ -572,7 +572,7 @@ ext_api.webRequest.onBeforeRequest.addListener(function (details) { // Australia News Corp redirect subscribe to amp var au_news_corp_subscr = au_news_corp_domains.map(domain => '*://www.' + domain + '/subscribe/*'); ext_api.webRequest.onBeforeRequest.addListener(function (details) { - if (!isSiteEnabled(details) || details.url.includes('/digitalprinteditions') || !details.url.includes('dest=')) { + if (!isSiteEnabled(details) || details.url.includes('/digitalprinteditions') || !(details.url.includes('dest=') && details.url.split('dest=')[1].split('&')[0])) { return; } var updatedUrl = decodeURIComponent(details.url.split('dest=')[1].split('&')[0]); @@ -913,14 +913,16 @@ ext_api.webRequest.onBeforeSendHeaders.addListener(function(details) { var useUserAgentMobile = false; var setReferer = false; + +if (matchUrlDomain(change_headers, details.url) && !['font', 'image', 'stylesheet'].includes(details.type)) { + var mobile = details.requestHeaders.filter(x => x.name.toLowerCase() === "user-agent" && x.value.toLowerCase().includes("mobile")).length; var googlebotEnabled = matchUrlDomain(use_google_bot, details.url) && !(matchUrlDomain('barrons.com', details.url) && enabledSites.includes('#options_disable_gb_barrons')) && - !(matchUrlDomain('thetimes.co.uk', details.url) && !details.url.match(/\/epaper\.thetimes\.co\.uk\/article\//)) && + !(matchUrlDomain('thetimes.co.uk', details.url) && !(details.url.match(/\/epaper\.thetimes\.co\.uk\/article\//) || mobile)) && !(matchUrlDomain('wsj.com', details.url) && enabledSites.includes('#options_disable_gb_wsj')); var bingbotEnabled = matchUrlDomain(use_bing_bot, details.url) && !(matchUrlDomain('stratfor.com', details.url) && details.url.match(/(\/(\d){4}-([a-z]||-)+-forecast(-([a-z]|-)+)?|-forecast-(\d){4}-([a-z]|[0-9]||-)+)$/)); -if (matchUrlDomain(change_headers, details.url) && !['font', 'image', 'stylesheet'].includes(details.type)) { // if referer exists, set it requestHeaders = requestHeaders.map(function (requestHeader) { if (requestHeader.name === 'Referer') { diff --git a/changelog.txt b/changelog.txt index c3062c0..6f169b8 100644 --- a/changelog.txt +++ b/changelog.txt @@ -8,6 +8,7 @@ Fix La Tercera (js) Fix MIT Technology Review (TinyPass) Fix TheTimes.co.uk (epaper) Fix Times Literary Supplement (set referer Google) +Fix WaPo * v2.5.4.0 (2022-01-30) Add group Outside magazines diff --git a/contentScript.js b/contentScript.js index b471aa6..16a2c82 100644 --- a/contentScript.js +++ b/contentScript.js @@ -218,13 +218,17 @@ else { let header_ads = document.querySelector('.header_ads-container'); removeDOMElement(header_ads); let amp_ads_sel = 'amp-ad, amp-embed, [id^="ad-mrec-"], .story-ad-container'; + let comments; if (window.location.hostname.startsWith('amp.')) { amp_unhide_access_hide('="access AND subscriber"', '', amp_ads_sel, true, true, 'resourcesssl.newscdn.com.au'); + comments = document.querySelector('#story-comments, .comments-wrapper'); } else if (window.location.href.includes('?amp')) { amp_unhide_access_hide('="subscriber AND status=\'logged-in\'"', '', amp_ads_sel, true, true, 'resourcesssl.newscdn.com.au'); + comments = document.querySelector('#comments-load'); let amp_iframe_sizers = document.querySelectorAll('amp-iframe > i-amphtml-sizer'); removeDOMElement(...amp_iframe_sizers) } + removeDOMElement(comments); } else { // Australian Seven West Media let swm_image = document.querySelector('img[src^="https://images.thewest.com.au"]'); diff --git a/manifest.json b/manifest.json index b9258f8..254907c 100644 --- a/manifest.json +++ b/manifest.json @@ -613,5 +613,5 @@ "*://*.wallkit.net/*", "*://*.wsj.net/*" ], - "version": "2.5.4.3" + "version": "2.5.4.4" } diff --git a/sites.js b/sites.js index c7beece..530c07d 100644 --- a/sites.js +++ b/sites.js @@ -1648,7 +1648,7 @@ var defaultSites = { "The Washington Post": { domain: "washingtonpost.com", allow_cookies: 1, - block_regex: /\.washingtonpost\.com\/pwapiv2\/article/ + block_regex: /\.washingtonpost\.com\/tetro\/evaluate/ }, "The West Australian (+ regional/opt-in to custom sites)": { domain: "thewest.com.au", diff --git a/sites_updated.json b/sites_updated.json index 39a3fd3..47d9c1a 100644 --- a/sites_updated.json +++ b/sites_updated.json @@ -20,16 +20,6 @@ "allow_cookies": 1, "block_regex": "(\\.com\\.au\\/remote\\/identity\\/rampart\\/latest\\/rampart\\.js|cdn\\.ampproject\\.org\\/v\\d\\/amp-(access|(sticky-)?ad)-.+\\.js)" }, - - "Clarín": { - "domain": "clarin.com", - "allow_cookies": 1, - "block_regex": "\\.clarin\\.com\\/commons\\/js\\/auth0\\.js" - }, - "Huffingtonpost.it": { - "domain": "huffingtonpost.it", - "group_rule": "###_gr_it_repubblica_domains" - }, "La Tercera": { "domain": "latercera.com", "allow_cookies": 1, @@ -40,12 +30,6 @@ "allow_cookies": 1, "block_regex": "(\\.tinypass\\.com\\/|cdn\\.ampproject\\.org\\/v\\d\\/amp-(access|ad)-.+\\.mjs)" }, - "###_gr_it_repubblica_domains": { - "group_rule_domains": ["gelocal.it", "huffingtonpost.it", "ilsecoloxix.it", "italian.tech", "lanuovasardegna.it", "lastampa.it", "lescienze.it", "limesonline.com", "repubblica.it"], - "allow_cookies": 1, - "block_regex": "(scripts\\.repubblica\\.it\\/pw\\/pw\\.js|cdn\\.ampproject\\.org\\/v\\d\\/amp-(access|ad|user-notification)-.+\\.js)", - "useragent": "googlebot" - }, "The Seattle Times": { "domain": "seattletimes.com", "allow_cookies": 1, @@ -59,5 +43,10 @@ "The Times Literary Supplement": { "domain": "the-tls.co.uk", "referer": "google" + }, + "The Washington Post": { + "domain": "washingtonpost.com", + "allow_cookies": 1, + "block_regex": "\\.washingtonpost\\.com\\/tetro\\/evaluate" } }