Not seeing background hits with use of relay
Tried out several things to have the relay package hit my BGSW.
Currently attempting this:
and the background/messages/request.ts looks like this:
Any ideas on what I may be messing up?
14 Replies
Also tried a similar example to this and didn't see the request in the BGSW land. https://github.com/PlasmoHQ/examples/blob/main/with-messaging/contents/index.ts
GitHub
examples/index.ts at main Ā· PlasmoHQ/examples
š° Example projects that demonstrate how to use the Plasmo Framework and integrate with popular tools - examples/index.ts at main Ā· PlasmoHQ/examples
Here is what my
src/tabs/test.tsx
looks like when attempting to sendViaRelay from a tab.
Hahah it's tricky - so a send via relay in the mainworld needs to communicate with another relay in the isolated world - basically another content script with just a relay
So that it can then propagate down to bgsw
Clutch!!!
Added this as another content script and it worked:
@alank can you make a PR to the messaging example or maybe a guide on the docs about the above - I bet it would save a lot of poor soul venturing into this part of the extension world lol
Can do, glad to help out š
and thank you for your time on this!
Gave +1 Rep to @louis
Hey! I just bumped into your thread and was wondering how you got this working, so basically you:
1. Injected the "tryFunc" into the main world
2. Created a background message handler
3. Created a new content script that receives the relay message and sends down the message to the background script?
4. Sent the same message from tabs?
I'm having the same issue but from a different webapp trying to send a relay message to my CSUI script and down to the BGSW but I can't get it to work
Correct. Although right now Iām not doing it through the tab but rather calling the func from chrome devtools
Will ensure the tabs works and confirm
so I cant seem to get the injected object into the tab although I can have it in an normal page
@alank has reached level 5. GG!
I ended up switching to runtime.sendMessage with runtime.onExternalMessage
that fixed it for you?
Yep. But it's because my use case is tricky ig: I have a whole different web app in a different repo and I wanna communicate with the extension to share the auth info. I ended up adding the url to "externally_connectable" inside the manifest and communicating with the extension via chrome.runtime.sendMessage. It works.
GitHub
Add main world to bgsw flow example to with-messaging by alanorwick...
Added example of the secondary content script to handle main world content script relays. I was unable to see the injected window.relay on http://localhost:1947/ so I left matching params as <al...