| 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-present eyeo GmbH | 3 * Copyright (C) 2006-present 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 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 | 421 |
| 422 *findPropsSelectors(styles, prefix, regexp) | 422 *findPropsSelectors(styles, prefix, regexp) |
| 423 { | 423 { |
| 424 for (let style of styles) | 424 for (let style of styles) |
| 425 if (regexp.test(style.style)) | 425 if (regexp.test(style.style)) |
| 426 for (let subSelector of style.subSelectors) | 426 for (let subSelector of style.subSelectors) |
| 427 { | 427 { |
| 428 if (subSelector.startsWith("*") && | 428 if (subSelector.startsWith("*") && |
| 429 !incompletePrefixRegexp.test(prefix)) | 429 !incompletePrefixRegexp.test(prefix)) |
| 430 { | 430 { |
| 431 subSelector = subSelector.substr(1); | 431 subSelector = subSelector.substring(1); |
| 432 } | 432 } |
| 433 let idx = subSelector.lastIndexOf("::"); | 433 let idx = subSelector.lastIndexOf("::"); |
| 434 if (idx != -1) | 434 if (idx != -1) |
| 435 subSelector = subSelector.substr(0, idx); | 435 subSelector = subSelector.substring(0, idx); |
| 436 yield qualifySelector(subSelector, prefix); | 436 yield qualifySelector(subSelector, prefix); |
| 437 } | 437 } |
| 438 } | 438 } |
| 439 | 439 |
| 440 *getSelectors(prefix, subtree, styles, targets) | 440 *getSelectors(prefix, subtree, styles, targets) |
| 441 { | 441 { |
| 442 for (let selector of this.findPropsSelectors(styles, prefix, this._regexp)) | 442 for (let selector of this.findPropsSelectors(styles, prefix, this._regexp)) |
| 443 yield [selector, subtree]; | 443 yield [selector, subtree]; |
| 444 } | 444 } |
| 445 } | 445 } |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 { | 637 { |
| 638 if (selector.length == 0) | 638 if (selector.length == 0) |
| 639 return []; | 639 return []; |
| 640 | 640 |
| 641 let match = abpSelectorRegexp.exec(selector); | 641 let match = abpSelectorRegexp.exec(selector); |
| 642 if (!match) | 642 if (!match) |
| 643 return [new PlainSelector(selector)]; | 643 return [new PlainSelector(selector)]; |
| 644 | 644 |
| 645 let selectors = []; | 645 let selectors = []; |
| 646 if (match.index > 0) | 646 if (match.index > 0) |
| 647 selectors.push(new PlainSelector(selector.substr(0, match.index))); | 647 selectors.push(new PlainSelector(selector.substring(0, match.index))); |
| 648 | 648 |
| 649 let startIndex = match.index + match[0].length; | 649 let startIndex = match.index + match[0].length; |
| 650 let content = parseSelectorContent(selector, startIndex); | 650 let content = parseSelectorContent(selector, startIndex); |
| 651 if (!content) | 651 if (!content) |
| 652 { | 652 { |
| 653 console.error(new SyntaxError("Failed to parse Adblock Plus " + | 653 console.error(new SyntaxError("Failed to parse Adblock Plus " + |
| 654 `selector ${selector} ` + | 654 `selector ${selector} ` + |
| 655 "due to unmatched parentheses.")); | 655 "due to unmatched parentheses.")); |
| 656 return null; | 656 return null; |
| 657 } | 657 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 668 selectors.push(new ContainsSelector(content.text)); | 668 selectors.push(new ContainsSelector(content.text)); |
| 669 else | 669 else |
| 670 { | 670 { |
| 671 // this is an error, can't parse selector. | 671 // this is an error, can't parse selector. |
| 672 console.error(new SyntaxError("Failed to parse Adblock Plus " + | 672 console.error(new SyntaxError("Failed to parse Adblock Plus " + |
| 673 `selector ${selector}, invalid ` + | 673 `selector ${selector}, invalid ` + |
| 674 `pseudo-class :-abp-${match[1]}().`)); | 674 `pseudo-class :-abp-${match[1]}().`)); |
| 675 return null; | 675 return null; |
| 676 } | 676 } |
| 677 | 677 |
| 678 let suffix = this.parseSelector(selector.substr(content.end + 1)); | 678 let suffix = this.parseSelector(selector.substring(content.end + 1)); |
| 679 if (suffix == null) | 679 if (suffix == null) |
| 680 return null; | 680 return null; |
| 681 | 681 |
| 682 selectors.push(...suffix); | 682 selectors.push(...suffix); |
| 683 | 683 |
| 684 if (selectors.length == 1 && selectors[0] instanceof ContainsSelector) | 684 if (selectors.length == 1 && selectors[0] instanceof ContainsSelector) |
| 685 { | 685 { |
| 686 console.error(new SyntaxError("Failed to parse Adblock Plus " + | 686 console.error(new SyntaxError("Failed to parse Adblock Plus " + |
| 687 `selector ${selector}, can't ` + | 687 `selector ${selector}, can't ` + |
| 688 "have a lonely :-abp-contains().")); | 688 "have a lonely :-abp-contains().")); |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 964 characterData: shouldObserveCharacterData(this.patterns), | 964 characterData: shouldObserveCharacterData(this.patterns), |
| 965 subtree: true | 965 subtree: true |
| 966 } | 966 } |
| 967 ); | 967 ); |
| 968 this.document.addEventListener("load", this.onLoad.bind(this), true); | 968 this.document.addEventListener("load", this.onLoad.bind(this), true); |
| 969 } | 969 } |
| 970 } | 970 } |
| 971 } | 971 } |
| 972 | 972 |
| 973 exports.ElemHideEmulation = ElemHideEmulation; | 973 exports.ElemHideEmulation = ElemHideEmulation; |
| OLD | NEW |