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-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 |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
16 */ | 16 */ |
17 | 17 |
18 | 18 |
19 (function() | 19 (function() |
20 { | 20 { |
| 21 // Both Edge and Mozilla Web Extensions use the namespace 'browser' instead of
'chrome' |
| 22 if (!("chrome" in window)) |
| 23 window.chrome = window.browser; |
| 24 |
21 window.ext = {}; | 25 window.ext = {}; |
22 | 26 |
23 var EventTarget = ext._EventTarget = function() | 27 var EventTarget = ext._EventTarget = function() |
24 { | 28 { |
25 this._listeners = []; | 29 this._listeners = []; |
26 }; | 30 }; |
27 EventTarget.prototype = { | 31 EventTarget.prototype = { |
28 addListener: function(listener) | 32 addListener: function(listener) |
29 { | 33 { |
30 if (this._listeners.indexOf(listener) == -1) | 34 if (this._listeners.indexOf(listener) == -1) |
(...skipping 10 matching lines...) Expand all Loading... |
41 var results = []; | 45 var results = []; |
42 var listeners = this._listeners.slice(); | 46 var listeners = this._listeners.slice(); |
43 | 47 |
44 for (var i = 0; i < listeners.length; i++) | 48 for (var i = 0; i < listeners.length; i++) |
45 results.push(listeners[i].apply(null, arguments)); | 49 results.push(listeners[i].apply(null, arguments)); |
46 | 50 |
47 return results; | 51 return results; |
48 } | 52 } |
49 }; | 53 }; |
50 })(); | 54 })(); |
OLD | NEW |