"use strict"; function onError(error) { console.error(`Error: ${error}`); } function sendMessageToTabs(tabs) { for (let tab of tabs) { browser.tabs.sendMessage( tab.id, {command: "bookmark"} ).catch(onError); } } browser.commands.onCommand.addListener(function (command) { if (command === "bookmark") { browser.tabs.query({ currentWindow: true, active: true }).then(sendMessageToTabs).catch(onError); } });