Skip to content

Instantly share code, notes, and snippets.

@bryanmylee
Created December 9, 2021 14:33
Show Gist options
  • Save bryanmylee/4cfa846a9410f762479cfbcd65b03c96 to your computer and use it in GitHub Desktop.
Save bryanmylee/4cfa846a9410f762479cfbcd65b03c96 to your computer and use it in GitHub Desktop.
Send message to the active tab of a browser extension
async () => {
const [activeTab] = await browser.tabs.query({
active: true,
currentWindow: true,
});
const response = await browser.tabs.sendMessage(activeTab.id, {
greeting: "hello",
});
console.log("main.js received response:", response);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment