Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 var propertySelectorRegExp = /\[\-abp\-properties=(["'])([^"']+)\1\]/; | |
2 | |
1 function splitSelector(selector) | 3 function splitSelector(selector) |
2 { | 4 { |
3 if (selector.indexOf(",") == -1) | 5 if (selector.indexOf(",") == -1) |
4 return [selector]; | 6 return [selector]; |
5 | 7 |
6 var selectors = []; | 8 var selectors = []; |
7 var start = 0; | 9 var start = 0; |
8 var level = 0; | 10 var level = 0; |
9 var sep = ""; | 11 var sep = ""; |
10 | 12 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
120 }, | 122 }, |
121 | 123 |
122 load: function(callback) | 124 load: function(callback) |
123 { | 125 { |
124 this.getFiltersFunc(function(patterns) | 126 this.getFiltersFunc(function(patterns) |
125 { | 127 { |
126 this.patterns = []; | 128 this.patterns = []; |
127 for (var i = 0; i < patterns.length; i++) | 129 for (var i = 0; i < patterns.length; i++) |
128 { | 130 { |
129 var pattern = patterns[i]; | 131 var pattern = patterns[i]; |
130 | |
131 // We currently don't support any element hiding emulation feature | |
132 // except for property selectors, so we remove rules that use other | |
133 // features. See https://issues.adblockplus.org/ticket/3143. | |
134 if (pattern.features != elemHideEmulationFeatureMap.PROPERTY_SELECTOR) | |
135 continue; | |
136 | |
137 var propertySelectorRegExp = /\[\-abp\-properties=(["'])([^"']+)\1\]/; | |
Wladimir Palant
2016/11/21 11:39:15
This regexp should be created outside the loop, id
Felix Dahlke
2016/11/21 14:38:59
Done.
| |
138 var match = propertySelectorRegExp.exec(pattern.selector); | 132 var match = propertySelectorRegExp.exec(pattern.selector); |
139 if (!match) | 133 if (!match) |
140 continue; | 134 continue; |
141 | 135 |
142 var propertyExpression = match[2]; | 136 var propertyExpression = match[2]; |
143 var regexpString; | 137 var regexpString; |
144 if (propertyExpression.length >= 2 && propertyExpression[0] == "/" && | 138 if (propertyExpression.length >= 2 && propertyExpression[0] == "/" && |
145 propertyExpression[propertyExpression.length - 1] == "/") | 139 propertyExpression[propertyExpression.length - 1] == "/") |
146 regexpString = propertyExpression.slice(1, -1); | 140 regexpString = propertyExpression.slice(1, -1); |
147 else | 141 else |
(...skipping 14 matching lines...) Expand all Loading... | |
162 apply: function() | 156 apply: function() |
163 { | 157 { |
164 if (this.patterns.length > 0) | 158 if (this.patterns.length > 0) |
165 { | 159 { |
166 var document = this.window.document; | 160 var document = this.window.document; |
167 this.addSelectors(document.styleSheets); | 161 this.addSelectors(document.styleSheets); |
168 document.addEventListener("load", this.onLoad.bind(this), true); | 162 document.addEventListener("load", this.onLoad.bind(this), true); |
169 } | 163 } |
170 } | 164 } |
171 }; | 165 }; |
LEFT | RIGHT |