Hi there ! I'm building my first GC extension, and I am having a problem using this function.
I would like to get the url of the current tab, and to do so (after some google research, of course), I use the chrome.tabs.getSelected() function. Here it is in my code :
...
socket.onopen = function(msg){ log("Welcome - status " + this.readyState);
chrome.tabs.getSelected(null, function(tab){ sendUrl(tab.url); }); };
function sendUrl(tabUrl)
{
socket.send("#URL#"+ tabUrl);
}
The socket.open is a listener for the Websocket API I use in my extension.
The log function print the status of the socket (1, which means it's OPEN or connected and ready to communicate, according to the Websocket API), but the chrome.tabs.getSelected() function do not seems to work, as the server do not receive anything (the socket is not the problem here, I tried to send a test message with socket.send() instead of chrome.tabs.getSelected() and the server received it).
I put the permissions: ["tabs"] into the manifest.json so I can use this function.
So I don't know what I am doing wrong here ? I also tried to put chrome.tab.getSelected() elsewhere in the code, but it is still not working.
Any help is welcome :)