1

I'm trying to get the index of my active tab using Javascript for my Google Chrome extension. What should I do?

Angelina Tsuboi
  • 196
  • 1
  • 2
  • 14
  • 1) get the active tab ([example](https://stackoverflow.com/a/18437759)), 2) read the tab's `index` property. – wOxxOm Jun 20 '20 at 03:28

1 Answers1

1

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> });
});