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-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 |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 }); | 572 }); |
573 | 573 |
574 this.propertyFilters.load(function() | 574 this.propertyFilters.load(function() |
575 { | 575 { |
576 propertyFiltersLoaded = true; | 576 propertyFiltersLoaded = true; |
577 checkLoaded(); | 577 checkLoaded(); |
578 }); | 578 }); |
579 } | 579 } |
580 }; | 580 }; |
581 | 581 |
582 if (document instanceof HTMLDocument) | 582 function whenDocumentVisible(callback) |
583 { | 583 { |
584 checkSitekey(); | |
585 wrapWebSocket(); | |
586 | |
587 var elemhide = new ElemHide(); | |
588 | |
589 if (document.visibilityState == "prerender") | 584 if (document.visibilityState == "prerender") |
590 { | 585 { |
591 // For prerendered documents, wait until the document is made visible. We | 586 // For prerendered documents, wait until the document is made visible. We |
592 // do not have access to the page property of the SafariBrowserTab object | 587 // do not have access to the page property of the SafariBrowserTab object |
593 // associated with this document until it is visible. Without the page | 588 // associated with this document until it is visible. Without the page |
594 // property, we cannot get a response from the background page. | 589 // property, we cannot get a response from the background page. |
595 document.addEventListener("visibilitychange", function onVisibilitychange() | 590 let onVisibilitychange = function() |
596 { | 591 { |
597 document.removeEventListener("visibilitychange", onVisibilitychange); | 592 document.removeEventListener("visibilitychange", onVisibilitychange); |
598 | 593 callback(); |
599 elemhide.apply(); | 594 }; |
600 }); | 595 |
| 596 document.addEventListener("visibilitychange", onVisibilitychange); |
601 } | 597 } |
602 else | 598 else |
603 { | 599 { |
604 elemhide.apply(); | 600 callback(); |
605 } | 601 } |
| 602 } |
| 603 |
| 604 if (document instanceof HTMLDocument) |
| 605 { |
| 606 checkSitekey(); |
| 607 wrapWebSocket(); |
| 608 |
| 609 var elemhide = new ElemHide(); |
| 610 |
| 611 whenDocumentVisible(elemhide.apply.bind(elemhide)); |
606 | 612 |
607 document.addEventListener("error", function(event) | 613 document.addEventListener("error", function(event) |
608 { | 614 { |
609 checkCollapse(event.target); | 615 checkCollapse(event.target); |
610 }, true); | 616 }, true); |
611 | 617 |
612 document.addEventListener("load", function(event) | 618 document.addEventListener("load", function(event) |
613 { | 619 { |
614 var element = event.target; | 620 var element = event.target; |
615 if (/^i?frame$/.test(element.localName)) | 621 if (/^i?frame$/.test(element.localName)) |
616 checkCollapse(element); | 622 checkCollapse(element); |
617 }, true); | 623 }, true); |
618 } | 624 } |
LEFT | RIGHT |