我对Firefox Web Extension开发很新,但我想尝试一下。我正在玩一些基本的例子,但我无法让“管理”API工作。
这是我的manifest.json
:
{
"description": "my demo",
"manifest_version": 2,
"name": "My Demo",
"version": "1.0",
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["first_try.js"]
}
],
"permissions": [
"management",
"webRequest",
"<all_urls>"
],
"background": {
"scripts": ["analysis.js"]
}
}
这是我的后台脚本代码:
var management = browser.management;
console.log(management);
management.getAll(function (apps) {
console.log(apps);
});
我还尝试了以下代码段,但它没有改变任何内容
management.getAll().then((extensions) => {
for (let extension of extensions) {
console.log(extension);
}
这是我运行扩展程序时的输出:
Object { getAll: Getter, get: Getter, getSelf: Getter, uninstallSelf: Getter, IconInfo: Getter, ExtensionDisabledReason: Getter, ExtensionType: Getter, ExtensionInstallType: Getter, ExtensionInfo: Getter }
TypeError: management.getAll is not a function
即使我从权限中删除了“管理”行,我也会收到错误。
我错过了什么?
提前致谢。