Left: | ||
Right: |
OLD | NEW |
---|---|
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
42 else if (sep == "") | 42 else if (sep == "") |
43 { | 43 { |
44 if (chr == '"' || chr == "'") | 44 if (chr == '"' || chr == "'") |
45 sep = chr; | 45 sep = chr; |
46 else if (chr == "(") // don't split between parentheses | 46 else if (chr == "(") // don't split between parentheses |
47 level++; // e.g. :matches(div,span) | 47 level++; // e.g. :matches(div,span) |
48 else if (chr == ")") | 48 else if (chr == ")") |
49 level = Math.max(0, level - 1); | 49 level = Math.max(0, level - 1); |
50 else if (chr == "," && level == 0) | 50 else if (chr == "," && level == 0) |
51 { | 51 { |
52 selectors.push(selector.substring(start, i)); | 52 selectors.push(selector.substring(start, i).trim()); |
53 start = i + 1; | 53 start = i + 1; |
54 } | 54 } |
55 } | 55 } |
56 } | 56 } |
57 | 57 |
58 selectors.push(selector.substring(start)); | 58 selectors.push(selector.substring(start).trim()); |
59 return selectors; | 59 return selectors; |
60 } | 60 } |
61 | 61 |
62 /** Return position of node from parent. | 62 /** Return position of node from parent. |
63 * @param {Node} node the node to find the position of. | 63 * @param {Node} node the node to find the position of. |
64 * @return {number} One-based index like for :nth-child(), or 0 on error. | 64 * @return {number} One-based index like for :nth-child(), or 0 on error. |
65 */ | 65 */ |
66 function positionInParent(node) | 66 function positionInParent(node) |
67 { | 67 { |
68 let {children} = node.parentNode; | 68 let {children} = node.parentNode; |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
266 regexpString = filterToRegExp(propertyExpression); | 266 regexpString = filterToRegExp(propertyExpression); |
267 | 267 |
268 this._regexp = new RegExp(regexpString, "i"); | 268 this._regexp = new RegExp(regexpString, "i"); |
269 } | 269 } |
270 | 270 |
271 PropsSelector.prototype = { | 271 PropsSelector.prototype = { |
272 preferHideWithSelector: true, | 272 preferHideWithSelector: true, |
273 | 273 |
274 *findPropsSelectors(styles, prefix, regexp) | 274 *findPropsSelectors(styles, prefix, regexp) |
275 { | 275 { |
276 let actualPrefix = (prefix && !incompletePrefixRegexp.test(prefix)) ? | |
277 prefix + " " : prefix; | |
Wladimir Palant
2017/08/16 08:37:02
No, this is not what we want. Consider .abp-testsu
hub
2017/08/16 19:50:32
Acknowledged.
| |
276 for (let style of styles) | 278 for (let style of styles) |
277 if (regexp.test(style.style)) | 279 if (regexp.test(style.style)) |
278 for (let subSelector of style.subSelectors) | 280 for (let subSelector of style.subSelectors) |
279 yield prefix + subSelector; | 281 { |
282 if (subSelector == "*") | |
283 subSelector = ""; | |
Wladimir Palant
2017/08/16 08:37:02
What if we have a filter like `:-abp-properties(fo
hub
2017/08/16 19:50:32
Done.
| |
284 yield actualPrefix + subSelector; | |
285 } | |
280 }, | 286 }, |
281 | 287 |
282 *getSelectors(prefix, subtree, styles) | 288 *getSelectors(prefix, subtree, styles) |
283 { | 289 { |
284 for (let selector of this.findPropsSelectors(styles, prefix, this._regexp)) | 290 for (let selector of this.findPropsSelectors(styles, prefix, this._regexp)) |
285 yield [selector, subtree]; | 291 yield [selector, subtree]; |
286 } | 292 } |
287 }; | 293 }; |
288 | 294 |
289 function ElemHideEmulation(window, getFiltersFunc, addSelectorsFunc, | 295 function ElemHideEmulation(window, getFiltersFunc, addSelectorsFunc, |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
456 | 462 |
457 if (this.patterns.length > 0) | 463 if (this.patterns.length > 0) |
458 { | 464 { |
459 let {document} = this.window; | 465 let {document} = this.window; |
460 this.addSelectors(document.styleSheets); | 466 this.addSelectors(document.styleSheets); |
461 document.addEventListener("load", this.onLoad.bind(this), true); | 467 document.addEventListener("load", this.onLoad.bind(this), true); |
462 } | 468 } |
463 }); | 469 }); |
464 } | 470 } |
465 }; | 471 }; |
OLD | NEW |