aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/js/hnswitches.js9
-rw-r--r--src/js/ublock.js10
2 files changed, 10 insertions, 9 deletions
diff --git a/src/js/hnswitches.js b/src/js/hnswitches.js
index 1ca46b3..392cda0 100644
--- a/src/js/hnswitches.js
+++ b/src/js/hnswitches.js
@@ -196,6 +196,15 @@ HnSwitches.prototype.toggleBranchZ = function(switchName, targetHostname, newSta
/******************************************************************************/
+HnSwitches.prototype.toggleZ = function(switchName, hostname, deep, newState) {
+ if ( deep === true ) {
+ return this.hnSwitches.toggleBranchZ(switchName, hostname, newState);
+ }
+ return this.hnSwitches.toggleOneZ(switchName, hostname, newState);
+};
+
+/******************************************************************************/
+
// 0 = inherit from broader scope, up to default state
// 1 = non-default state
// 2 = forced default state (to override a broader non-default state)
diff --git a/src/js/ublock.js b/src/js/ublock.js
index 329724e..e1b259e 100644
--- a/src/js/ublock.js
+++ b/src/js/ublock.js
@@ -319,15 +319,7 @@ var matchWhitelistDirective = function(url, hostname, directive) {
/******************************************************************************/
µBlock.toggleHostnameSwitch = function(details) {
- var changed = false;
-
- if ( details.deep === true ) {
- changed = this.hnSwitches.toggleBranchZ(details.name, details.hostname, details.state);
- } else {
- changed = this.hnSwitches.toggleOneZ(details.name, details.hostname, details.state);
- }
-
- if ( changed ) {
+ if ( this.hnSwitches.toggleZ(details.name, details.hostname, !!details.deep, details.state) ) {
this.saveHostnameSwitches();
}