diff --git a/background.js b/background.js index e9319f9..03e2d34 100755 --- a/background.js +++ b/background.js @@ -52,7 +52,8 @@ 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', 'nationalgeographic.com']; +var random_ip = {}; +var use_random_ip = []; // concat all sites with change of headers (useragent, referer or random ip) var change_headers; @@ -80,6 +81,7 @@ function initSetRules() { use_facebook_referer = []; use_google_referer = []; use_twitter_referer = []; + random_ip = {}; change_headers = []; amp_unhide = []; amp_redirect = {}; @@ -244,6 +246,9 @@ function set_rules(sites, sites_updated, sites_custom) { break; } } + if (rule.random_ip) { + random_ip[domain] = rule.random_ip; + } // updated if (rule.amp_redirect) amp_redirect[domain] = rule.amp_redirect; @@ -261,6 +266,7 @@ function set_rules(sites, sites_updated, sites_custom) { } } } + 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(); } @@ -911,10 +917,11 @@ 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 domain_random; + if (domain_random = matchUrlDomain(use_random_ip, details.url)) { let randomIP_val; - if (matchUrlDomain('nationalgeographic.com', details.url)) - randomIP_val = randomIP(185, 187); + if (random_ip[domain_random] === 'eu') + randomIP_val = randomIP(185, 185); else randomIP_val = randomIP(); requestHeaders.push({ @@ -1380,7 +1387,7 @@ function randomIP(range_low = 0, range_high = 223) { let rndmIP = []; for (let n = 0; n < 4; n++) { if (n === 0) - rndmIP.push(range_low + randomInt(range_high - range_low) + 1); + rndmIP.push(range_low + randomInt(range_high - range_low + 1)); else rndmIP.push(randomInt(255) + 1); } diff --git a/changelog.txt b/changelog.txt index 0a1ef39..10dac27 100644 --- a/changelog.txt +++ b/changelog.txt @@ -2,6 +2,7 @@ Changelog Bypass Paywalls Clean - Chrome Post-release +Update custom sites (random ip) * v2.4.8.0 (2021-12-19) Add Aachener-Nachrichten.de diff --git a/options/options_custom.js b/options/options_custom.js index 43bb68c..1a9d0f2 100644 --- a/options/options_custom.js +++ b/options/options_custom.js @@ -2,6 +2,7 @@ var ext_api = chrome || browser; var useragent_options = ['', 'googlebot', 'bingbot']; var referer_options = ['', 'facebook', 'google', 'twitter']; +var random_ip_options = ['', 'all', 'eu']; function capitalize(str) { return (typeof str === 'string') ? str.charAt(0).toUpperCase() + str.slice(1) : ''; @@ -191,6 +192,7 @@ function edit_options() { document.querySelector('input[data-key="block_regex"]').value = edit_site.block_regex ? edit_site.block_regex : ''; document.querySelector('input[data-key="amp_unhide"]').checked = (edit_site.amp_unhide > 0); document.querySelector('select[data-key="referer"]').selectedIndex = referer_options.indexOf(edit_site.referer); + document.querySelector('select[data-key="random_ip"]').selectedIndex = random_ip_options.indexOf(edit_site.random_ip); }); } @@ -271,7 +273,8 @@ function renderOptions() { var add_options = { useragent: useragent_options, - referer: referer_options + referer: referer_options, + random_ip: random_ip_options }; for (let key in add_options) { labelEl = document.createElement('label'); @@ -312,6 +315,7 @@ function renderOptions() { (sites_custom[key]['block_regex'] ? ' | block regex' : '') + (sites_custom[key]['useragent'] ? ' | useragent: ' + sites_custom[key]['useragent'] : '') + (sites_custom[key]['referer'] ? ' | referer: ' + sites_custom[key]['referer'] : '') + + (sites_custom[key]['random_ip'] ? ' | random_ip: ' + sites_custom[key]['random_ip'] : '') + (sites_custom[key]['amp_unhide'] > 0 ? ' | amp_unhide' : ''); optionEl.value = key; selectEl.add(optionEl); diff --git a/sites.js b/sites.js index c5c89f3..5a2c4ef 100755 --- a/sites.js +++ b/sites.js @@ -404,7 +404,8 @@ var defaultSites = { }, "Esprit": { domain: "esprit.presse.fr", - allow_cookies: 1 + allow_cookies: 1, + random_ip: "all" }, "EUobserver": { domain: "euobserver.com", @@ -1048,7 +1049,8 @@ var defaultSites = { "National Geographic USA": { domain: "nationalgeographic.com", allow_cookies: 1, - block_regex: /\.blueconic\.net\// + block_regex: /\.blueconic\.net\//, + random_ip: "eu" }, "National Post": { domain: "nationalpost.com",