In the manifest.json file, add the following:
"permissions":[ "background", "tabs" ], "background" : { "scripts": ["scripts/background.js"], "persistent": false }
In your background.js:
chrome.tabs.onActivated.addListener(function(activeInfo) { console.log(activeInfo.tabId);
});
source share