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-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 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
409 ) | 409 ) |
410 ); | 410 ); |
411 } | 411 } |
412 | 412 |
413 function ElemHideEmulation(addSelectorsFunc, hideElemsFunc) | 413 function ElemHideEmulation(addSelectorsFunc, hideElemsFunc) |
414 { | 414 { |
415 this.document = document; | 415 this.document = document; |
416 this.addSelectorsFunc = addSelectorsFunc; | 416 this.addSelectorsFunc = addSelectorsFunc; |
417 this.hideElemsFunc = hideElemsFunc; | 417 this.hideElemsFunc = hideElemsFunc; |
418 this.observer = new MutationObserver(this.observe.bind(this)); | 418 this.observer = new MutationObserver(this.observe.bind(this)); |
419 this.useInlineStyles = true; | |
kzar
2018/03/19 21:18:54
This doesn't match `alwaysHideWithSelector` in the
Manish Jethani
2018/03/20 11:20:23
Done.
| |
419 } | 420 } |
420 | 421 |
421 ElemHideEmulation.prototype = { | 422 ElemHideEmulation.prototype = { |
422 isSameOrigin(stylesheet) | 423 isSameOrigin(stylesheet) |
423 { | 424 { |
424 try | 425 try |
425 { | 426 { |
426 return new URL(stylesheet.href).origin == this.document.location.origin; | 427 return new URL(stylesheet.href).origin == this.document.location.origin; |
427 } | 428 } |
428 catch (e) | 429 catch (e) |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
566 pattern = null; | 567 pattern = null; |
567 return processPatterns(); | 568 return processPatterns(); |
568 } | 569 } |
569 generator = evaluate(pattern.selectors, 0, "", | 570 generator = evaluate(pattern.selectors, 0, "", |
570 this.document, cssStyles); | 571 this.document, cssStyles); |
571 } | 572 } |
572 for (let selector of generator) | 573 for (let selector of generator) |
573 { | 574 { |
574 if (selector != null) | 575 if (selector != null) |
575 { | 576 { |
576 if (isSelectorHidingOnlyPattern(pattern)) | 577 if (!this.useInlineStyles || |
578 isSelectorHidingOnlyPattern(pattern)) | |
577 { | 579 { |
578 selectors.push(selector); | 580 selectors.push(selector); |
579 selectorFilters.push(pattern.text); | 581 selectorFilters.push(pattern.text); |
580 } | 582 } |
581 else | 583 else |
582 { | 584 { |
583 for (let element of this.document.querySelectorAll(selector)) | 585 for (let element of this.document.querySelectorAll(selector)) |
584 { | 586 { |
585 elements.push(element); | 587 elements.push(element); |
586 elementFilters.push(pattern.text); | 588 elementFilters.push(pattern.text); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
712 characterData: shouldObserveCharacterData(this.patterns), | 714 characterData: shouldObserveCharacterData(this.patterns), |
713 subtree: true | 715 subtree: true |
714 } | 716 } |
715 ); | 717 ); |
716 this.document.addEventListener("load", this.onLoad.bind(this), true); | 718 this.document.addEventListener("load", this.onLoad.bind(this), true); |
717 } | 719 } |
718 } | 720 } |
719 }; | 721 }; |
720 | 722 |
721 exports.ElemHideEmulation = ElemHideEmulation; | 723 exports.ElemHideEmulation = ElemHideEmulation; |
OLD | NEW |