Index: lib/filterListener.js |
diff --git a/lib/filterListener.js b/lib/filterListener.js |
index d56e82545b8fa0562ffa1681a5273c51e737837d..1d4dfe133d6c94e04d46243c2d324f463752783e 100644 |
--- a/lib/filterListener.js |
+++ b/lib/filterListener.js |
@@ -15,12 +15,13 @@ |
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
*/ |
+"use strict"; |
+ |
/** |
- * @fileOverview Component synchronizing filter storage with Matcher instances and ElemHide. |
+ * @fileOverview Component synchronizing filter storage with Matcher |
+ * instances and ElemHide. |
*/ |
-"use strict"; |
- |
Cu.import("resource://gre/modules/XPCOMUtils.jsm"); |
Cu.import("resource://gre/modules/Services.jsm"); |
@@ -35,7 +36,7 @@ let {Prefs} = require("prefs"); |
/** |
* Increases on filter changes, filters will be saved if it exceeds 1. |
- * @type Integer |
+ * @type {number} |
*/ |
let isDirty = 0; |
@@ -43,15 +44,16 @@ let isDirty = 0; |
* This object can be used to change properties of the filter change listeners. |
* @class |
*/ |
-let FilterListener = |
-{ |
+let FilterListener = { |
/** |
- * Increases "dirty factor" of the filters and calls FilterStorage.saveToDisk() |
- * if it becomes 1 or more. Save is executed delayed to prevent multiple |
- * subsequent calls. If the parameter is 0 it forces saving filters if any |
- * changes were recorded after the previous save. |
+ * Increases "dirty factor" of the filters and calls |
+ * FilterStorage.saveToDisk() if it becomes 1 or more. Save is |
+ * executed delayed to prevent multiple subsequent calls. If the |
+ * parameter is 0 it forces saving filters if any changes were |
+ * recorded after the previous save. |
+ * @param {number} factor |
*/ |
- setDirty: function(/**Integer*/ factor) |
+ setDirty(factor) |
{ |
if (factor == 0 && isDirty > 0) |
isDirty = 1; |
@@ -69,11 +71,11 @@ let FilterListener = |
* Observer listening to history purge actions. |
* @class |
*/ |
-let HistoryPurgeObserver = |
-{ |
- observe: function(subject, topic, data) |
+let HistoryPurgeObserver = { |
+ observe(subject, topic, data) |
{ |
- if (topic == "browser:purge-session-history" && Prefs.clearStatsOnHistoryPurge) |
+ if (topic == "browser:purge-session-history" && |
+ Prefs.clearStatsOnHistoryPurge) |
{ |
FilterStorage.resetHitCounts(); |
FilterListener.setDirty(0); // Force saving to disk |
@@ -81,7 +83,9 @@ let HistoryPurgeObserver = |
Prefs.recentReports = []; |
} |
}, |
- QueryInterface: XPCOMUtils.generateQI([Ci.nsISupportsWeakReference, Ci.nsIObserver]) |
+ QueryInterface: XPCOMUtils.generateQI( |
+ [Ci.nsISupportsWeakReference, Ci.nsIObserver] |
+ ) |
}; |
/** |
@@ -113,10 +117,12 @@ function init() |
FilterStorage.loadFromDisk(); |
- Services.obs.addObserver(HistoryPurgeObserver, "browser:purge-session-history", true); |
- onShutdown.add(function() |
+ Services.obs.addObserver(HistoryPurgeObserver, |
+ "browser:purge-session-history", true); |
+ onShutdown.add(() => |
{ |
- Services.obs.removeObserver(HistoryPurgeObserver, "browser:purge-session-history"); |
+ Services.obs.removeObserver(HistoryPurgeObserver, |
+ "browser:purge-session-history"); |
}); |
} |
init(); |
@@ -133,8 +139,10 @@ function addFilter(filter) |
let hasEnabled = false; |
for (let i = 0; i < filter.subscriptions.length; i++) |
+ { |
if (!filter.subscriptions[i].disabled) |
hasEnabled = true; |
+ } |
if (!hasEnabled) |
return; |
@@ -163,8 +171,10 @@ function removeFilter(filter) |
{ |
let hasEnabled = false; |
for (let i = 0; i < filter.subscriptions.length; i++) |
+ { |
if (!filter.subscriptions[i].disabled) |
hasEnabled = true; |
+ } |
if (hasEnabled) |
return; |
} |
@@ -197,9 +207,8 @@ function addFilters(filters) |
let current = (Math.random() * len) | 0; |
let step; |
do |
- { |
step = primes[(Math.random() * primes.length) | 0]; |
- } while (len % step == 0); |
+ while (len % step == 0); |
for (let i = 0; i < len; i++, current = (current + step) % len) |
addFilter(filters[current]); |
@@ -298,8 +307,10 @@ function onLoad() |
ElemHide.clear(); |
ElemHideEmulation.clear(); |
for (let subscription of FilterStorage.subscriptions) |
+ { |
if (!subscription.disabled) |
addFilters(subscription.filters); |
+ } |
} |
function onSave() |