Index: chrome/content/elemHideEmulation.js |
diff --git a/chrome/content/elemHideEmulation.js b/chrome/content/elemHideEmulation.js |
index 95a4c5d4ba314ce0c5697c626e52e62edbde574c..3e000229a29b1c49a6a5067e045728656c4b416c 100644 |
--- a/chrome/content/elemHideEmulation.js |
+++ b/chrome/content/elemHideEmulation.js |
@@ -73,33 +73,37 @@ 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); |
+ |
Sebastian Noack
2017/02/07 15:37:57
Nit: The blank line added here is unrelated at lea
wspee
2017/02/09 08:40:34
Done.
|
+ 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); |
+ } |
+ |
+ for (let subSelector of splitSelector(rule.selectorText)) |
+ selectors.push(pattern.prefix + subSelector + pattern.suffix); |
} |
} |
} |
@@ -107,11 +111,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)); |
+ let filters = new Map(); |
+ for (let stylesheet of stylesheets) |
+ this.findSelectors(stylesheet, filters); |
+ this.addSelectorsFunc(filters); |
Sebastian Noack
2017/02/07 15:37:57
I just realized, the implications for when this fu
Sebastian Noack
2017/02/07 15:59:56
Another advantage of this approach is, that the AP
Sebastian Noack
2017/02/08 07:12:29
Perhaps even better, just use two arrays (instead
wspee
2017/02/09 08:40:34
Done.
|
}, |
onLoad: function(event) |