I'm trying to get the index of my active tab using Javascript for my Google Chrome extension. What should I do?
Does this help? It also depends on where it is executed from. This snippet is executed on a window event from popup.
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
chrome.tabs.executeScript(
tabs[0].id,
{ code: <your code> });
});