diff --git a/background.js b/background.js index ec89600..f49632f 100755 --- a/background.js +++ b/background.js @@ -232,7 +232,6 @@ var use_google_bot_default = [ 'rheinpfalz.de', 'ruhrnachrichten.de', 'seekingalpha.com', - 'statista.com', 'thetimes.co.uk', 'usatoday.com', 'usinenouvelle.com', @@ -255,7 +254,7 @@ var use_bing_bot = use_bing_bot_default.slice(); var use_facebook_referer_default = ['clarin.com', 'fd.nl', 'ilmanifesto.it', 'law.com', 'sloanreview.mit.edu']; var use_facebook_referer = use_facebook_referer_default.slice(); -var use_google_referer_default = []; +var use_google_referer_default = ['statista.com']; var use_google_referer = use_google_referer_default.slice(); var use_twitter_referer_default = ['medium.com', 'towardsdatascience.com']; var use_twitter_referer = use_twitter_referer_default.slice(); @@ -1145,14 +1144,15 @@ ext_api.webRequest.onBeforeSendHeaders.addListener(function(details) { var useUserAgentMobile = false; var setReferer = false; + var googlebotEnabled = matchUrlDomain(use_google_bot, details.url) && + !(matchUrlDomain('barrons.com', details.url) && enabledSites.includes('#options_disable_gb_barrons')) && + !(matchUrlDomain('wsj.com', details.url) && enabledSites.includes('#options_disable_gb_wsj')); -if (matchUrlDomain(change_headers, details.url) && (['main_frame', 'sub_frame', 'xmlhttprequest'].includes(details.type) || matchUrlDomain('thetimes.co.uk', details.url)) && - !(matchUrlDomain('barrons.com', details.url) && enabledSites.includes('#options_disable_gb_barrons')) && - !(matchUrlDomain('wsj.com', details.url) && enabledSites.includes('#options_disable_gb_wsj'))) { - // if referer exists, set it to google +if (matchUrlDomain(change_headers, details.url) && (['main_frame', 'sub_frame', 'xmlhttprequest'].includes(details.type) || matchUrlDomain('thetimes.co.uk', details.url))) { + // if referer exists, set it requestHeaders = requestHeaders.map(function (requestHeader) { if (requestHeader.name === 'Referer') { - if (matchUrlDomain(use_google_bot, details.url) || matchUrlDomain(use_google_referer, details.url)) { + if (googlebotEnabled || matchUrlDomain(use_google_referer, details.url)) { requestHeader.value = 'https://www.google.com/'; } else if (matchUrlDomain(use_facebook_referer, details.url)) { requestHeader.value = 'https://www.facebook.com/'; @@ -1169,7 +1169,7 @@ if (matchUrlDomain(change_headers, details.url) && (['main_frame', 'sub_frame', // otherwise add it if (!setReferer) { - if (matchUrlDomain(use_google_bot, details.url) || matchUrlDomain(use_google_referer, details.url)) { + if (googlebotEnabled || matchUrlDomain(use_google_referer, details.url)) { requestHeaders.push({ name: 'Referer', value: 'https://www.google.com/' @@ -1188,7 +1188,7 @@ if (matchUrlDomain(change_headers, details.url) && (['main_frame', 'sub_frame', } // override User-Agent to use Googlebot - if (matchUrlDomain(use_google_bot, details.url)) { + if (googlebotEnabled) { requestHeaders.push({ "name": "User-Agent", "value": useUserAgentMobile ? userAgentMobileG : userAgentDesktopG diff --git a/changelog.txt b/changelog.txt index 7471521..a4dc5fb 100644 --- a/changelog.txt +++ b/changelog.txt @@ -7,6 +7,7 @@ Add Southern Weekly (China) Fix Alma Talent sites Fix Bloomberg Fix Nikkei Asian Review (cookies) +Fix Statista (set referer Google) Fix The Daily Telegraph (au) Fix Times of India (TOI+ region block) Fix WaPo (magazine) diff --git a/contentScript.js b/contentScript.js index e1dd80f..2b11594 100755 --- a/contentScript.js +++ b/contentScript.js @@ -1669,25 +1669,23 @@ else if (matchDomain('bloomberg.com')) { if (json_script) { let json = JSON.parse(json_script.innerHTML); if (json) { - let json_text = json.body; - let json_id = json.id; - let meta_id = document.querySelector('meta[name="parsely-post-id"][content]'); - if (json_text && json_text !== 'undefined' && json_id && json_id !== 'undefined' && meta_id && meta_id.content === json_id) { + let json_text = json.body ? json.body : ''; + if (json_text) { removeDOMElement(json_script); - let article = document.querySelector('div.body-copy-v2'); + let article = document.querySelector('div.body-copy-v2:not(.art_done)'); let article_class = 'body-copy-v2'; if (!article) { - article = document.querySelector('div.body-copy'); + article = document.querySelector('div.body-copy:not(.art_done)'); article_class = 'body-copy'; } - let parser = new DOMParser(); - let doc = parser.parseFromString('
' + DOMPurify.sanitize(json_text, {ADD_TAGS: ['iframe']}) + '
', 'text/html'); - let article_new = doc.querySelector('div'); - if (article_new) { - if (article) { + if (article) { + article_class += ' art_done'; + let parser = new DOMParser(); + let doc = parser.parseFromString('
' + DOMPurify.sanitize(json_text, {ADD_TAGS: ['iframe']}) + '
', 'text/html'); + let article_new = doc.querySelector('div'); + if (article_new) article.parentNode.replaceChild(article_new, article); - } - } + } } } } diff --git a/custom/manifest.json b/custom/manifest.json index 73f8a10..ed49bbd 100644 --- a/custom/manifest.json +++ b/custom/manifest.json @@ -38,5 +38,5 @@ "webRequestBlocking", "" ], - "version": "2.2.9.7" + "version": "2.2.9.8" } \ No newline at end of file diff --git a/manifest.json b/manifest.json index d65efc3..abaeb73 100755 --- a/manifest.json +++ b/manifest.json @@ -526,5 +526,5 @@ "*://*.wallkit.net/*", "*://*.wsj.net/*" ], - "version": "2.2.9.7" + "version": "2.2.9.8" } \ No newline at end of file