Reputation: 4130
I want to activate some Scripts on twitch.tv with a chrome extension.
So I got a file called script2.js and a file called script3.js
In my manifest, I want to say www.twitch.tv is loaded script2.js has to be loaded, and if www.twitch.tv/directory is loaded, script3.js has to be loaded:
{
"content_scripts": [{
"js": [ "script2.js" ],
"matches": [ "*://*.twitch.tv/" ]
}, {
"js": [ "script3.js" ],
"matches": [ "*://*.twitch.tv/directory" ]
} ],
"description": "desc",
"manifest_version": 2,
"name": "TwitchTV",
"permissions": [ "*://*.twitch.tv/*" ],
"version": "1.0"
}
script2 is loaded, but script3 not. Am I doing something wrong?
EDIT:
Well with looking into the manifest I mentioned, the manifest is right. I added an alert("test"); on top of my script and the alert is triggerd, so the script is executed correctly. But:
I add some new Buttons onto the site. And if I copy&paste my script3.js to the chrome-console on twitch.com/directory, the new buttons will be shown. But if the script is executed by chrome the buttons are not there.
Why could this be, that the script seems to be correct (because if i load it manually it works) but if its loaded automatically its wrong?
Upvotes: 1
Views: 4635
Reputation: 58
Reverse the two rules, because the first will always match
{
"js": [ "script3.js" ],
"matches": [ "*://*.twitch.tv/directory" ]
},
{
"js": [ "script2.js" ],
"matches": [ "*://*.twitch.tv/" ]
}]
Upvotes: 2