From aae4b9cbba31cd4dec5962555d79f49fe0318f2a Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Sun, 19 Dec 2021 15:09:54 +0100 Subject: [PATCH] Fix National Geographic USA (magazine) --- background.js | 19 ++++++++++++++----- changelog.txt | 1 + contentScript.js | 2 +- custom/sites_custom.json | 15 +++++++++++++++ manifest.json | 2 +- 5 files changed, 32 insertions(+), 7 deletions(-) diff --git a/background.js b/background.js index 19e0ef9..e9319f9 100644 --- a/background.js +++ b/background.js @@ -52,7 +52,7 @@ var use_google_bot, use_bing_bot; // Set Referer var use_facebook_referer, use_google_referer, use_twitter_referer; // Set random IP-address -var use_random_ip = ['esprit.presse.fr']; +var use_random_ip = ['esprit.presse.fr', 'nationalgeographic.com']; // concat all sites with change of headers (useragent, referer or random ip) var change_headers; @@ -912,9 +912,14 @@ if (matchUrlDomain(change_headers, details.url) && !['font', 'image', 'styleshee // random IP for sites in use_random_ip if (matchUrlDomain(use_random_ip, details.url)) { + let randomIP_val; + if (matchUrlDomain('nationalgeographic.com', details.url)) + randomIP_val = randomIP(185, 187); + else + randomIP_val = randomIP(); requestHeaders.push({ "name": "X-Forwarded-For", - "value": randomIP() + "value": randomIP_val }) } } @@ -1371,10 +1376,14 @@ function randomInt(max) { return Math.floor(Math.random() * Math.floor(max)); } -function randomIP() { +function randomIP(range_low = 0, range_high = 223) { let rndmIP = []; - for (let n = 0; n < 4; n++) - rndmIP.push(randomInt(254) + 1); + for (let n = 0; n < 4; n++) { + if (n === 0) + rndmIP.push(range_low + randomInt(range_high - range_low) + 1); + else + rndmIP.push(randomInt(255) + 1); + } return rndmIP.join('.'); } diff --git a/changelog.txt b/changelog.txt index 257ecee..69702c2 100644 --- a/changelog.txt +++ b/changelog.txt @@ -11,6 +11,7 @@ Add San Antonio Express-News (local USA) Add The Indian Express Add Vrij Nederland Fix Bloomberg (permission block js) +Fix National Geographic USA (magazine) Remove tabs-permission (amo - Firefox 86+) * v2.4.7.0 (2021-12-12) diff --git a/contentScript.js b/contentScript.js index 9be96c5..870d8b8 100644 --- a/contentScript.js +++ b/contentScript.js @@ -3211,7 +3211,7 @@ function replaceDomElementExt(url, proxy, base64, selector, text_fail = '') { } function archiveLink(url) { - let archive_url = 'https://archive.today?run=1&url=' + url; + let archive_url = 'https://archive.today?run=1&url=' + url.split('?')[0]; let text_fail_div = document.createElement('div'); text_fail_div.id = 'bpc_archive'; text_fail_div.appendChild(document.createTextNode('BPC > Full article text:\r\n')); diff --git a/custom/sites_custom.json b/custom/sites_custom.json index 9768cad..84d743b 100644 --- a/custom/sites_custom.json +++ b/custom/sites_custom.json @@ -15,6 +15,11 @@ "domain": "ara.cat", "useragent": "googlebot" }, + "Bauernzeitung.ch": { + "allow_cookies": 1, + "domain": "bauernzeitung.ch", + "useragent": "googlebot" + }, "Beobachter.ch": { "allow_cookies": 1, "domain": "beobachter.ch", @@ -70,6 +75,11 @@ "allow_cookies": 1, "domain": "internationalepolitik.de" }, + "Investorschronicle.co.uk": { + "allow_cookies": 1, + "domain": "investorschronicle.co.uk", + "referer": "google" + }, "Lindipendente.online": { "allow_cookies": 1, "domain": "lindipendente.online", @@ -139,6 +149,11 @@ "domain": "thebanker.com", "useragent": "googlebot" }, + "Thecourier.co.uk": { + "allow_cookies": 1, + "domain": "thecourier.co.uk", + "useragent": "googlebot" + }, "Thenational.scot": { "allow_cookies": 1, "block_regex": "\\.tinypass\\.com\\/", diff --git a/manifest.json b/manifest.json index 9e76802..a57b6fe 100644 --- a/manifest.json +++ b/manifest.json @@ -595,5 +595,5 @@ "*://*.wallkit.net/*", "*://*.wsj.net/*" ], - "version": "2.4.7.7" + "version": "2.4.7.8" }