Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2017 eyeo GmbH | 3 * Copyright (C) 2006-2017 eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
301 let selectors = []; | 301 let selectors = []; |
302 if (match.index > 0) | 302 if (match.index > 0) |
303 selectors.push(new PlainSelector(selector.substr(0, match.index))); | 303 selectors.push(new PlainSelector(selector.substr(0, match.index))); |
304 | 304 |
305 let startIndex = match.index + match[0].length; | 305 let startIndex = match.index + match[0].length; |
306 let content = parseSelectorContent(selector, startIndex); | 306 let content = parseSelectorContent(selector, startIndex); |
307 if (!content) | 307 if (!content) |
308 { | 308 { |
309 this.window.console.error( | 309 this.window.console.error( |
310 new SyntaxError("Failed to parse Adblock Plus " + | 310 new SyntaxError("Failed to parse Adblock Plus " + |
311 `selector ${selector}, ` + | 311 `selector ${selector} ` + |
Wladimir Palant
2017/06/19 11:22:37
Nit: There should be no comma here, I vaguely reme
hub
2017/06/19 13:24:42
Done.
| |
312 "due to unmatched parentheses.")); | 312 "due to unmatched parentheses.")); |
313 return null; | 313 return null; |
314 } | 314 } |
315 if (match[1] == "properties") | 315 if (match[1] == "properties") |
316 selectors.push(new PropsSelector(content.text)); | 316 selectors.push(new PropsSelector(content.text)); |
317 else if (match[1] == "has") | 317 else if (match[1] == "has") |
318 { | 318 { |
319 let hasSelectors = this.parseSelector(content.text); | 319 let hasSelectors = this.parseSelector(content.text); |
320 if (hasSelectors == null) | 320 if (hasSelectors == null) |
321 return null; | 321 return null; |
322 let hasSelector = new HasSelector(hasSelectors); | 322 selectors.push(new HasSelector(hasSelectors)); |
323 selectors.push(hasSelector); | |
Wladimir Palant
2017/06/19 11:22:37
Nit: The temporary hasSelector variable no longer
hub
2017/06/19 13:24:42
Done.
| |
324 } | 323 } |
325 else | 324 else |
326 { | 325 { |
327 // this is an error, can't parse selector. | 326 // this is an error, can't parse selector. |
328 this.window.console.error( | 327 this.window.console.error( |
329 new SyntaxError("Failed to parse Adblock Plus " + | 328 new SyntaxError("Failed to parse Adblock Plus " + |
330 `selector ${selector}, invalid ` + | 329 `selector ${selector}, invalid ` + |
331 `pseudo-class :-abp-${match[1]}().`)); | 330 `pseudo-class :-abp-${match[1]}().`)); |
332 return null; | 331 return null; |
333 } | 332 } |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
418 | 417 |
419 if (this.patterns.length > 0) | 418 if (this.patterns.length > 0) |
420 { | 419 { |
421 let {document} = this.window; | 420 let {document} = this.window; |
422 this.addSelectors(document.styleSheets); | 421 this.addSelectors(document.styleSheets); |
423 document.addEventListener("load", this.onLoad.bind(this), true); | 422 document.addEventListener("load", this.onLoad.bind(this), true); |
424 } | 423 } |
425 }); | 424 }); |
426 } | 425 } |
427 }; | 426 }; |
LEFT | RIGHT |