I'm trying to run code when some press my icon in my chrome extension. When i used to run the code with code: "code..." it changed the title but didn't run the jquery code. I read that you need to execute it from a file so i added a file. Now both of them doesn't work, before the title was changed (when i used code) and now (when i use the file) it doesn't work. I added alerts to see what code run, none of them work, not even the first
I got the following app:
manifest.json:
{
"name": "Pandora Likes",
"version": "0.0.1",
"manifest_version": 2,
"background": { "scripts": ["background.js"] },
"browser_action": {
"default_icon": {
"19": "icons/19x19.png"
},
"default_title": "Pandora Likes"
},
"permissions": ["tabs","http://*/","https://*/"]
}
background.js:
function onClick() {
chrome.tabs.query({},function(array_of_Tabs) {
for(var i=0;i<array_of_Tabs.length; i++){
if(array_of_Tabs[i].url.indexOf('pandora.com')> -1) {
//chrome.tabs.update(array_of_Tabs[i].id, { selected: true });
chrome.tabs.executeScript(array_of_Tabs[i].id,{file: "like.js"});
}
}
});
}
chrome.browserAction.onClicked.addListener(onClick);
like.js:
alert("before");
document.title='gaga';
alert('after');
console.log("before);
$('.thumbDownButton').click();
console.log("after);
Thank you for your help