I want to make a chrome extension that will connect to a localhost server to receive instructions to play songs in Grooveshark using the Grooveshark Javascript API. (http://grooveshark.com/GroovesharkAPI.html)
For example, if I type window.Grooveshark.addSongsByID([13963],true)
in the javascript console, it'll add the song and start playing like it should I need to be able to do this from the extension. So to start, I just wanted to make an extension with a background page and just this single script to execute the command:
background.html
<!doctype html>
<html>
<head>
<script src="background.js"></script>
</head>
<body>
</body>
</html>
background.js
chrome.browserAction.onClicked.addListener(function(tab) {
chrome.tabs.executeScript(
null, {code:"window.Grooveshark.addSongsByID([13963],true)"});
});
manifest.json
{
"name": "Play song in Grooveshark",
"version": "0.1.0",
"background_page": "background.html",
"permissions": [
"tabs", "http://*/*"
],
"browser_action": {
"name": "Play song",
"default_icon": "icon.png"
}
}
Could anyone tell me why it doesn't work?
Thank you very much!!