LukasD: After debugging and looking at the code (via CRX Viewer) I have found that the piece of code responsible for asking said permission is written for the Chrome browser, which handles web extensions fairly similar, but not 100% the same.
[code]
function addTabsPermission(callbackSuccess, callbackFail) {
chrome.permissions.contains({
permissions: ['tabs'],
origins: ['']
}, function(result) {
if (result) {
callbackSuccess();
} else {
chrome.permissions.request({
permissions: ['tabs'],
origins: ['']
}, function (granted) {
console.log(chrome.runtime.lastError);
if (granted) {
callbackSuccess();
} else {
console.log("permissions not granted" );
if (callbackFail) callbackFail();
}
});
}
});
}
[/code]
As can be seen in the function above, the methods being used are chrome.permissions.request(), while in FireFox this would be browser.permissions.request(). I have not testen the following, but I think changing the code for Firefox in the following way would work (which seems logical to me, as the only difference I see in the documentation is "chrome" being replaced by "browser");
[code]
function addTabsPermission(callbackSuccess, callbackFail) {
browser.permissions.contains({
permissions: ['tabs'],
origins: ['']
}, function(result) {
if (result) {
callbackSuccess();
} else {
browser.permissions.request({
permissions: ['tabs'],
origins: ['']
}, function (granted) {
console.log(browser.runtime.lastError);
if (granted) {
callbackSuccess();
} else {
console.log("permissions not granted" );
if (callbackFail) callbackFail();
}
});
}
});
}
[/code]
↧