试图进行扩展

时间:2016-10-25 20:58:16

标签: javascript html json firefox firefox-webextensions

我有一个扩展程序,我试图在后台脚本旁边添加内容,但在尝试临时加载时它只是说无效。

{

"description": "Creates tasks and calculates application incomplete date",
"manifest_version": 2,
"name": "Task Creator",
"version": "1.31",

"permissions": [
"http://*/*", "tabs", "https://*/*",
],

"icons": {
"48": "icons/page-48.png"
},
"web_accessible_resources": [
"style/popUpStyle.css",
"script/popUpTask.js",

"script/logicTaskFiller.js",
"js/autosize.js",
"style/jquery-ui.css",
"js/jquery-1.12.4.js",
"js/jquery-ui.js"
 ],
"content_scripts":{

  "matches": ["*urlhere.com*"],
  "js": ["comSendForm.js"]

},

"background": {
"scripts": ["background.js"]
},

"browser_action": {
 "default_icon": "icons/page-32.png"
  }

}

我不太确定我搞砸了哪里。它在我取出内容脚本后立即工作,但是我在这个扩展中做了很多事情,我确实需要内容脚本在某个页面上运行。任何帮助表示赞赏。

错误消息 1477430058898 addons.webextension。错误加载扩展&#39; null&#39;:读取清单:处理content_scripts时出错:预期数组而不是{&#34;匹配&#34;:[&#34; *:// url.com/ < / EM>&#34],&#34; JS&#34;:[&#34; comSendForm.js&#34;]}

1 个答案:

答案 0 :(得分:0)

您获得的错误是 manifest.json 具有content_scripts键的值作为Object。 content_scripts键的值必须是一个对象数组,而不仅仅是一个对象。

此外,您还有以下问题:

  • 该行:
    "http://*/*", "tabs", "https://*/*",
    不应该有尾随,。这实际上是第一个错误报告,因此您可能不准确地复制了 manifest.json 文件的内容。
  • 您的matches模式无效。你可能想要这样的东西:
    "matches": ["*://*.urlhere.com/"],

通过所有这些更改,您的 manifest.json 将如下所示:

{
    "description": "Creates tasks and calculates application incomplete date",
    "manifest_version": 2,
    "name": "Task Creator",
    "version": "1.31",
    "permissions": [
        "http://*/*", "tabs", "https://*/*"
    ],
    "icons": {
        "48": "icons/page-48.png"
    },
   "web_accessible_resources": [
        "style/popUpStyle.css",
        "script/popUpTask.js",
        "script/logicTaskFiller.js",
        "js/autosize.js",
        "style/jquery-ui.css",
        "js/jquery-1.12.4.js",
        "js/jquery-ui.js"
     ],
    "content_scripts": [
        {
            "matches": ["*://*.urlhere.com/"],
            "js": ["comSendForm.js"]
        }
    ],
    "background": {
        "scripts": ["background.js"]
    },
    "browser_action": {
        "default_icon": "icons/page-32.png"
    }
}