This commit is contained in:
gorhill 2015-02-04 09:03:34 -05:00
parent c7edec0d68
commit 77133b58c6
5 changed files with 18 additions and 20 deletions

View File

@ -151,6 +151,10 @@
"message":"3rd-party frames are <b>blocked<\/b> everywhere by default", "message":"3rd-party frames are <b>blocked<\/b> everywhere by default",
"description":"" "description":""
}, },
"popupAnyRulePrompt":{
"message":"all",
"description":""
},
"popupImageRulePrompt":{ "popupImageRulePrompt":{
"message":"images", "message":"images",
"description":"" "description":""

View File

@ -39,7 +39,6 @@ var Matrix = function() {
/******************************************************************************/ /******************************************************************************/
var supportedDynamicTypes = { var supportedDynamicTypes = {
'*': true,
'inline-script': true, 'inline-script': true,
'1p-script': true, '1p-script': true,
'3p-script': true, '3p-script': true,
@ -243,21 +242,15 @@ Matrix.prototype.evaluateCellZ = function(srcHostname, desHostname, type) {
Matrix.prototype.evaluateCellZY = function(srcHostname, desHostname, type) { Matrix.prototype.evaluateCellZY = function(srcHostname, desHostname, type) {
this.r = 0; this.r = 0;
this.type = '*';
// Specific-destination + any type // Specific-destination + any type
this.y = desHostname; this.type = '*';
this.r = this.evaluateCellZ(srcHostname, desHostname, '*');
if ( this.r !== 0 ) { return this; }
var d = desHostname; var d = desHostname;
for (;;) { while ( d !== '*' ) {
d = toBroaderHostname(d);
if ( d === '*' ) {
break;
}
this.y = d; this.y = d;
this.r = this.evaluateCellZ(srcHostname, d, '*'); this.r = this.evaluateCellZ(srcHostname, d, '*');
if ( this.r !== 0 ) { return this; } if ( this.r !== 0 ) { return this; }
d = toBroaderHostname(d);
} }
// Any destination + specific-type // Any destination + specific-type

View File

@ -145,6 +145,7 @@ var getHostnameDict = function(hostnameToCountMap) {
var getDynamicFilterRules = function(srcHostname, desHostnames) { var getDynamicFilterRules = function(srcHostname, desHostnames) {
var r = {}; var r = {};
var dFiltering = µb.dynamicNetFilteringEngine; var dFiltering = µb.dynamicNetFilteringEngine;
r['/ * *'] = dFiltering.evaluateCellZY('*', '*', '*').toFilterString();
r['/ * image'] = dFiltering.evaluateCellZY('*', '*', 'image').toFilterString(); r['/ * image'] = dFiltering.evaluateCellZY('*', '*', 'image').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();
@ -154,6 +155,7 @@ var getDynamicFilterRules = function(srcHostname, desHostnames) {
return r; return r;
} }
r['. * *'] = dFiltering.evaluateCellZY(srcHostname, '*', '*').toFilterString();
r['. * image'] = dFiltering.evaluateCellZY(srcHostname, '*', 'image').toFilterString(); r['. * image'] = dFiltering.evaluateCellZY(srcHostname, '*', 'image').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();

View File

@ -33,7 +33,7 @@ var popupData;
var dfPaneBuilt = false; var dfPaneBuilt = false;
var popupHeight; var popupHeight;
var reIP = /^\d+(?:\.\d+){1,3}$/; var reIP = /^\d+(?:\.\d+){1,3}$/;
var reSrcHostnameFromRule = /^d[abn]:([^ ]+) ([^ ]+)/; var reSrcHostnameFromRule = /^d[abn]:([^ ]+) ([^ ]+) ([^ ]+)/;
var scopeToSrcHostnameMap = { var scopeToSrcHostnameMap = {
'/': '*', '/': '*',
'.': '' '.': ''
@ -200,12 +200,13 @@ 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] === des &&
matches[1] === scopeToSrcHostnameMap[scope]; matches[3] === type &&
matches[1] === scopeToSrcHostnameMap[scope];
} }
cell.toggleClass('ownRule', ownRule); cell.toggleClass('ownRule', ownRule);
if ( scope !== '.' || type !== '*' ) { if ( scope !== '.' || des === '*' ) {
return; return;
} }
if ( popupData.hostnameDict.hasOwnProperty(des) === false ) { if ( popupData.hostnameDict.hasOwnProperty(des) === false ) {
@ -269,12 +270,9 @@ var buildAllDynamicFilters = function() {
var key, des; var key, des;
for ( var i = 0; i < keys.length; i++ ) { for ( var i = 0; i < keys.length; i++ ) {
key = keys[i]; key = keys[i];
// Specific-type rules -- these are built-in
if ( key.slice(-1) !== '*' ) {
continue;
}
des = key.slice(2, key.indexOf(' ', 2)); des = key.slice(2, key.indexOf(' ', 2));
if ( desHostnameDone.hasOwnProperty(des) ) { // Specific-type rules -- these are built-in
if ( des === '*' || desHostnameDone.hasOwnProperty(des) ) {
continue; continue;
} }
addDynamicFilterRow(des); addDynamicFilterRow(des);

View File

@ -26,12 +26,13 @@
<div id="refresh" class="fa">&#xf021;</div> <div id="refresh" class="fa">&#xf021;</div>
</div><!-- DO NOT REMOVE --><div> </div><!-- DO NOT REMOVE --><div>
<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="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="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>
<div><span data-i18n="popup3pFrameRulePrompt"></span><span data-src="/" data-des="*" data-type="3p-frame"> </span><span data-src="." data-des="*" data-type="3p-frame"> </span></div> <div><span data-i18n="popup3pFrameRulePrompt"></span><span data-src="/" data-des="*" data-type="3p-frame"> </span><span data-src="." data-des="*" data-type="3p-frame"> </span></div>
<div id="privacyInfo"></div> <div id="privacyInfo" style="display: none;"></div>
</div> </div>
</div> </div>
</div> </div>