OLD | NEW |
1 "use strict"; | 1 "use strict"; |
2 | 2 |
3 (function() | 3 (function() |
4 { | 4 { |
| 5 if ((typeof chrome == "undefined") || |
| 6 (typeof chrome.extension == "undefined")) |
| 7 window.chrome = browser; |
5 const backgroundPage = chrome.extension.getBackgroundPage(); | 8 const backgroundPage = chrome.extension.getBackgroundPage(); |
6 window.ext = Object.create(backgroundPage.ext); | 9 window.ext = Object.create(backgroundPage.ext); |
7 | 10 |
8 window.ext.closePopup = () => | 11 window.ext.closePopup = () => |
9 { | 12 { |
10 window.close(); | 13 window.close(); |
11 }; | 14 }; |
12 | 15 |
13 // We have to override ext.backgroundPage, because in order | 16 // We have to override ext.backgroundPage, because in order |
14 // to send messages the local "chrome" namespace must be used. | 17 // to send messages the local "chrome" namespace must be used. |
15 window.ext.backgroundPage = { | 18 window.ext.backgroundPage = { |
16 sendMessage: chrome.runtime.sendMessage, | 19 sendMessage: chrome.runtime.sendMessage, |
17 | 20 |
18 getWindow() | 21 getWindow() |
19 { | 22 { |
20 return backgroundPage; | 23 return backgroundPage; |
21 } | 24 } |
22 }; | 25 }; |
23 }()); | 26 }()); |
OLD | NEW |