"use strict"; //Simple background script that seds a message to content script // code mainly from: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/sendMessage function onError(error) { console.error(`Error: ${error}`); } function sendMessageToTabs(tabs) { for (let tab of tabs) { browser.tabs.sendMessage( tab.id, {trigger: "extension click"} ).then(response => { }).catch(onError); } } browser.browserAction.onClicked.addListener(() => { browser.tabs.query({ currentWindow: true, active: true }).then(sendMessageToTabs).catch(onError); });