mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2024-12-31 09:01:56 +01:00
Don't break if browser API is not available
This commit is contained in:
parent
33b30e158f
commit
403885f426
@ -20,20 +20,26 @@
|
||||
browser.extension.getBackgroundPage() === window
|
||||
);
|
||||
|
||||
scope.getTranslation = function getTranslation(id){
|
||||
scope.getTranslation = browserAvailable? function getTranslation(id){
|
||||
return browser.i18n.getMessage(id);
|
||||
}: function(id){
|
||||
return id;
|
||||
};
|
||||
|
||||
scope.extensionID = browser.extension.getURL("");
|
||||
scope.extensionID = browserAvailable? browser.extension.getURL(""): "extensionID";
|
||||
|
||||
scope.inIncognitoContext = browser.extension.inIncognitoContext;
|
||||
scope.inIncognitoContext = browserAvailable? browser.extension.inIncognitoContext: false;
|
||||
|
||||
scope.message = {
|
||||
on: function(callback){
|
||||
on: browserAvailable? function(callback){
|
||||
return browser.runtime.onMessage.addListener(callback);
|
||||
}: function(){
|
||||
return false;
|
||||
},
|
||||
send: function(data){
|
||||
send: browserAvailable? function(data){
|
||||
return browser.runtime.sendMessage(data);
|
||||
}: function(){
|
||||
return false;
|
||||
}
|
||||
};
|
||||
Object.seal(scope.message);
|
||||
|
@ -10,6 +10,7 @@
|
||||
"background": {
|
||||
"scripts": [
|
||||
"lib/require.js",
|
||||
"lib/extension.js",
|
||||
"lib/logging.js",
|
||||
"lib/settingDefinitions.js",
|
||||
"lib/settingContainers.js",
|
||||
|
Loading…
x
Reference in New Issue
Block a user