aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/_locales/en/messages.json4
-rw-r--r--src/css/popup.css8
-rw-r--r--src/js/dynamic-net-filtering.js57
-rw-r--r--src/js/messaging.js2
-rw-r--r--src/js/popup.js6
-rw-r--r--src/popup.html1
6 files changed, 49 insertions, 29 deletions
diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json
index 84666bc..31547b9 100644
--- a/src/_locales/en/messages.json
+++ b/src/_locales/en/messages.json
@@ -159,6 +159,10 @@
"message":"images",
"description":""
},
+ "popup3pAnyRulePrompt":{
+ "message":"3rd-party",
+ "description":""
+ },
"popupInlineScriptRulePrompt":{
"message":"inline scripts",
"description":""
diff --git a/src/css/popup.css b/src/css/popup.css
index 0a3a601..1af20e3 100644
--- a/src/css/popup.css
+++ b/src/css/popup.css
@@ -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%;
}
diff --git a/src/js/dynamic-net-filtering.js b/src/js/dynamic-net-filtering.js
index e776f8c..4ed0b45 100644
--- a/src/js/dynamic-net-filtering.js
+++ b/src/js/dynamic-net-filtering.js
@@ -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';
+ // 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; }
}
- // Is this a type suitable for dynamic filtering purpose?
+
+ // Any destination, any party, specific type
if ( supportedDynamicTypes.hasOwnProperty(type) ) {
- this.type = type;
- this.r = this.evaluateCellZ(srcHostname, '*', type);
- if ( this.r !== 0 ) { return this; }
+ if ( this.evaluateCellZ(srcHostname, '*', type) !== 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, any type
+ if ( this.evaluateCellZ(srcHostname, '*', '*') !== 0 ) { return this; }
this.type = '';
return this;
diff --git a/src/js/messaging.js b/src/js/messaging.js
index acb20f9..b80289d 100644
--- a/src/js/messaging.js
+++ b/src/js/messaging.js
@@ -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();
diff --git a/src/js/popup.js b/src/js/popup.js
index 6144b95..5e814d4 100644
--- a/src/js/popup.js
+++ b/src/js/popup.js
@@ -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);
diff --git a/src/popup.html b/src/popup.html
index 4aa4361..f134cd0 100644
--- a/src/popup.html
+++ b/src/popup.html
@@ -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>