mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-24 03:12:46 +01:00
This commit is contained in:
parent
0a55c3fb20
commit
6013880472
@ -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,
|
||||
|
@ -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);
|
||||
});
|
||||
|
||||
/******************************************************************************/
|
||||
|
@ -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');
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user