I'm trying to make a chrome extension that closes any tab that's created after a certain amount of tabs (for testing I've set it to 1) has already been opened.
I tried using chrome.tabs.onCreated.addListener( but I'm not sure why it's not working.
As for checking the number of tabs currently open, I've come across chrome.tabs.query() but I'm not quite sure how to use it.
let tabsCount;
chrome.tabs.onCreated.addListener(function(tab){
//get number of tabs??
if (tabsCount > 3) {
window.closeTab()
}
});