Update block general paywall script (config sites.js)

merge-requests/10/head
magnolia1234 2 years ago
parent e605b32de4
commit 196ba07745

@ -65,6 +65,8 @@ var change_headers;
// block paywall-scripts individually // block paywall-scripts individually
var blockedRegexes = {}; var blockedRegexes = {};
var blockedRegexesDomains = [];
var blockedRegexesGeneral = {};
// unhide text on amp-page // unhide text on amp-page
var amp_unhide; var amp_unhide;
@ -101,6 +103,8 @@ function initSetRules() {
block_js_custom = []; block_js_custom = [];
block_js_custom_ext = []; block_js_custom_ext = [];
blockedRegexes = {}; blockedRegexes = {};
blockedRegexesDomains = [];
blockedRegexesGeneral = {};
init_custom_domains(); init_custom_domains();
} }
@ -236,6 +240,11 @@ function set_rules(sites, sites_updated, sites_custom) {
} }
} }
} }
if (rule.hasOwnProperty('block_regex_general')) {
if (rule.block_regex_general instanceof RegExp)
blockedRegexesGeneral[domain] = {block_regex: rule.block_regex_general};
blockedRegexesGeneral[domain]['excluded_domains'] = rule.excluded_domains ? rule.excluded_domains : [];
}
if (rule.useragent) { if (rule.useragent) {
switch (rule.useragent) { switch (rule.useragent) {
case 'googlebot': case 'googlebot':
@ -294,9 +303,9 @@ function set_rules(sites, sites_updated, sites_custom) {
} }
} }
} }
blockedRegexesDomains = Object.keys(blockedRegexes);
use_random_ip = Object.keys(random_ip); 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); change_headers = use_google_bot.concat(use_bing_bot, use_facebook_referer, use_google_referer, use_twitter_referer, use_random_ip);
disableJavascriptOnListedSites();
} }
// add grouped sites to en/disabledSites (and exclude sites) // add grouped sites to en/disabledSites (and exclude sites)
@ -481,9 +490,6 @@ ext_api.storage.onChanged.addListener(function (changes, namespace) {
if (key === 'optInUpdate') { if (key === 'optInUpdate') {
optin_update = storageChange.newValue; optin_update = storageChange.newValue;
} }
// reset disableJavascriptOnListedSites eventListener
ext_api.webRequest.onBeforeRequest.removeListener(disableJavascriptOnListedSites);
ext_api.webRequest.handlerBehaviorChanged();
// Refresh the current tab // Refresh the current tab
refreshCurrentTab(); refreshCurrentTab();
@ -684,58 +690,6 @@ ext_api.webRequest.onHeadersReceived.addListener(function (details) {
}, },
['blocking', 'responseHeaders']); ['blocking', 'responseHeaders']);
var block_js = [
"*://*.blueconic.net/*",
"*://*.cxense.com/*",
"*://*.ensighten.com/*/Bootstrap.js*",
"*://*.evolok.net/*",
"*://*.newsmemory.com/?meter*",
"*://*.onecount.net/*",
"*://*.piano.io/*",
"*://*.poool.fr/*",
"*://*.qiota.com/*",
"*://*.tribdss.com/*",
"*://*.weborama.fr/*",
"*://*.zephr.com/zephr-browser/*",
"*://*/*/ev-widgets.min.js*",
"*://*/c/assets/pigeon.js*",
"*://*/wp-content/*/ev-em.min.js*",
"*://*/zephr/features*",
"*://api.pico.tools/*",
"*://cdn.ampproject.org/v*/amp-access-*.*js",
"*://cdn.ampproject.org/v*/amp-subscriptions-*.*js",
"*://cdn.ampproject.org/v*/amp*-ad-*.*js",
"*://cdn.ampproject.org/v*/amp-analytics-*.*js",
"*://cdn.ampproject.org/v*/amp-fx-flying-carpet-*.*js",
"*://cdn.tinypass.com/*",
"*://js.matheranalytics.com/*",
"*://js.pelcro.com/*",
"*://loader-cdn.azureedge.net/prod/*/loader.min.js*",
"*://olytics.omeda.com/*",
];
// Disable javascript for these sites/general paywall-scripts
function disableJavascriptOnListedSites() {
ext_api.webRequest.onBeforeRequest.addListener(function (details) {
let header_referer = details.originUrl ? details.originUrl : details.initiator;
if (!(isSiteEnabled(details)
|| (['script', 'xmlhttprequest'].includes(details.type)
&& ((enabledSites.includes('###_wp_evolok') && details.url.match(/\/(wp-content\/.+\/ev-em|evolok\/.+\/ev-widgets)\.min\.js/))
|| (enabledSites.includes('###_wp_pigeon') && details.url.includes('/c/assets/pigeon.js'))
|| (enabledSites.includes('zephr.com') && details.url.includes('/zephr/features')))))
|| matchUrlDomain(excludedSites.concat(disabledSites, ['asia.nikkei.com', 'businesspost.ie', 'cambridge.org', 'japantimes.co.jp']), header_referer)) {
return;
}
return {
cancel: true
};
}, {
urls: block_js,
types: ["script", "xmlhttprequest"]
},
["blocking"]);
}
if (typeof browser !== 'object') { if (typeof browser !== 'object') {
var focus_changed = false; var focus_changed = false;
ext_api.windows.onFocusChanged.addListener((windowId) => { ext_api.windows.onFocusChanged.addListener((windowId) => {
@ -792,6 +746,7 @@ ext_api.webRequest.onBeforeSendHeaders.addListener(function(details) {
if ((typeof custom_block_regex === 'string') && custom_block_regex.includes('{domain}')) if ((typeof custom_block_regex === 'string') && custom_block_regex.includes('{domain}'))
custom_block_regex = new RegExp(custom_block_regex.replace('{domain}', custom_domain.replace(/\./g, '\\.'))); custom_block_regex = new RegExp(custom_block_regex.replace('{domain}', custom_domain.replace(/\./g, '\\.')));
blockedRegexes[custom_domain] = custom_block_regex; blockedRegexes[custom_domain] = custom_block_regex;
blockedRegexesDomains = Object.keys(blockedRegexes);
} }
if (custom_useragent) { if (custom_useragent) {
if (custom_useragent === 'googlebot') { if (custom_useragent === 'googlebot') {
@ -956,16 +911,26 @@ ext_api.webRequest.onBeforeSendHeaders.addListener(function(details) {
} // not in excludedSites } // not in excludedSites
// block external javascript for custom sites (optional) // block external javascript for custom sites (optional)
var domain_blockjs_ext = matchUrlDomain(block_js_custom_ext, header_referer); if (['script'].includes(details.type)) {
if (domain_blockjs_ext && !matchUrlDomain(domain_blockjs_ext, details.url) && details.type === 'script' && isSiteEnabled({url: header_referer})) { let domain_blockjs_ext = matchUrlDomain(block_js_custom_ext, header_referer);
return { cancel: true }; if (domain_blockjs_ext && !matchUrlDomain(domain_blockjs_ext, details.url) && isSiteEnabled({url: header_referer}))
return { cancel: true };
} }
// check for blocked regular expression: domain enabled, match regex, block on an internal or external regex // check for blocked regular expression: domain enabled, match regex, block on an internal or external regex
var blockedDomains = Object.keys(blockedRegexes); if (['script', 'xmlhttprequest'].includes(details.type)) {
var domain = matchUrlDomain(blockedDomains, header_referer); let domain = matchUrlDomain(blockedRegexesDomains, header_referer);
if (domain && details.url.match(blockedRegexes[domain]) && isSiteEnabled({url: header_referer})) if (domain && details.url.match(blockedRegexes[domain]) && isSiteEnabled({url: header_referer}))
return { cancel: true }; return { cancel: true };
}
// block general paywall scripts
if (['script', 'xmlhttprequest'].includes(details.type)) {
for (let domain in blockedRegexesGeneral) {
if (details.url.match(blockedRegexesGeneral[domain].block_regex) && !(matchUrlDomain(excludedSites.concat(blockedRegexesGeneral[domain].excluded_domains), header_referer)))
return { cancel: true };
}
}
// load toggleIcon.js (icon for dark or incognito mode in Chrome)) // load toggleIcon.js (icon for dark or incognito mode in Chrome))
if (typeof browser !== 'object' && ['main_frame', 'xmlhttprequest'].includes(details.type)) { if (typeof browser !== 'object' && ['main_frame', 'xmlhttprequest'].includes(details.type)) {

@ -3,7 +3,7 @@ Changelog Bypass Paywalls Clean - Firefox
Post-release Post-release
Add Mediapart.fr Add Mediapart.fr
Update block general paywall script (fix Zephr-local) Update block general paywall script (fix Zephr-local & config sites.js)
* v2.9.1.0 (2022-10-30) * v2.9.1.0 (2022-10-30)
Add 4 more NHST Media Group sites Add 4 more NHST Media Group sites

@ -730,5 +730,5 @@
"*://gcm.omerlocdn.com/*", "*://gcm.omerlocdn.com/*",
"*://webcache.googleusercontent.com/*" "*://webcache.googleusercontent.com/*"
], ],
"version": "2.9.1.2" "version": "2.9.1.3"
} }

@ -1129,7 +1129,7 @@ var defaultSites = {
"LiveMint": { "LiveMint": {
domain: "livemint.com", domain: "livemint.com",
allow_cookies: 1, allow_cookies: 1,
block_regex: /(\.livemint\.com\/__js\/lm_subscription_.+\.js|\.piano\.io\/api\/tinypass\.min\.js|cdn\.ampproject\.org\/v\d\/amp-access-.+\.js)/ block_regex: /(\.livemint\.com\/__js\/lm_subscription|\.piano\.io\/api\/tinypass\.min\.js|cdn\.ampproject\.org\/v\d\/amp-access-.+\.js)/
}, },
"Loeb Classical Library": { "Loeb Classical Library": {
domain: "loebclassics.com" domain: "loebclassics.com"
@ -1225,7 +1225,7 @@ var defaultSites = {
"twincities.com" "twincities.com"
], ],
allow_cookies: 1, allow_cookies: 1,
block_regex: /(\.blueconic\.net\/|\.tinypass\.com\/|\.com\/.+\/loader-wp\/.+\/loader\.min\.js|cdn\.ampproject\.org\/v\d\/amp-subscriptions-.+\.js)/ block_regex: /(\.blueconic\.net\/|\.tinypass\.com\/|\/loader-wp\/.+\/loader\.min\.js|cdn\.ampproject\.org\/v\d\/amp-subscriptions-.+\.js)/
}, },
"Mediapart.fr": { "Mediapart.fr": {
domain: "mediapart.fr", domain: "mediapart.fr",
@ -1835,7 +1835,7 @@ var defaultSites = {
"The Indian Express": { "The Indian Express": {
domain: "indianexpress.com", domain: "indianexpress.com",
allow_cookies: 1, allow_cookies: 1,
block_regex: /(\/indianexpress\.com\/.+\/indianexpress\/js\/(evolok\/.+|min\/premiumContent)\.js|cdn\.ampproject\.org\/v\d\/amp-access-.+\.js)/ block_regex: /(\/indianexpress\.com\/.+\/(evolok\/.+|premiumContent)\.js|cdn\.ampproject\.org\/v\d\/amp-access-.+\.js)/
}, },
"The Intercept": { "The Intercept": {
domain: "theintercept.com", domain: "theintercept.com",
@ -2050,7 +2050,7 @@ var defaultSites = {
"UOL.com.br": { "UOL.com.br": {
domain: "uol.com.br", domain: "uol.com.br",
allow_cookies: 1, allow_cookies: 1,
block_regex: /(\.folha\.uol\.com\.br\/paywall\/js\/|paywall\.folha\.uol\.com\.br\/|\.tinypass\.com|js\.matheranalytics\.com\/|cdn\.ampproject\.org\/v\d\/amp-subscriptions-.+\.js)/, block_regex: /(paywall\.folha\.uol\.com\.br\/|\.(tinypass|matheranalytics)\.com\/|cdn\.ampproject\.org\/v\d\/amp-subscriptions-.+\.js)/,
useragent: "googlebot" useragent: "googlebot"
}, },
"USA Today": { "USA Today": {
@ -2121,70 +2121,115 @@ var defaultSites = {
domain: "###" domain: "###"
}, },
"Amp-access": { "Amp-access": {
domain: "cdn.ampproject.org" domain: "cdn.ampproject.org",
allow_cookies: 1,
block_regex_general: /cdn\.ampproject\.org\/.+\/amp-(access|ad|analytics|fx-flying-carpet|subscriptions)-.+\.(m)?js/,
excluded_domains: ["cambridge.org"]
}, },
"AzureEdge": { "AzureEdge": {
domain: "loader-cdn.azureedge.net" domain: "loader-cdn.azureedge.net",
allow_cookies: 1,
block_regex_general: /loader-cdn\.azureedge\.net\//
}, },
"BlueConic": { "BlueConic": {
domain: "blueconic.net" domain: "blueconic.net",
allow_cookies: 1,
block_regex_general: /\.blueconic\.net\//
}, },
"Cxense": { "Cxense": {
domain: "cxense.com" domain: "cxense.com",
allow_cookies: 1,
block_regex_general: /cdn\.cxense\.com\//
}, },
"Ensighten": { "Ensighten": {
domain: "ensighten.com" domain: "ensighten.com",
allow_cookies: 1,
block_regex_general: /\.ensighten\.com\/.+\/Bootstrap\.js/
}, },
"Evolok": { "Evolok": {
domain: "evolok.net" domain: "evolok.net",
allow_cookies: 1,
block_regex_general: /\.evolok\.net\//
}, },
"Evolok WordPress": { "Evolok WordPress": {
domain: "###_wp_evolok" domain: "###_wp_evolok",
allow_cookies: 1,
block_regex_general: /\/(wp-content\/.+\/ev-em|evolok\/.+\/ev-widgets)\.min\.js/
}, },
"Leaky Paywall (WordPress plugin)": { "Leaky Paywall (WordPress plugin)": {
domain: "###_wp_leaky_paywall" domain: "###_wp_leaky_paywall",
allow_cookies: 1,
}, },
"MatherAnalytics": { "MatherAnalytics": {
domain: "matheranalytics.com" domain: "matheranalytics.com",
allow_cookies: 1,
block_regex_general: /js\.matheranalytics.com\//
}, },
"NewsMemory": { "NewsMemory": {
domain: "newsmemory.com" domain: "newsmemory.com",
allow_cookies: 1,
block_regex_general: /\.newsmemory\.com\/\?meter/
}, },
"Omeda Olytics": { "Omeda Olytics": {
domain: "omeda.com" domain: "omeda.com",
allow_cookies: 1,
block_regex_general: /olytics\.omeda\.com\//
}, },
"OneCount": { "OneCount": {
domain: "onecount.net" domain: "onecount.net",
allow_cookies: 1,
block_regex_general: /\.onecount\.net\//
}, },
"Pelcro": { "Pelcro": {
domain: "pelcro.com" domain: "pelcro.com",
allow_cookies: 1,
block_regex_general: /js\.pelcro\.com\//
}, },
"Piano.io": { "Piano.io": {
domain: "piano.io" domain: "piano.io",
allow_cookies: 1,
block_regex_general: /\.piano\.io\//,
excluded_domains: ["asia.nikkei.com", "businesspost.ie", "japantimes.co.jp"]
}, },
"Pico.tools": { "Pico.tools": {
domain: "pico.tools" domain: "pico.tools",
allow_cookies: 1,
block_regex_general: /api\.pico.tools\//
}, },
"Pigeon (WordPress plugin)": { "Pigeon (WordPress plugin)": {
domain: "###_wp_pigeon" domain: "###_wp_pigeon",
allow_cookies: 1,
block_regex_general: /\/c\/assets\/pigeon\.js/
}, },
"Poool.fr": { "Poool.fr": {
domain: "poool.fr" domain: "poool.fr",
allow_cookies: 1,
block_regex_general: /\.blueconic\.net\//
}, },
"Qiota": { "Qiota": {
domain: "qiota.com" domain: "qiota.com",
allow_cookies: 1,
block_regex_general: /\.qiota\.com\//
}, },
"TinyPass": { "TinyPass": {
domain: "tinypass.com" domain: "tinypass.com",
allow_cookies: 1,
block_regex_general: /cdn\.tinypass\.com\//
}, },
"TribDss": { "TribDss": {
domain: "tribdss.com" domain: "tribdss.com",
allow_cookies: 1,
block_regex_general: /\.tribdss\.com\//
}, },
"Weborama.fr": { "Weborama.fr": {
domain: "weborama.fr" domain: "weborama.fr",
allow_cookies: 1,
block_regex_general: /\.weborama\.fr\//
}, },
"Zephr": { "Zephr": {
domain: "zephr.com" domain: "zephr.com",
allow_cookies: 1,
block_regex_general: /(\.zephr\.com\/zephr-browser\/|\/zephr\/features)/
}, },
"* BPC settings": { "* BPC settings": {
domain: "###" domain: "###"

Loading…
Cancel
Save