Sending messages to a content script in the "main" world

What's the current best practice for sending messages from a background script/popup/sidebar to a content script running in the "main" world? So far I've succeeded only by using another content script (bridge) to intercept messages via listen() and then relay them to the other content script using window.postMessage(). For the opposite direction the "main" world script uses sendToBackgroundViaRelay() and the bridge uses relayMessage() to forward it to the background. Perhaps something like sendToContentViaRelay() could be useful as well? Also the docs regarding the relayMessage() function are out of date as a second argument is no longer present in 0.89.2
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server