mirror of https://github.com/gorhill/uBlock.git
new dynamic rule type: "3p-passive", for css/images
This commit is contained in:
parent
c1e54d33b2
commit
35106dcd90
|
@ -103,6 +103,10 @@
|
|||
"message":"3rd-party",
|
||||
"description":""
|
||||
},
|
||||
"popup3pPassiveRulePrompt":{
|
||||
"message":"3rd-party css/images",
|
||||
"description":""
|
||||
},
|
||||
"popupInlineScriptRulePrompt":{
|
||||
"message":"inline scripts",
|
||||
"description":""
|
||||
|
|
|
@ -46,7 +46,8 @@ var supportedDynamicTypes = {
|
|||
'inline-script': true,
|
||||
'1p-script': true,
|
||||
'3p-script': true,
|
||||
'3p-frame': true
|
||||
'3p-frame': true,
|
||||
'3p-passive': true
|
||||
};
|
||||
|
||||
var typeBitOffsets = {
|
||||
|
@ -56,7 +57,8 @@ var typeBitOffsets = {
|
|||
'3p-script': 6,
|
||||
'3p-frame': 8,
|
||||
'image': 10,
|
||||
'3p': 12
|
||||
'3p': 12,
|
||||
'3p-passive': 14
|
||||
};
|
||||
|
||||
var actionToNameMap = {
|
||||
|
@ -386,7 +388,9 @@ Matrix.prototype.evaluateCellZY = function(srcHostname, desHostname, type) {
|
|||
// Specific party
|
||||
if ( thirdParty ) {
|
||||
// 3rd-party, specific type
|
||||
if ( type === 'script' ) {
|
||||
if ( type === 'image' || type === 'stylesheet' ) {
|
||||
if ( this.evaluateCellZ(srcHostname, '*', '3p-passive') !== 0 ) { return this; }
|
||||
} else if ( type === 'script' ) {
|
||||
if ( this.evaluateCellZ(srcHostname, '*', '3p-script') !== 0 ) { return this; }
|
||||
} else if ( type === 'sub_frame' ) {
|
||||
if ( this.evaluateCellZ(srcHostname, '*', '3p-frame') !== 0 ) { return this; }
|
||||
|
@ -588,51 +592,6 @@ Matrix.prototype.fromString = function(text, append) {
|
|||
|
||||
/******************************************************************************/
|
||||
|
||||
Matrix.prototype.fromObsoleteSelfie = function(selfie) {
|
||||
if ( selfie === '' ) {
|
||||
return '';
|
||||
}
|
||||
var bin = {};
|
||||
try {
|
||||
bin = JSON.parse(selfie);
|
||||
} catch(e) {
|
||||
}
|
||||
var filters = bin.filters;
|
||||
var bits, val;
|
||||
for ( var hostname in filters ) {
|
||||
if ( filters.hasOwnProperty(hostname) === false ) {
|
||||
continue;
|
||||
}
|
||||
bits = filters[hostname];
|
||||
val = bits & 3;
|
||||
if ( val === 1 ) {
|
||||
this.setCell(hostname, '*', 'inline-script', 1);
|
||||
} else if ( val === 2 ) {
|
||||
this.setCell(hostname, '*', 'inline-script', 3);
|
||||
}
|
||||
val = (bits >> 2) & 3;
|
||||
if ( val === 1 ) {
|
||||
this.setCell(hostname, '*', '1p-script', 1);
|
||||
} else if ( val === 2 ) {
|
||||
this.setCell(hostname, '*', '1p-script', 3);
|
||||
}
|
||||
val = (bits >> 4) & 3;
|
||||
if ( val === 1 ) {
|
||||
this.setCell(hostname, '*', '3p-script', 1);
|
||||
} else if ( val === 2 ) {
|
||||
this.setCell(hostname, '*', '3p-script', 3);
|
||||
}
|
||||
val = (bits >> 8) & 3;
|
||||
if ( val === 1 ) {
|
||||
this.setCell(hostname, '*', '3p-frame', 1);
|
||||
} else if ( val === 2 ) {
|
||||
this.setCell(hostname, '*', '3p-frame', 3);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
Matrix.prototype.toSelfie = function() {
|
||||
return {
|
||||
magicId: magicId,
|
||||
|
|
|
@ -245,6 +245,7 @@ var getFirewallRules = function(srcHostname, desHostnames) {
|
|||
r['/ * *'] = df.evaluateCellZY('*', '*', '*').toFilterString();
|
||||
r['/ * image'] = df.evaluateCellZY('*', '*', 'image').toFilterString();
|
||||
r['/ * 3p'] = df.evaluateCellZY('*', '*', '3p').toFilterString();
|
||||
r['/ * 3p-passive'] = df.evaluateCellZY('*', '*', '3p-passive').toFilterString();
|
||||
r['/ * inline-script'] = df.evaluateCellZY('*', '*', 'inline-script').toFilterString();
|
||||
r['/ * 1p-script'] = df.evaluateCellZY('*', '*', '1p-script').toFilterString();
|
||||
r['/ * 3p-script'] = df.evaluateCellZY('*', '*', '3p-script').toFilterString();
|
||||
|
@ -256,6 +257,7 @@ var getFirewallRules = function(srcHostname, desHostnames) {
|
|||
r['. * *'] = df.evaluateCellZY(srcHostname, '*', '*').toFilterString();
|
||||
r['. * image'] = df.evaluateCellZY(srcHostname, '*', 'image').toFilterString();
|
||||
r['. * 3p'] = df.evaluateCellZY(srcHostname, '*', '3p').toFilterString();
|
||||
r['. * 3p-passive'] = df.evaluateCellZY(srcHostname, '*', '3p-passive').toFilterString();
|
||||
r['. * inline-script'] = df.evaluateCellZY(srcHostname, '*', 'inline-script').toFilterString();
|
||||
r['. * 1p-script'] = df.evaluateCellZY(srcHostname, '*', '1p-script').toFilterString();
|
||||
r['. * 3p-script'] = df.evaluateCellZY(srcHostname, '*', '3p-script').toFilterString();
|
||||
|
|
|
@ -321,7 +321,7 @@ var buildAllFirewallRows = function() {
|
|||
|
||||
// Remove and reuse all rows: the order may have changed, we can't just
|
||||
// reuse them in-place.
|
||||
rowsToRecycle = uDom('#firewallContainer > div:nth-of-type(7) ~ div').detach();
|
||||
rowsToRecycle = uDom('#firewallContainer > div:nth-of-type(8) ~ div').detach();
|
||||
|
||||
var n = allHostnameRows.length;
|
||||
for ( var i = 0; i < n; i++ ) {
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
<div><span data-i18n="popupAnyRulePrompt"></span><span data-src="/" data-des="*" data-type="*"> </span><span data-src="." data-des="*" data-type="*"> </span></div>
|
||||
<div><span data-i18n="popupImageRulePrompt"></span><span data-src="/" data-des="*" data-type="image"> </span><span data-src="." data-des="*" data-type="image"> </span></div>
|
||||
<div><span data-i18n="popup3pAnyRulePrompt"></span><span data-src="/" data-des="*" data-type="3p"> </span><span data-src="." data-des="*" data-type="3p"> </span></div>
|
||||
<div><span data-i18n="popup3pPassiveRulePrompt"></span><span data-src="/" data-des="*" data-type="3p-passive"> </span><span data-src="." data-des="*" data-type="3p-passive"> </span></div>
|
||||
<div><span data-i18n="popupInlineScriptRulePrompt"></span><span data-src="/" data-des="*" data-type="inline-script"> </span><span data-src="." data-des="*" data-type="inline-script"> </span></div>
|
||||
<div><span data-i18n="popup1pScriptRulePrompt"></span><span data-src="/" data-des="*" data-type="1p-script"> </span><span data-src="." data-des="*" data-type="1p-script"> </span></div>
|
||||
<div><span data-i18n="popup3pScriptRulePrompt"></span><span data-src="/" data-des="*" data-type="3p-script"> </span><span data-src="." data-des="*" data-type="3p-script"> </span></div>
|
||||
|
|
Loading…
Reference in New Issue