Colorfulstan

How does manifest.jsons data.content_scripts work?

Recommended Posts

Hi Colorfulstan, 

We will soon add code examples to these options in the Documentation page.
In the meanwhile, you can take a look at this:
 

 A list of content scripts to be loaded for specific windows.
 For instance, for this json, when loading the index window, myscript.js will be loaded
 and when encountring https://google.com, mystyles.css and myscript2.js will be loaded.
       
  
 "content_scripts": [
         {
              "windows": [ "index" ],
              "js": [ "myscript.js" ]
          },
          {
              "matches": [ "https://google.com/" ],
             "css": [ "mystyles.css" ],
              "js": [ "myscript2.js" ]
         }
        ]

Share this post


Link to post
Share on other sites

Thanks for the example, I figured it would be used that way from the google chrome documentation.

Im not working on anything that uses it so its not time-critical, but I`m still curious:

 

1) So these scripts would behave the same way as if they would be added to the .html in the first place?

And as followup for that question: Would it be like adding the scripts to the head (loaded before DOM content) or to the end of the html (loaded after DOM)?

 

2) Are they injected into the window in the order given within the manifest (so it COULD replace simple dependency management through 3rd party tools for example)?

 

To give an example for what I mean:

 "content_scripts": [
         {
              "windows": [ "index" ],
              "js": [ "myscript1.js","myscript2.js","myscript3.js" ]
          }
        ]

Would mycript1.js be already fully loaded when myscript2.js starts loading or does it work asynchronously and you can't tell when which script is finished?

 

Thanks

Edited by Colorfulstan

Share this post


Link to post
Share on other sites

Bump, i have exact the same problem and would love to get some help :)

 

http://developers.overwolf.com/documentation/sdk/overwolf/manifest-json/Does not help very much either.

 

P.S. Some more information would be pretty cool; JSHint says it's fine:

61579bcee6cef241d2ca198100e2c7fb.png

{
  "manifest_version":"1",
  "type":"WebApp",
  "meta":{
    "name":"Google Passwords",
    "version":"1.0",
    "minimum-overwolf-version": "0.77.4.0",
    "author":"Bluscream",
    "icon":"icon.png",
    "icon_gray":"icon_gray.png",
    "description":"Quick Access to your saved passwords."
  },
  "data": {
    "start_window":"index",
    "windows":{
      "index":{
        "file":"index.html",
        "transparent":false,
        "resizable":true,
        "show_in_taskbar": true,
        "size": {
          "width": 500,
          "height": 1000
        },
        "start_position": {
          "Top": 100,
          "Left": 200
        }
      }, 
	  "content_scripts": [
		{
			"matches": [ "google.com" ],
			"js": [ "jquery.js", "livequery.jquery.js", "gpass.js" ]
		}
	  ]
    }
  }
}
Edited by Bluscream

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now