質問

I'm new to chrome extensions but I have a question concerning content scripts.

I want to execute a specific js file if the user accesses a specific domain, and another different js file if they access a different one.

My question is, how can I do this inside the manifest.json file?

This is what I have so far:

    "content_scripts": 
         [{"matches": ["http://store.example.com/*"], "js": ["store.js"]}], 
         [{"matches": ["https://purchase.example.com/*"], "js": ["purchase.js"]}]

    "permissions":["tabs", "http://store.example.com/*"]

But I keep getting an error. Thank you!!

役に立ちましたか?

解決

The format of your content_scripts declaration is incorrect. Try this:

"content_scripts": [
    {"matches": ["http://store.example.com/*"], "js": ["store.js"]},
    {"matches": ["https://purchase.example.com/*"], "js": ["purchase.js"]}
],
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top