getSelected
has been deprecated. The new way to do it is:
chrome.tabs.query(
{currentWindow: true, active : true},
function(tabArray){...}
)
If you want to perform some callback on the active tab, you can wrap the above as so:
function doInCurrentTab(tabCallback) {
chrome.tabs.query(
{ currentWindow: true, active: true },
function (tabArray) { tabCallback(tabArray[0]); }
);
}
For example
var activeTabId;
doInCurrentTab( function(tab){ activeTabId = tab.id } );
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…