| 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-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 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 453 } | 453 } |
| 454 }; | 454 }; |
| 455 | 455 |
| 456 function filterPatterns(patterns, {stylesheets, mutations}, document) | 456 function filterPatterns(patterns, {stylesheets, mutations}, document) |
| 457 { | 457 { |
| 458 if (!stylesheets && !mutations) | 458 if (!stylesheets && !mutations) |
| 459 { | 459 { |
| 460 // On initial load, skip DOM-only patterns if it's the top frame, because | 460 // On initial load, skip DOM-only patterns if it's the top frame, because |
| 461 // there's usually nothing interesting to see and we can respond to any | 461 // there's usually nothing interesting to see and we can respond to any |
| 462 // mutations later. | 462 // mutations later. |
| 463 if (typeof top != "undefined" && document.defaultView == top) | 463 if (typeof top != "undefined" && document.defaultView == top) |
|
hub
2018/03/23 14:58:59
Maybe I'm missing something, but where does that `
Manish Jethani
2018/03/23 16:56:46
That's a reference to the global variable window.t
hub
2018/03/24 01:02:14
I think it would be better, yes, both for clarity
| |
| 464 return patterns.filter(pattern => pattern.dependsOnStyles); | 464 return patterns.filter(pattern => pattern.dependsOnStyles); |
| 465 | 465 |
| 466 return patterns.slice(); | 466 return patterns.slice(); |
| 467 } | 467 } |
| 468 | 468 |
| 469 return patterns.filter( | 469 return patterns.filter( |
| 470 pattern => (stylesheets && pattern.dependsOnStyles) || | 470 pattern => (stylesheets && pattern.dependsOnStyles) || |
| 471 (mutations && pattern.dependsOnDOM) | 471 (mutations && pattern.dependsOnDOM) |
| 472 ); | 472 ); |
| 473 } | 473 } |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 598 | 598 |
| 599 // If neither any style sheets nor any DOM mutations have been specified, | 599 // If neither any style sheets nor any DOM mutations have been specified, |
| 600 // do full processing. | 600 // do full processing. |
| 601 if (!stylesheets && !mutations) | 601 if (!stylesheets && !mutations) |
| 602 stylesheets = this.document.styleSheets; | 602 stylesheets = this.document.styleSheets; |
| 603 | 603 |
| 604 // If there are any DOM mutations and any of the patterns depends on both | 604 // If there are any DOM mutations and any of the patterns depends on both |
| 605 // style sheets and the DOM (e.g. -abp-has(-abp-properties)), find all the | 605 // style sheets and the DOM (e.g. -abp-has(-abp-properties)), find all the |
| 606 // rules in every style sheet in the document, because we need to run | 606 // rules in every style sheet in the document, because we need to run |
| 607 // querySelectorAll afterwards. On the other hand, if we only have patterns | 607 // querySelectorAll afterwards. On the other hand, if we only have patterns |
| 608 // that depend on either styles or DOM both not both | 608 // that depend on either styles or DOM but not both |
| 609 // (e.g. -abp-properties or -abp-contains), we can skip this part. | 609 // (e.g. -abp-properties or -abp-contains), we can skip this part. |
| 610 if (mutations && patterns.some(pattern => pattern.dependsOnStylesAndDOM)) | 610 if (mutations && patterns.some(pattern => pattern.dependsOnStylesAndDOM)) |
| 611 stylesheets = this.document.styleSheets; | 611 stylesheets = this.document.styleSheets; |
| 612 | 612 |
| 613 for (let stylesheet of stylesheets || []) | 613 for (let stylesheet of stylesheets || []) |
| 614 { | 614 { |
| 615 // Explicitly ignore third-party stylesheets to ensure consistent behavior | 615 // Explicitly ignore third-party stylesheets to ensure consistent behavior |
| 616 // between Firefox and Chrome. | 616 // between Firefox and Chrome. |
| 617 if (!this.isSameOrigin(stylesheet)) | 617 if (!this.isSameOrigin(stylesheet)) |
| 618 continue; | 618 continue; |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 817 characterData: shouldObserveCharacterData(this.patterns), | 817 characterData: shouldObserveCharacterData(this.patterns), |
| 818 subtree: true | 818 subtree: true |
| 819 } | 819 } |
| 820 ); | 820 ); |
| 821 this.document.addEventListener("load", this.onLoad.bind(this), true); | 821 this.document.addEventListener("load", this.onLoad.bind(this), true); |
| 822 } | 822 } |
| 823 } | 823 } |
| 824 }; | 824 }; |
| 825 | 825 |
| 826 exports.ElemHideEmulation = ElemHideEmulation; | 826 exports.ElemHideEmulation = ElemHideEmulation; |
| LEFT | RIGHT |