Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

loading script to google chrome extension

I'm trying to create new extensions but I'm having a problem when I include the JavaScript:

 {
  "name": "<name>",
  "version": "1.0",
  "description": "<description>",
    "default_icon": "icon.png",
    "content_scripts": [
    {
      "matches": ["http://*.com"],
          "js": ["script.js"]
    }
  ],
  "permissions": [
    "http://*.com/"
  ]
}

I'm having this error:

could not load extension from <path>
Invaild value for 'content_scripts[0].matches[0]':Empty path
like image 467
Yehonatan Avatar asked Aug 04 '11 09:08

Yehonatan


People also ask

What is content script Chrome extension?

A content script is a part of your extension that runs in the context of a particular web page (as opposed to background scripts which are part of the extension, or scripts which are part of the website itself, such as those loaded using the <script> element).

Can I run a JS file in Chrome?

Activate JavaScript in Google ChromeClick Site settings. Click JavaScript. Select Sites can use Javascript.


1 Answers

You have a invalid matches URL - content script match patterns need a scheme, host, and a path. The path includes the first slash / after the host (in this case, *.co.il).
Chrome is complaining that you do not have a path, so you have to add one.

  • If you want to match only http://*.co.il, just change it to http://*.co.il/.
  • If you want to match all paths change it to http://*.co.il/*.
like image 196
Digital Plane Avatar answered Oct 16 '22 14:10

Digital Plane