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