| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2013 Eyeo GmbH | 3 * Copyright (C) 2006-2013 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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 } | 256 } |
| 257 }; | 257 }; |
| 258 | 258 |
| 259 | 259 |
| 260 /* Web request blocking */ | 260 /* Web request blocking */ |
| 261 | 261 |
| 262 document.addEventListener("beforeload", function(event) | 262 document.addEventListener("beforeload", function(event) |
| 263 { | 263 { |
| 264 var type; | 264 var type; |
| 265 | 265 |
| 266 switch(event.target.nodeName) | 266 switch(event.target.localName) |
| 267 { | 267 { |
| 268 case "FRAME": | 268 case "frame": |
| 269 case "IFRAME": | 269 case "iframe": |
| 270 type = "frame"; | 270 type = "sub_rame"; |
| 271 break; | 271 break; |
| 272 case "IMG": | 272 case "img": |
| 273 type = "image"; | 273 type = "image"; |
| 274 break; | 274 break; |
| 275 case "OBJECT": | 275 case "object": |
| 276 case "EMBED": | 276 case "embed": |
| 277 type = "object"; | 277 type = "object"; |
| 278 break; | 278 break; |
| 279 case "SCRIPT": | 279 case "script": |
| 280 type = "script"; | 280 type = "script"; |
| 281 break; | 281 break; |
| 282 case "LINK": | 282 case "link": |
| 283 if (/(^|\s)stylesheet($|\s)/i.test(event.target.rel)) | 283 if (/\bstylesheet\b/i.test(event.target.rel)) |
| 284 { | 284 { |
| 285 type = "stylesheet"; | 285 type = "stylesheet"; |
| 286 break; | 286 break; |
| 287 } | 287 } |
| 288 default: | 288 default: |
| 289 type = "other"; | 289 type = "other"; |
| 290 } | 290 } |
| 291 | 291 |
| 292 if (!safari.self.tab.canLoad(event, {type: "webRequest", payload: {url: even
t.url, type: type}})) | 292 if (!safari.self.tab.canLoad(event, {type: "webRequest", payload: {url: even
t.url, type: type}})) |
| 293 event.preventDefault(); | 293 event.preventDefault(); |
| 294 }, true); | 294 }, true); |
| 295 | 295 |
| 296 | 296 |
| 297 /* API */ | 297 /* API */ |
| 298 | 298 |
| 299 ext.backgroundPage = { | 299 ext.backgroundPage = { |
| 300 _eventTarget: safari.self, | 300 _eventTarget: safari.self, |
| 301 _messageDispatcher: safari.self.tab, | 301 _messageDispatcher: safari.self.tab, |
| 302 | 302 |
| 303 sendMessage: sendMessage, | 303 sendMessage: sendMessage, |
| 304 getWindow: function() { return proxy.getObject(0); } | 304 getWindow: function() { return proxy.getObject(0); } |
| 305 }; | 305 }; |
| 306 | 306 |
| 307 ext.onMessage = new MessageEventTarget(safari.self); | 307 ext.onMessage = new MessageEventTarget(safari.self); |
| 308 })(); | 308 })(); |
| OLD | NEW |