| 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 561 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 function whenDocumentVisible(callback) |
| 583 { |
| 584 if (document.visibilityState == "prerender") |
| 585 { |
| 586 // For prerendered documents, wait until the document is made visible. We |
| 587 // do not have access to the page property of the SafariBrowserTab object |
| 588 // associated with this document until it is visible. Without the page |
| 589 // property, we cannot get a response from the background page. |
| 590 let onVisibilitychange = function() |
| 591 { |
| 592 document.removeEventListener("visibilitychange", onVisibilitychange); |
| 593 callback(); |
| 594 }; |
| 595 |
| 596 document.addEventListener("visibilitychange", onVisibilitychange); |
| 597 } |
| 598 else |
| 599 { |
| 600 callback(); |
| 601 } |
| 602 } |
| 603 |
| 582 if (document instanceof HTMLDocument) | 604 if (document instanceof HTMLDocument) |
| 583 { | 605 { |
| 584 checkSitekey(); | 606 checkSitekey(); |
| 585 wrapWebSocket(); | 607 wrapWebSocket(); |
| 586 | 608 |
| 587 var elemhide = new ElemHide(); | 609 var elemhide = new ElemHide(); |
| 588 elemhide.apply(); | 610 |
| 611 whenDocumentVisible(elemhide.apply.bind(elemhide)); |
| 589 | 612 |
| 590 document.addEventListener("error", function(event) | 613 document.addEventListener("error", function(event) |
| 591 { | 614 { |
| 592 checkCollapse(event.target); | 615 checkCollapse(event.target); |
| 593 }, true); | 616 }, true); |
| 594 | 617 |
| 595 document.addEventListener("load", function(event) | 618 document.addEventListener("load", function(event) |
| 596 { | 619 { |
| 597 var element = event.target; | 620 var element = event.target; |
| 598 if (/^i?frame$/.test(element.localName)) | 621 if (/^i?frame$/.test(element.localName)) |
| 599 checkCollapse(element); | 622 checkCollapse(element); |
| 600 }, true); | 623 }, true); |
| 601 } | 624 } |
| OLD | NEW |