Created
December 9, 2021 14:33
-
-
Save bryanmylee/4cfa846a9410f762479cfbcd65b03c96 to your computer and use it in GitHub Desktop.
Send message to the active tab of a browser extension
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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