Index: ext/common.js |
=================================================================== |
--- a/ext/common.js |
+++ b/ext/common.js |
@@ -17,18 +17,19 @@ |
"use strict"; |
(function() |
{ |
// Both Edge and Mozilla Web Extensions use the namespace |
// 'browser' instead of 'chrome'. Edge has chrome namespace defined, |
// in some cases, but only with one property: 'app'. |
- if (typeof chrome == "undefined" || typeof chrome.extension == "undefined") |
- window.chrome = window.browser; |
+ if (typeof browser == "undefined" || |
+ typeof chrome != "undefined" && typeof chrome.extension != "undefined") |
+ window.browser = chrome; |
window.ext = {}; |
let EventTarget = ext._EventTarget = function() |
{ |
this._listeners = new Set(); |
}; |
EventTarget.prototype = { |
@@ -67,20 +68,20 @@ |
/* Message passing */ |
ext.onMessage = new ext._EventTarget(); |
/* Background page */ |
ext.backgroundPage = { |
- sendMessage: chrome.runtime.sendMessage, |
+ sendMessage: browser.runtime.sendMessage, |
getWindow() |
{ |
- return chrome.extension.getBackgroundPage(); |
+ return browser.extension.getBackgroundPage(); |
} |
}; |
/* Utils */ |
- ext.getURL = chrome.extension.getURL; |
+ ext.getURL = browser.extension.getURL; |
}()); |