Update block inline script (config sites.js)

merge-requests/10/head
magnolia1234 2 years ago
parent 73ccdf5fc4
commit 460022559f

@ -63,10 +63,12 @@ var use_random_ip = [];
// concat all sites with change of headers (useragent, referer or random ip)
var change_headers;
// block paywall-scripts individually
// block paywall-scripts
var blockedRegexes = {};
var blockedRegexesDomains = [];
var blockedRegexesGeneral = {};
var blockedJsInline = {};
var blockedJsInlineDomains = [];
// unhide text on amp-page
var amp_unhide;
@ -105,6 +107,8 @@ function initSetRules() {
blockedRegexes = {};
blockedRegexesDomains = [];
blockedRegexesGeneral = {};
blockedJsInline = {};
blockedJsInlineDomains = [];
init_custom_domains();
}
@ -245,6 +249,10 @@ function set_rules(sites, sites_updated, sites_custom) {
blockedRegexesGeneral[domain] = {block_regex: rule.block_regex_general};
blockedRegexesGeneral[domain]['excluded_domains'] = rule.excluded_domains ? rule.excluded_domains : [];
}
if (rule.hasOwnProperty('block_js_inline')) {
if (rule.block_js_inline instanceof RegExp)
blockedJsInline[domain] = rule.block_js_inline;
}
if (rule.useragent) {
switch (rule.useragent) {
case 'googlebot':
@ -304,8 +312,10 @@ function set_rules(sites, sites_updated, sites_custom) {
}
}
blockedRegexesDomains = Object.keys(blockedRegexes);
blockedJsInlineDomains = Object.keys(blockedJsInline);
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);
disableJavascriptInline();
}
// add grouped sites to en/disabledSites (and exclude sites)
@ -664,31 +674,33 @@ ext_api.webRequest.onHeadersReceived.addListener(function (details) {
},
['blocking', 'responseHeaders']);
// block inline script
var block_js_inline = ["*://*.crusoe.uol.com.br/*", "*://*.elpais.com/*", "*://*.lavoz.com.ar/*", "*://*.nautil.us/*", "*://*.rugbypass.com/*", "*://*.theglobeandmail.com/*/article-*"];
if (block_js_inline.length)
ext_api.webRequest.onHeadersReceived.addListener(function (details) {
let url_path = details.url.split('?')[0];
let excluded = (matchUrlDomain('crusoe.uol.com.br', details.url) && (optin_setcookie || !url_path.match(/\.br\/(diario|edicoes)\/.+/)))
|| (matchUrlDomain('elpais.com', details.url) && (url_path.includes('/elpais.com') || !url_path.includes('.html')))
|| (matchUrlDomain('nautil.us', details.url) && !details.url.match(/((\w)+(\-)+){3,}/))
|| (matchUrlDomain('rugbypass.com', details.url) && !details.url.includes('.com/plus/'))
|| (matchUrlDomain('theglobeandmail.com', details.url) && !details.url.includes('?rel=premium'));
if (!isSiteEnabled(details) || excluded)
return;
var headers = details.responseHeaders;
headers.push({
'name': 'Content-Security-Policy',
'value': "script-src *;"
});
return {
responseHeaders: headers
};
}, {
'types': ['main_frame', 'sub_frame'],
'urls': block_js_inline
},
['blocking', 'responseHeaders']);
function disableJavascriptInline() {
// block inline script
var block_js_inline = [];
for (let domain in blockedJsInline)
block_js_inline.push("*://*." + domain + "/*");
if (block_js_inline.length)
ext_api.webRequest.onHeadersReceived.addListener(function (details) {
let domain = matchUrlDomain(blockedJsInlineDomains, details.url);
let matched = domain && details.url.match(blockedJsInline[domain]);
if (matched && optin_setcookie && ['uol.com.br'].includes(domain))
matched = false;
if (!isSiteEnabled(details) || !matched)
return;
var headers = details.responseHeaders;
headers.push({
'name': 'Content-Security-Policy',
'value': "script-src *;"
});
return {
responseHeaders: headers
};
}, {
'types': ['main_frame', 'sub_frame'],
'urls': block_js_inline
},
['blocking', 'responseHeaders']);
}
if (typeof browser !== 'object') {
var focus_changed = false;
@ -927,7 +939,7 @@ ext_api.webRequest.onBeforeSendHeaders.addListener(function(details) {
// 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)))
if (details.url.match(blockedRegexesGeneral[domain].block_regex) && !(matchUrlDomain(excludedSites.concat(disabledSites, blockedRegexesGeneral[domain].excluded_domains), header_referer)))
return { cancel: true };
}
}

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

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

@ -425,6 +425,7 @@ var defaultSites = {
"El País": {
domain: "elpais.com",
allow_cookies: 1,
block_js_inline: /\.elpais\.com\/.+\.html/,
block_regex: /(\/elpais\.com\/arc\/subs\/p\.min\.js|cdn\.ampproject\.org\/v\d\/amp-access-.+\.js)/
},
"El Periódico (de Catalunya)": {
@ -1052,7 +1053,8 @@ var defaultSites = {
},
"La Voz del Interior": {
domain: "lavoz.com.ar",
allow_cookies: 1
allow_cookies: 1,
block_js_inline: /\.lavoz\.com\.ar/
},
"Law.com (free articles only)": {
domain: "law.com",
@ -1289,7 +1291,8 @@ var defaultSites = {
},
"Nautilus": {
domain: "nautil.us",
allow_cookies: 1
allow_cookies: 1,
block_js_inline: /\/nautil\.us\/((\w)+(\-)+){3,}/
},
"Neue Osnabrücker Zeitung": {
domain: "noz.de",
@ -1554,6 +1557,7 @@ var defaultSites = {
"RugbyPass": {
domain: "rugbypass.com",
allow_cookies: 1,
block_js_inline: /\.rugbypass\.com\/plus\//,
block_regex: /\.tinypass\.com\//
},
"S&P Global": {
@ -1804,6 +1808,7 @@ var defaultSites = {
},
"The Globe and Mail": {
domain: "theglobeandmail.com",
block_js_inline: /\.theglobeandmail\.com\/.+\/article-.+\?rel=premium/,
block_regex: /smartwall\.theglobeandmail\.com\//
},
"The Hill": {
@ -2050,6 +2055,7 @@ var defaultSites = {
"UOL.com.br": {
domain: "uol.com.br",
allow_cookies: 1,
block_js_inline: /crusoe\.uol\.com\.br\/(diario|edicoes)\/.+/,
block_regex: /(paywall\.folha\.uol\.com\.br\/|\.(tinypass|matheranalytics)\.com\/|cdn\.ampproject\.org\/v\d\/amp-subscriptions-.+\.js)/,
useragent: "googlebot"
},

Loading…
Cancel
Save