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-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 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 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 } | 478 } |
479 unhighlightElements(); | 479 unhighlightElements(); |
480 | 480 |
481 let overlays = document.getElementsByClassName("__adblockplus__overlay"); | 481 let overlays = document.getElementsByClassName("__adblockplus__overlay"); |
482 while (overlays.length > 0) | 482 while (overlays.length > 0) |
483 overlays[0].parentNode.removeChild(overlays[0]); | 483 overlays[0].parentNode.removeChild(overlays[0]); |
484 | 484 |
485 ext.onExtensionUnloaded.removeListener(deactivateBlockElement); | 485 ext.onExtensionUnloaded.removeListener(deactivateBlockElement); |
486 } | 486 } |
487 | 487 |
488 // In Chrome 37-40, the document_end content script (this one) runs properly, | 488 if (document instanceof HTMLDocument) |
489 // while the document_start content scripts (that defines ext) might not. Check | |
490 // whether variable ext exists before continuing to avoid | |
491 // "Uncaught ReferenceError: ext is not defined". See https://crbug.com/416907 | |
492 if ("ext" in window && document instanceof HTMLDocument) | |
493 { | 489 { |
494 // Use a contextmenu handler to save the last element the user right-clicked | 490 // Use a contextmenu handler to save the last element the user right-clicked |
495 // on. To make things easier, we actually save the DOM event. We have to do | 491 // on. To make things easier, we actually save the DOM event. We have to do |
496 // this because the contextMenu API only provides a URL, not the actual DOM | 492 // this because the contextMenu API only provides a URL, not the actual DOM |
497 // element. | 493 // element. |
498 // We also need to make sure that the previous right click event, | 494 // We also need to make sure that the previous right click event, |
499 // if there is one, is removed. We don't know which frame it is in so we must | 495 // if there is one, is removed. We don't know which frame it is in so we must |
500 // send a message to the other frames to clear their old right click events. | 496 // send a message to the other frames to clear their old right click events. |
501 document.addEventListener("contextmenu", event => | 497 document.addEventListener("contextmenu", event => |
502 { | 498 { |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 } | 576 } |
581 }); | 577 }); |
582 } | 578 } |
583 break; | 579 break; |
584 } | 580 } |
585 }); | 581 }); |
586 | 582 |
587 if (window == window.top) | 583 if (window == window.top) |
588 ext.backgroundPage.sendMessage({type: "composer.ready"}); | 584 ext.backgroundPage.sendMessage({type: "composer.ready"}); |
589 } | 585 } |
LEFT | RIGHT |