serversideup / webext-bridge

💬 Messaging in Web Extensions made easy. Batteries included.
https://serversideup.net/open-source/webext-bridge
MIT License
547 stars 50 forks source link

sendMessage to injected script not working #33

Closed joeuan closed 1 year ago

joeuan commented 2 years ago

Version: 6.0.0-rc2

in content-script: allowWindowMessaging('test') sendMessage('hello', 'world', 'test')

in injected script(append a script element): import { setNamespace,onMessage } from 'webext-bridge/window' setNamespace('test') onMessage('hello', console.log )

get error when sendMessage: Bridge#sendMessage -> Destination must be any one of known destinations

zikaari commented 2 years ago

You need to use sendMessage('hello', 'world', 'window'). Namespace 'test' is just an internal setting that webext-bridge relies on.