0

I have an extension that i'm trying to add content scrips alongside background scripts but it just says invalid when trying to temp load.

{

"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"
  }

}

I'm not quite sure where i'm messing up. It works instantly after I take out the content scripts, but I'm doing multiple things with this extension and I really do need the content scripts to run on a certain page. Any help is appreciated.

error message 1477430058898 addons.webextension. ERROR Loading extension 'null': Reading manifest: Error processing content_scripts: Expected array instead of {"matches":["*://url.com/"],"js":["comSendForm.js"]}

Branden Ham
  • 92
  • 1
  • 1
  • 7
  • What *exactly* is the error you are seeing and where? What, *exactly*, was shown in the [Browser Console](https://developer.mozilla.org/en-US/docs/Tools/Browser_Console) (Ctrl-Shift-J, or Cmd-Shift-J on OSX) when you tried to install the extension? – Makyen Oct 25 '16 at 21:12
  • 1477430058898 addons.webextension. ERROR Loading extension 'null': Reading manifest: Error processing content_scripts: Expected array instead of {"matches":["*://*url.com/*"],"js":["comSendForm.js"]} – Branden Ham Oct 25 '16 at 21:15
  • Well, the first problem is that your *manifest.json* JSON is malformed: `"http://*/*", "tabs", "https://*/*",` needs to not have the final `,`. – Makyen Oct 25 '16 at 21:22
  • oh i see where i went wrong. was adding a * to a url. thanks for pointing out the browser console tho, i've been just using f12 to debug didn't realize there was one for the whole browser. was very helpful! – Branden Ham Oct 25 '16 at 21:29

1 Answers1

0

The error that you are getting is that your manifest.json has the value of the content_scripts key as an Object. The value of the content_scripts key needs to be an Array of Objects, not just an Object.

In addition, you have the following problems:

  • The line:
    "http://*/*", "tabs", "https://*/*",
    should not have the trailing ,. This is actually reported as the first error, so you may have copied the contents of your manifest.json file inaccurately.
  • Your matches pattern is invalid. You probably wanted something like:
    "matches": ["*://*.urlhere.com/"],

With all of those changes your manifest.json would look like:

{
    "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"
    }
}
Makyen
  • 31,849
  • 12
  • 86
  • 121