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