문제

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