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-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 | 57 |
58 document.addEventListener("beforeload", function(event) | 58 document.addEventListener("beforeload", function(event) |
59 { | 59 { |
60 // we don't block non-HTTP requests anyway, so we can bail out | 60 // we don't block non-HTTP requests anyway, so we can bail out |
61 // without asking the background page. This is even necessary | 61 // without asking the background page. This is even necessary |
62 // because passing large data (like a photo encoded as data: URL) | 62 // because passing large data (like a photo encoded as data: URL) |
63 // to the background page, freezes Safari. | 63 // to the background page, freezes Safari. |
64 if (/^(?!https?:)[\w-]+:/.test(event.url)) | 64 if (/^(?!https?:)[\w-]+:/.test(event.url)) |
65 return; | 65 return; |
66 | 66 |
67 var type = "other"; | 67 var type = "OTHER"; |
68 var eventName = "error"; | 68 var eventName = "error"; |
69 | 69 |
70 switch(event.target.localName) | 70 switch(event.target.localName) |
71 { | 71 { |
72 case "frame": | 72 case "frame": |
73 case "iframe": | 73 case "iframe": |
74 type = "sub_frame"; | 74 type = "SUBDOCUMENT"; |
75 eventName = "load"; | 75 eventName = "load"; |
76 break; | 76 break; |
77 case "img": | 77 case "img": |
78 case "input": | 78 case "input": |
79 type = "image"; | 79 type = "IMAGE"; |
80 break; | 80 break; |
81 case "object": | 81 case "object": |
82 case "embed": | 82 case "embed": |
83 type = "object"; | 83 type = "OBJECT"; |
84 break; | 84 break; |
85 case "script": | 85 case "script": |
86 type = "script"; | 86 type = "SCRIPT"; |
87 break; | 87 break; |
88 case "link": | 88 case "link": |
89 if (/\bstylesheet\b/i.test(event.target.rel)) | 89 if (/\bstylesheet\b/i.test(event.target.rel)) |
90 type = "stylesheet"; | 90 type = "STYLESHEET"; |
91 break; | 91 break; |
92 } | 92 } |
93 | 93 |
94 if (!safari.self.tab.canLoad( | 94 if (!safari.self.tab.canLoad( |
95 event, { | 95 event, { |
96 category: "webRequest", | 96 category: "webRequest", |
97 url: event.url, | 97 url: event.url, |
98 type: type, | 98 type: type, |
99 pageId: documentInfo.pageId, | 99 pageId: documentInfo.pageId, |
100 frameId: documentInfo.frameId | 100 frameId: documentInfo.frameId |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 }); | 428 }); |
429 | 429 |
430 | 430 |
431 /* Detecting extension reload/disable/uninstall (not supported on Safari) */ | 431 /* Detecting extension reload/disable/uninstall (not supported on Safari) */ |
432 | 432 |
433 ext.onExtensionUnloaded = { | 433 ext.onExtensionUnloaded = { |
434 addListener: function() {}, | 434 addListener: function() {}, |
435 removeListener: function() {} | 435 removeListener: function() {} |
436 }; | 436 }; |
437 })(); | 437 })(); |
OLD | NEW |