Index: lib/elemHide.js |
=================================================================== |
--- a/lib/elemHide.js |
+++ b/lib/elemHide.js |
@@ -26,17 +26,17 @@ var {IO} = require("io"); |
var {Prefs} = require("prefs"); |
var {ElemHideException} = require("filterClasses"); |
var {FilterNotifier} = require("filterNotifier"); |
/** |
* Lookup table, filters by their associated key |
* @type Object |
*/ |
-var filterByKey = Object.create(null); |
+var filterByKey = []; |
/** |
* Lookup table, keys of the filters by filter text |
* @type Object |
*/ |
var keyByFilter = Object.create(null); |
/** |
@@ -111,17 +111,17 @@ var ElemHide = exports.ElemHide = |
styleURL = Services.io.newFileURI(styleFile).QueryInterface(Ci.nsIFileURL); |
}, |
/** |
* Removes all known filters |
*/ |
clear: function() |
{ |
- filterByKey = Object.create(null); |
+ filterByKey = []; |
keyByFilter = Object.create(null); |
filtersByDomain = Object.create(null); |
knownExceptions = Object.create(null); |
exceptions = Object.create(null); |
ElemHide.isDirty = false; |
ElemHide.unapply(); |
}, |
@@ -142,22 +142,17 @@ var ElemHide = exports.ElemHide = |
exceptions[selector].push(filter); |
knownExceptions[filter.text] = true; |
} |
else |
{ |
if (filter.text in keyByFilter) |
return; |
- let key; |
- do { |
- key = Math.random().toFixed(15).substr(5); |
- } while (key in filterByKey); |
- |
- filterByKey[key] = filter; |
+ let key = filterByKey.push(filter) - 1; |
keyByFilter[filter.text] = key; |
if (usingFiltersByDomain) |
{ |
let domains = filter.domains || defaultDomains; |
for (let domain in domains) |
{ |
let filters = filtersByDomain[domain]; |
@@ -329,27 +324,31 @@ var ElemHide = exports.ElemHide = |
_generateCSSContent: function*() |
{ |
// Grouping selectors by domains |
let domains = Object.create(null); |
let hasFilters = false; |
for (let key in filterByKey) |
{ |
let filter = filterByKey[key]; |
+ let selector = filter.selector; |
+ if (!selector) |
+ continue; |
+ |
let domain = filter.selectorDomain || ""; |
let list; |
if (domain in domains) |
list = domains[domain]; |
else |
{ |
list = Object.create(null); |
domains[domain] = list; |
} |
- list[filter.selector] = key; |
+ list[selector] = key; |
hasFilters = true; |
} |
if (!hasFilters) |
throw Cr.NS_ERROR_NOT_AVAILABLE; |
function escapeChar(match) |
{ |