How do you use chrome.tabs.getCurrent to get the page object in a Chrome extension?
The method getSelected()
has been deprecated since Google Chrome 16 (but many articles in the official documentation had not yet been updated). Official message is here. To get the tab that is selected in the specified window, use chrome.tabs.query()
with the argument {'active': true}
. So now it should look like this:
chrome.tabs.query({ currentWindow: true, active: true }, function (tabs) {
console.log(tabs[0]);
});
Try:
chrome.tabs.getSelected(null, function(tab){
console.log(tab);
});