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