mirror of
https://github.com/gorhill/uBlock.git
synced 2024-09-04 10:09:38 +02:00
this fixes #690
This commit is contained in:
parent
c4ee65b8cf
commit
9c2277fccf
@ -159,6 +159,10 @@
|
||||
"message":"images",
|
||||
"description":""
|
||||
},
|
||||
"popup3pAnyRulePrompt":{
|
||||
"message":"3rd-party",
|
||||
"description":""
|
||||
},
|
||||
"popupInlineScriptRulePrompt":{
|
||||
"message":"inline scripts",
|
||||
"description":""
|
||||
|
@ -85,7 +85,7 @@ p {
|
||||
#switch .fa {
|
||||
color: green;
|
||||
cursor: pointer;
|
||||
font-size: 96px;
|
||||
font-size: 108px;
|
||||
margin: 0;
|
||||
}
|
||||
#switch .fa:hover {
|
||||
@ -195,8 +195,8 @@ body.dirty #refresh:hover {
|
||||
-moz-box-sizing: border-box;
|
||||
color: #000;
|
||||
display: inline-block;
|
||||
height: 24px;
|
||||
line-height: 24px;
|
||||
height: 22px;
|
||||
line-height: 22px;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
vertical-align: top;
|
||||
@ -261,7 +261,7 @@ body.dirty #refresh:hover {
|
||||
}
|
||||
#actionSelector > span {
|
||||
display: inline-block;
|
||||
height: 24px;
|
||||
height: 22px;
|
||||
opacity: 0.2;
|
||||
width: 33.33%;
|
||||
}
|
||||
|
@ -39,11 +39,12 @@ var Matrix = function() {
|
||||
/******************************************************************************/
|
||||
|
||||
var supportedDynamicTypes = {
|
||||
'3p': true,
|
||||
'image': true,
|
||||
'inline-script': true,
|
||||
'1p-script': true,
|
||||
'3p-script': true,
|
||||
'3p-frame': true,
|
||||
'image': true
|
||||
'3p-frame': true
|
||||
};
|
||||
|
||||
var typeBitOffsets = {
|
||||
@ -53,7 +54,7 @@ var typeBitOffsets = {
|
||||
'3p-script': 6,
|
||||
'3p-frame': 8,
|
||||
'image': 10,
|
||||
'3p-any': 12
|
||||
'3p': 12
|
||||
};
|
||||
|
||||
var actionToNameMap = {
|
||||
@ -200,6 +201,9 @@ Matrix.prototype.clearRegisters = function() {
|
||||
/******************************************************************************/
|
||||
|
||||
var is3rdParty = function(srcHostname, desHostname) {
|
||||
if ( desHostname === '*' ) {
|
||||
return false;
|
||||
}
|
||||
var srcDomain = domainFromHostname(srcHostname);
|
||||
if ( srcDomain === '' ) {
|
||||
srcDomain = desHostname;
|
||||
@ -217,6 +221,7 @@ var domainFromHostname = µBlock.URI.domainFromHostname;
|
||||
/******************************************************************************/
|
||||
|
||||
Matrix.prototype.evaluateCellZ = function(srcHostname, desHostname, type) {
|
||||
this.type = type;
|
||||
var bitOffset = typeBitOffsets[type];
|
||||
var s = srcHostname;
|
||||
var v;
|
||||
@ -226,6 +231,7 @@ Matrix.prototype.evaluateCellZ = function(srcHostname, desHostname, type) {
|
||||
if ( v !== undefined ) {
|
||||
v = v >> bitOffset & 3;
|
||||
if ( v !== 0 ) {
|
||||
this.r = v;
|
||||
return v;
|
||||
}
|
||||
}
|
||||
@ -235,44 +241,51 @@ Matrix.prototype.evaluateCellZ = function(srcHostname, desHostname, type) {
|
||||
}
|
||||
}
|
||||
// srcHostname is '*' at this point
|
||||
this.r = 0;
|
||||
return 0;
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
Matrix.prototype.evaluateCellZY = function(srcHostname, desHostname, type) {
|
||||
this.r = 0;
|
||||
// Precedence: from most specific to least specific
|
||||
|
||||
// Specific-destination + any type
|
||||
this.type = '*';
|
||||
// Specific-destination, any party, any type
|
||||
var d = desHostname;
|
||||
while ( d !== '*' ) {
|
||||
this.y = d;
|
||||
this.r = this.evaluateCellZ(srcHostname, d, '*');
|
||||
if ( this.r !== 0 ) { return this; }
|
||||
if ( this.evaluateCellZ(srcHostname, d, '*') !== 0 ) { return this; }
|
||||
d = toBroaderHostname(d);
|
||||
}
|
||||
|
||||
// Any destination + specific-type
|
||||
var thirdParty = is3rdParty(srcHostname, desHostname);
|
||||
|
||||
// Any destination
|
||||
this.y = '*';
|
||||
|
||||
if ( type === 'script' ) {
|
||||
type = is3rdParty(srcHostname, desHostname) ? '3p-script' : '1p-script';
|
||||
} else if ( type === 'sub_frame' && is3rdParty(srcHostname, desHostname) ) {
|
||||
type = '3p-frame';
|
||||
}
|
||||
// Is this a type suitable for dynamic filtering purpose?
|
||||
if ( supportedDynamicTypes.hasOwnProperty(type) ) {
|
||||
this.type = type;
|
||||
this.r = this.evaluateCellZ(srcHostname, '*', type);
|
||||
if ( this.r !== 0 ) { return this; }
|
||||
// Specific party
|
||||
if ( thirdParty ) {
|
||||
// 3rd-party, specific type
|
||||
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; }
|
||||
}
|
||||
// 3rd-party, any type
|
||||
if ( this.evaluateCellZ(srcHostname, '*', '3p') !== 0 ) { return this; }
|
||||
|
||||
} else if ( type === 'script' ) {
|
||||
// 1st party, specific type
|
||||
if ( this.evaluateCellZ(srcHostname, '*', '1p-script') !== 0 ) { return this; }
|
||||
}
|
||||
|
||||
// https://github.com/gorhill/uBlock/issues/682
|
||||
// Any destination, any type
|
||||
this.type = '*';
|
||||
this.r = this.evaluateCellZ(srcHostname, '*', '*');
|
||||
if ( this.r !== 0 ) { return this; }
|
||||
// Any destination, any party, specific type
|
||||
if ( supportedDynamicTypes.hasOwnProperty(type) ) {
|
||||
if ( this.evaluateCellZ(srcHostname, '*', type) !== 0 ) { return this; }
|
||||
}
|
||||
|
||||
// Any destination, any party, any type
|
||||
if ( this.evaluateCellZ(srcHostname, '*', '*') !== 0 ) { return this; }
|
||||
|
||||
this.type = '';
|
||||
return this;
|
||||
|
@ -147,6 +147,7 @@ var getDynamicFilterRules = function(srcHostname, desHostnames) {
|
||||
var dFiltering = µb.dynamicNetFilteringEngine;
|
||||
r['/ * *'] = dFiltering.evaluateCellZY('*', '*', '*').toFilterString();
|
||||
r['/ * image'] = dFiltering.evaluateCellZY('*', '*', 'image').toFilterString();
|
||||
r['/ * 3p'] = dFiltering.evaluateCellZY('*', '*', '3p').toFilterString();
|
||||
r['/ * inline-script'] = dFiltering.evaluateCellZY('*', '*', 'inline-script').toFilterString();
|
||||
r['/ * 1p-script'] = dFiltering.evaluateCellZY('*', '*', '1p-script').toFilterString();
|
||||
r['/ * 3p-script'] = dFiltering.evaluateCellZY('*', '*', '3p-script').toFilterString();
|
||||
@ -157,6 +158,7 @@ var getDynamicFilterRules = function(srcHostname, desHostnames) {
|
||||
|
||||
r['. * *'] = dFiltering.evaluateCellZY(srcHostname, '*', '*').toFilterString();
|
||||
r['. * image'] = dFiltering.evaluateCellZY(srcHostname, '*', 'image').toFilterString();
|
||||
r['. * 3p'] = dFiltering.evaluateCellZY(srcHostname, '*', '3p').toFilterString();
|
||||
r['. * inline-script'] = dFiltering.evaluateCellZY(srcHostname, '*', 'inline-script').toFilterString();
|
||||
r['. * 1p-script'] = dFiltering.evaluateCellZY(srcHostname, '*', '1p-script').toFilterString();
|
||||
r['. * 3p-script'] = dFiltering.evaluateCellZY(srcHostname, '*', '3p-script').toFilterString();
|
||||
|
@ -200,9 +200,9 @@ var updateDynamicFilterCell = function(scope, des, type, rule) {
|
||||
var ownRule = false;
|
||||
var matches = reSrcHostnameFromRule.exec(rule);
|
||||
if ( matches !== null ) {
|
||||
ownRule = matches[2] === des &&
|
||||
matches[3] === type &&
|
||||
matches[1] === scopeToSrcHostnameMap[scope];
|
||||
ownRule = (matches[2] !== '*' || matches[3] === type) &&
|
||||
(matches[2] === des) &&
|
||||
(matches[1] === scopeToSrcHostnameMap[scope]);
|
||||
}
|
||||
cell.toggleClass('ownRule', ownRule);
|
||||
|
||||
|
@ -28,6 +28,7 @@
|
||||
<div id="dynamicFilteringContainer">
|
||||
<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="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
Block a user