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 22 matching lines...) Expand all Loading... |
33 // exception or return true when used.) | 33 // exception or return true when used.) |
34 var usingContentBlockerAPI = true; | 34 var usingContentBlockerAPI = true; |
35 try | 35 try |
36 { | 36 { |
37 if (safari.self.tab.canLoad(beforeLoadEvent, | 37 if (safari.self.tab.canLoad(beforeLoadEvent, |
38 {category: "request", | 38 {category: "request", |
39 payload: {type: "prefs.get", | 39 payload: {type: "prefs.get", |
40 key: "safariContentBlocker"}}) != tru
e) | 40 key: "safariContentBlocker"}}) != tru
e) |
41 usingContentBlockerAPI = false; | 41 usingContentBlockerAPI = false; |
42 } | 42 } |
43 catch (e) { }; | 43 catch (e) |
| 44 { |
| 45 } |
44 | 46 |
45 var isTopLevel; | 47 var isTopLevel; |
46 var isPrerendered; | 48 var isPrerendered; |
47 var documentId; | 49 var documentId; |
48 function notifyFrameLoading() | 50 function notifyFrameLoading() |
49 { | 51 { |
50 isTopLevel = window == window.top; | 52 isTopLevel = window == window.top; |
51 isPrerendered = document.visibilityState == "prerender"; | 53 isPrerendered = document.visibilityState == "prerender"; |
52 documentId = Math.random().toString().substr(2); | 54 documentId = Math.random().toString().substr(2); |
53 | 55 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 // been prevented from loading by having their "beforeload" event | 148 // been prevented from loading by having their "beforeload" event |
147 // cancelled. That is a "load" event for blocked frames, and an "error" | 149 // cancelled. That is a "load" event for blocked frames, and an "error" |
148 // event for other blocked elements. We need to dispatch those events | 150 // event for other blocked elements. We need to dispatch those events |
149 // manually here to avoid breaking element collapsing and pages that | 151 // manually here to avoid breaking element collapsing and pages that |
150 // rely on those events. | 152 // rely on those events. |
151 setTimeout(function() | 153 setTimeout(function() |
152 { | 154 { |
153 var evt = document.createEvent("Event"); | 155 var evt = document.createEvent("Event"); |
154 evt.initEvent(eventName); | 156 evt.initEvent(eventName); |
155 event.target.dispatchEvent(evt); | 157 event.target.dispatchEvent(evt); |
156 }, 0); | 158 }); |
157 } | 159 } |
158 }, true); | 160 }, true); |
159 } | 161 } |
160 | 162 |
161 | 163 |
162 /* Context menus */ | 164 /* Context menus */ |
163 | 165 |
164 document.addEventListener("contextmenu", function(event) | 166 document.addEventListener("contextmenu", function(event) |
165 { | 167 { |
166 var element = event.srcElement; | 168 var element = event.srcElement; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 }); | 223 }); |
222 | 224 |
223 | 225 |
224 /* Detecting extension reload/disable/uninstall (not supported on Safari) */ | 226 /* Detecting extension reload/disable/uninstall (not supported on Safari) */ |
225 | 227 |
226 ext.onExtensionUnloaded = { | 228 ext.onExtensionUnloaded = { |
227 addListener: function() {}, | 229 addListener: function() {}, |
228 removeListener: function() {} | 230 removeListener: function() {} |
229 }; | 231 }; |
230 })(); | 232 })(); |
LEFT | RIGHT |