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 | 132 var match = propertySelectorRegExp.exec(pattern.selector); |
131 // We currently don't support any element hiding emulation feature | 133 if (!match) |
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) | |
kzar
2016/11/04 15:45:56
Before I suggested adding a supportedFeatures para
Felix Dahlke
2016/11/04 16:43:35
I'm not sure. For one, I feel that logic belongs i
| |
135 continue; | 134 continue; |
136 | 135 |
137 var propertySelectorRegExp = /\[\-abp\-properties=(["'])([^"']+)\1\]/; | 136 var propertyExpression = match[2]; |
138 var match = propertySelectorRegExp.exec(pattern.selector); | 137 var regexpString; |
kzar
2016/11/04 15:45:56
I guess the regexp won't necessarily match and if
Felix Dahlke
2016/11/04 16:43:35
Oops, true, I'll fix that.
Felix Dahlke
2016/11/11 11:51:42
Done.
| |
138 if (propertyExpression.length >= 2 && propertyExpression[0] == "/" && | |
139 propertyExpression[propertyExpression.length - 1] == "/") | |
140 regexpString = propertyExpression.slice(1, -1); | |
141 else | |
142 regexpString = filterToRegExp(propertyExpression); | |
143 | |
139 this.patterns.push({ | 144 this.patterns.push({ |
140 text: pattern.text, | 145 text: pattern.text, |
141 regexp: new RegExp(filterToRegExp(match[2])), | 146 regexp: new RegExp(regexpString, "i"), |
142 prefix: pattern.selector.substr(0, match.index), | 147 prefix: pattern.selector.substr(0, match.index), |
143 suffix: pattern.selector.substr(match.index + match[0].length) | 148 suffix: pattern.selector.substr(match.index + match[0].length) |
144 }); | 149 }); |
145 } | 150 } |
146 | 151 |
147 callback(); | 152 callback(); |
148 }.bind(this)); | 153 }.bind(this)); |
149 }, | 154 }, |
150 | 155 |
151 apply: function() | 156 apply: function() |
152 { | 157 { |
153 if (this.patterns.length > 0) | 158 if (this.patterns.length > 0) |
154 { | 159 { |
155 var document = this.window.document; | 160 var document = this.window.document; |
156 this.addSelectors(document.styleSheets); | 161 this.addSelectors(document.styleSheets); |
157 document.addEventListener("load", this.onLoad.bind(this), true); | 162 document.addEventListener("load", this.onLoad.bind(this), true); |
158 } | 163 } |
159 } | 164 } |
160 }; | 165 }; |
LEFT | RIGHT |