Plasmo Equivalent to chrome.runtime.onMessage.addListener
Hi, I am a total newbie trying to figure out how to send triggers from my popup window to my content script. Online I have been seeing examples of adding eventListeners. Does this work in Plasmo or is there a 'Plasmo specific' way to do this.
Thanks!
2 Replies
same question here!
I'm still new to Plasmo and browser extensions in general. I've sent messages from the sidebar to a content script with two different methods.
You can use the
chrome.*
methods inside a plasmo project. I've been experimenting with the native methods to learn a little more.
In sidepanel.tsx I used chrome.tabs.sendMessage
in an onClick handler to send the message.
Inside of my content script I used chrome.runtime.onMessage.addListener
to handle the message.
What I'm getting tripped up on now is getting a response back from the listener. For whatever reason the chrome.tabs.sendMessage
is returning before my content script even executes.