I'm trying to get the index of my active tab using Javascript for my Google Chrome extension. What should I do?
Asked
Active
Viewed 1,266 times
1
-
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 Answers
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> });
});

Flat Screen
- 62
- 6