Chrome Extension Manifest 'Matches'


Answer :

You need to surround the value of the content_scripts field in square brackets:

"content_scripts": [ {   "matches": ["http://*"],   "js": ["scripts.js"] } ] 

(see the Chrome Docs for more info)

Incidentally, using http://*/* would be a better match for all urls (see the docs), adding https://*/* if you also need to match those as well.

Edit:

Following your edit, the error you are getting is because of the match pattern being incorrect.


If you want to match every URL, then Google has a special pattern just for this purpose: <all_urls>

Sample usage:

"matches": ["<all_urls>"], 

See this page for more info: https://developer.chrome.com/extensions/match_patterns


Any match pattern should be of the following structure [scheme]://[host][path]

  1. scheme is '*' | 'http' | 'https' | 'file' | 'ftp'
  2. host is '' | '.' (any char except '/' and '*')+
  3. path is '/' (any chars)

For matching any HTTP/S and FILE URL use:

 "matches": [     "*://*/*",     "file://*/*"   ], 

Ref: https://developer.chrome.com/apps/match_patterns

By the way, in order to allow access to local files - add the permission:

"permissions": [    "file://*/*" ] 

Or approve file access on the extension settings page.


Comments

Popular posts from this blog

Chemistry - Bond Angles In NH3 And NCl3

Are Regular VACUUM ANALYZE Still Recommended Under 9.1?

Change The Font Size Of Visual Studio Solution Explorer