Code: Select all
async function closeAllTabs(activeTab)
{
const tabs = await browser.tabs.query({ currentWindow: true, active: false });
for (const tab of tabs)
browser.tabs.remove(tab.id);
browser.tabs.remove(activeTab.id); // Close the active tab last so that it would be first in the Recently Closed list.
}
browser.browserAction.onClicked.addListener(closeAllTabs);