LEFT | RIGHT |
1 // We are currently limited to ECMAScript 5 in this file, because it is being | 1 // We are currently limited to ECMAScript 5 in this file, because it is being |
2 // used in the browser tests. See https://issues.adblockplus.org/ticket/4796 | 2 // used in the browser tests. See https://issues.adblockplus.org/ticket/4796 |
3 | 3 |
4 var propertySelectorRegExp = /\[\-abp\-properties=(["'])([^"']+)\1\]/; | 4 var propertySelectorRegExp = /\[\-abp\-properties=(["'])([^"']+)\1\]/; |
5 | 5 |
6 function splitSelector(selector) | 6 function splitSelector(selector) |
7 { | 7 { |
8 if (selector.indexOf(",") == -1) | 8 if (selector.indexOf(",") == -1) |
9 return [selector]; | 9 return [selector]; |
10 | 10 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 if (!rules) | 87 if (!rules) |
88 return; | 88 return; |
89 | 89 |
90 for (var i = 0; i < rules.length; i++) | 90 for (var i = 0; i < rules.length; i++) |
91 { | 91 { |
92 var rule = rules[i]; | 92 var rule = rules[i]; |
93 if (rule.type != rule.STYLE_RULE) | 93 if (rule.type != rule.STYLE_RULE) |
94 continue; | 94 continue; |
95 | 95 |
96 var style = this.stringifyStyle(rule.style); | 96 var style = this.stringifyStyle(rule.style); |
97 this.patterns.forEach(function(pattern) { | 97 for (var j = 0; j < this.patterns.length; j++) |
| 98 { |
| 99 var pattern = this.patterns[j]; |
98 if (pattern.regexp.test(style)) | 100 if (pattern.regexp.test(style)) |
99 { | 101 { |
100 var subSelectors = splitSelector(rule.selectorText); | 102 var subSelectors = splitSelector(rule.selectorText); |
101 subSelectors.forEach(function(subSelector) { | 103 for (var k = 0; k < subSelectors.length; k++) |
| 104 { |
| 105 var subSelector = subSelectors[k]; |
102 selectors.push(pattern.prefix + subSelector + pattern.suffix); | 106 selectors.push(pattern.prefix + subSelector + pattern.suffix); |
103 filters.push(pattern.text); | 107 filters.push(pattern.text); |
104 }); | 108 } |
105 } | 109 } |
106 }); | 110 } |
107 } | 111 } |
108 }, | 112 }, |
109 | 113 |
110 addSelectors: function(stylesheets) | 114 addSelectors: function(stylesheets) |
111 { | 115 { |
112 var selectors = []; | 116 var selectors = []; |
113 var filters = []; | 117 var filters = []; |
114 for (var i = 0; i < stylesheets.length; i++) | 118 for (var i = 0; i < stylesheets.length; i++) |
115 this.findSelectors(stylesheets[i], selectors, filters); | 119 this.findSelectors(stylesheets[i], selectors, filters); |
116 this.addSelectorsFunc(selectors, filters); | 120 this.addSelectorsFunc(selectors, filters); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 | 158 |
155 if (this.patterns.length > 0) | 159 if (this.patterns.length > 0) |
156 { | 160 { |
157 var document = this.window.document; | 161 var document = this.window.document; |
158 this.addSelectors(document.styleSheets); | 162 this.addSelectors(document.styleSheets); |
159 document.addEventListener("load", this.onLoad.bind(this), true); | 163 document.addEventListener("load", this.onLoad.bind(this), true); |
160 } | 164 } |
161 }.bind(this)); | 165 }.bind(this)); |
162 } | 166 } |
163 }; | 167 }; |
LEFT | RIGHT |