Reputation: 601
I was wanting to match my chrome extension run on both google.com
and twitch.tv.
I tried these two ways:
first way:
"content_scripts": [ {
"exclude_globs": [ ],
"include_globs": [ "*" ],
"js":["jquery.user.js","h.js", "main.js"],
"matches": ["*//google.com", "*//twitch.tv/"],
"run_at": "document_end",
"permissions":["tabs","<all_urls>"]
} ],
second way:
"content_scripts": [ {
"exclude_globs": [ ],
"include_globs": [ "*" ],
"js":["jquery.user.js","h.js", "main.js"],
"matches": ["*//google.com, *//twitch.tv/"],
"run_at": "document_end",
"permissions":["tabs","<all_urls>"]
} ],
The way where I separated the two with a quotation mark crashed and didn't work, the one where I didn't separate the URL's
ran only the first URL
(google)
So is there a way to make it run on two URLs
?
Thanks!
Upvotes: 2
Views: 4042
Reputation: 5118
permissions
goes outside content_scripts
. The match pattern for twitch.tv
has an extra slash. Try *//*.twitch.tv
manifest.json
"content_scripts": [ {
"js":["jquery.user.js","h.js", "main.js"],
"matches": ["*//*.google.com", "*//*.twitch.tv"],
"run_at": "document_end",
} ],
"permissions":["tabs","<all_urls>"]
Upvotes: 3
Reputation: 780
if you need to load conman js and css for both domain.
"content_scripts": [ { "matches": ["http://www.google.com/","https://www.twitch.tv/"], "css": , "js": "run_at": "document_end" //add this tag if you want to load js and css after document is ready } ],
if you need to load indivisual css and js for each domain
"content_scripts": [ { "matches": ["http://www.google.com/"], "css": , "js": "run_at": "document_end" //add this tag if you want to load js and css after document is ready }, { "matches": ["https://www.twitch.tv/"], "css": , "js": "run_at": "document_end" //add this tag if you want to load js and css after document is ready } ]
Upvotes: 0