mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-01-03 10:31:54 +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
|
browser.extension.getBackgroundPage() === window
|
||||||
);
|
);
|
||||||
|
|
||||||
scope.getTranslation = function getTranslation(id){
|
scope.getTranslation = browserAvailable? function getTranslation(id){
|
||||||
return browser.i18n.getMessage(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 = {
|
scope.message = {
|
||||||
on: function(callback){
|
on: browserAvailable? function(callback){
|
||||||
return browser.runtime.onMessage.addListener(callback);
|
return browser.runtime.onMessage.addListener(callback);
|
||||||
|
}: function(){
|
||||||
|
return false;
|
||||||
},
|
},
|
||||||
send: function(data){
|
send: browserAvailable? function(data){
|
||||||
return browser.runtime.sendMessage(data);
|
return browser.runtime.sendMessage(data);
|
||||||
|
}: function(){
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Object.seal(scope.message);
|
Object.seal(scope.message);
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
"background": {
|
"background": {
|
||||||
"scripts": [
|
"scripts": [
|
||||||
"lib/require.js",
|
"lib/require.js",
|
||||||
|
"lib/extension.js",
|
||||||
"lib/logging.js",
|
"lib/logging.js",
|
||||||
"lib/settingDefinitions.js",
|
"lib/settingDefinitions.js",
|
||||||
"lib/settingContainers.js",
|
"lib/settingContainers.js",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user