Index: chrome/content/elemHideEmulation.js |
diff --git a/chrome/content/elemHideEmulation.js b/chrome/content/elemHideEmulation.js |
index 95a4c5d4ba314ce0c5697c626e52e62edbde574c..901a2d3b42b20c2cc3a7832c5e0e9f61826fdb7a 100644 |
--- a/chrome/content/elemHideEmulation.js |
+++ b/chrome/content/elemHideEmulation.js |
@@ -73,33 +73,38 @@ ElemHideEmulation.prototype = { |
} |
}, |
- findSelectors: function(stylesheet, selectors, filters) |
+ findSelectors: function(stylesheet, filters) |
{ |
// Explicitly ignore third-party stylesheets to ensure consistent behavior |
// between Firefox and Chrome. |
if (!this.isSameOrigin(stylesheet)) |
return; |
- var rules = stylesheet.cssRules; |
+ let rules = stylesheet.cssRules; |
if (!rules) |
return; |
- for (var i = 0; i < rules.length; i++) |
+ for (let rule of rules) |
{ |
- var rule = rules[i]; |
if (rule.type != rule.STYLE_RULE) |
continue; |
- var style = this.stringifyStyle(rule.style); |
- for (var j = 0; j < this.patterns.length; j++) |
+ let style = this.stringifyStyle(rule.style); |
+ |
+ for (let pattern of this.patterns) |
{ |
- var pattern = this.patterns[j]; |
if (pattern.regexp.test(style)) |
{ |
- var subSelectors = splitSelector(rule.selectorText); |
- for (var k = 0; k < subSelectors.length; k++) |
- selectors.push(pattern.prefix + subSelectors[k] + pattern.suffix); |
- filters[pattern.text] = true; |
+ let selectors = filters.get(pattern.text); |
+ if (!selectors) |
+ { |
+ selectors = []; |
+ filters.set(pattern.text, selectors); |
+ } |
+ |
+ let subSelectors = splitSelector(rule.selectorText); |
Sebastian Noack
2017/02/07 14:55:53
The temporary variable is no longer necessary, as
wspee
2017/02/07 15:01:06
Done.
|
+ for (let subSelector of subSelectors) |
+ selectors.push(pattern.prefix + subSelector + pattern.suffix); |
} |
} |
} |
@@ -107,11 +112,10 @@ ElemHideEmulation.prototype = { |
addSelectors: function(stylesheets) |
{ |
- var selectors = []; |
- var filters = {}; |
- for (var i = 0; i < stylesheets.length; i++) |
- this.findSelectors(stylesheets[i], selectors, filters); |
- this.addSelectorsFunc(selectors, Object.keys(filters)); |
+ var filters = new Map(); |
Sebastian Noack
2017/02/07 14:55:53
While you took the liberty to convert var-statemen
wspee
2017/02/07 15:01:06
Done.
|
+ for (let stylesheet of stylesheets) |
+ this.findSelectors(stylesheet, filters); |
+ this.addSelectorsFunc(filters); |
}, |
onLoad: function(event) |