gorhill 2015-02-11 15:48:39 -05:00
parent 0a55c3fb20
commit 6013880472
3 changed files with 26 additions and 12 deletions

View File

@ -282,7 +282,7 @@ var onMessage = function(request, sender, callback) {
response = lastModified !== request.contentLastModified;
break;
case 'saveRules':
case 'saveFirewallRules':
µb.permanentFirewall.copyRules(
µb.sessionFirewall,
request.srcHostname,

View File

@ -491,7 +491,7 @@ var mouseleaveCellHandler = function() {
/******************************************************************************/
var setFirewallRule = function(src, des, type, action) {
var setFirewallRule = function(src, des, type, action, persist) {
// This can happen on pages where uBlock does not work
if ( typeof popupData.pageHostname !== 'string' || popupData.pageHostname === '' ) {
return;
@ -508,26 +508,28 @@ var setFirewallRule = function(src, des, type, action) {
srcHostname: src,
desHostname: des,
requestType: type,
action: action
action: action,
persist: persist
}, onFirewallRuleChanged);
};
/******************************************************************************/
var unsetFirewallRuleHandler = function() {
var unsetFirewallRuleHandler = function(ev) {
var cell = uDom(this);
setFirewallRule(
cell.attr('data-src') === '/' ? '*' : popupData.pageHostname,
cell.attr('data-des'),
cell.attr('data-type'),
0
0,
ev.ctrlKey || ev.metaKey
);
dfHotspots.appendTo(cell);
};
/******************************************************************************/
var setFirewallRuleHandler = function() {
var setFirewallRuleHandler = function(ev) {
var hotspot = uDom(this);
var cell = hotspot.ancestors('[data-src]');
if ( cell.length === 0 ) {
@ -546,7 +548,8 @@ var setFirewallRuleHandler = function() {
cell.attr('data-src') === '/' ? '*' : popupData.pageHostname,
cell.attr('data-des'),
cell.attr('data-type'),
action
action,
ev.ctrlKey || ev.metaKey
);
dfHotspots.detach();
};
@ -569,10 +572,11 @@ var reloadTab = function() {
/******************************************************************************/
var saveRules = function() {
messager.send({ what: 'saveRules',
'srcHostname': popupData.pageHostname,
'desHostnames': popupData.hostnameDict
var saveFirewallRules = function() {
messager.send({
what: 'saveFirewallRules',
srcHostname: popupData.pageHostname,
desHostnames: popupData.hostnameDict
});
uDom('#firewallContainer').removeClass('dirty');
};
@ -653,7 +657,7 @@ uDom.onLoad(function() {
uDom('a[href]').on('click', gotoURL);
uDom('h2').on('click', toggleFirewallPane);
uDom('#refresh').on('click', reloadTab);
uDom('#saveRules').on('click', saveRules);
uDom('#saveRules').on('click', saveFirewallRules);
});
/******************************************************************************/

View File

@ -288,6 +288,16 @@ var matchWhitelistDirective = function(url, hostname, directive) {
this.sessionFirewall.unsetCell(details.srcHostname, details.desHostname, details.requestType);
}
// https://github.com/gorhill/uBlock/issues/731#issuecomment-73937469
if ( details.persist ) {
if ( details.action !== 0 ) {
this.permanentFirewall.setCellZ(details.srcHostname, details.desHostname, details.requestType, details.action);
} else {
this.permanentFirewall.unsetCell(details.srcHostname, details.desHostname, details.requestType, details.action);
}
this.savePermanentFirewallRules();
}
// https://github.com/gorhill/uBlock/issues/420
this.cosmeticFilteringEngine.removeFromSelectorCache(details.srcHostname, 'net');
};