aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorgorhill <rhill@raymondhill.net>2015-02-11 15:48:39 -0500
committergorhill <rhill@raymondhill.net>2015-02-11 15:48:39 -0500
commit050fee4d3d57fd9b42b749359051e97a8054317c (patch)
tree7d20ecd387c7639557050355a83c138a767d147d /src
parent0a55c3fb20a4f023516b907b3888a533dc5b996f (diff)
downloaduBlock-050fee4d3d57fd9b42b749359051e97a8054317c.zip
uBlock-050fee4d3d57fd9b42b749359051e97a8054317c.tar.gz
uBlock-050fee4d3d57fd9b42b749359051e97a8054317c.tar.bz2
https://github.com/gorhill/uBlock/issues/731#issuecomment-73956166
Diffstat (limited to 'src')
-rw-r--r--src/js/messaging.js2
-rw-r--r--src/js/popup.js26
-rw-r--r--src/js/ublock.js10
3 files changed, 26 insertions, 12 deletions
diff --git a/src/js/messaging.js b/src/js/messaging.js
index bd69e59..e3cbeb4 100644
--- a/src/js/messaging.js
+++ b/src/js/messaging.js
@@ -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,
diff --git a/src/js/popup.js b/src/js/popup.js
index 5c643e9..b680926 100644
--- a/src/js/popup.js
+++ b/src/js/popup.js
@@ -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);
});
/******************************************************************************/
diff --git a/src/js/ublock.js b/src/js/ublock.js
index 4ad8c78..6050ae4 100644
--- a/src/js/ublock.js
+++ b/src/js/ublock.js
@@ -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');
};