Messaging between two content scripts

Hi! How would I go on to send a message from one content script to another using Plasmo? The basic chrome.runtime doesn't work and the Plasmo messaging functionality seems to be working backend <-> CS but not between CS. E.g if I use sendToContentScript, I get a 'Error: Extension tabs API is not available' during runtime.
Solution:
If they're in the same world wouldn't they have access to each other? Could you use window.postMessage? https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage
Window: postMessage() method - Web APIs | MDN
The window.postMessage() method safely enables cross-origin communication between Window objects; e.g., between a page and a pop-up that it spawned, or between a page and an iframe embedded within it.
Jump to solution
4 Replies
Arcane
Arcane•11mo ago
@MarkusT has reached level 1. GG!
Solution
Sam
Sam•11mo ago
If they're in the same world wouldn't they have access to each other? Could you use window.postMessage? https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage
Window: postMessage() method - Web APIs | MDN
The window.postMessage() method safely enables cross-origin communication between Window objects; e.g., between a page and a pop-up that it spawned, or between a page and an iframe embedded within it.
Arcane
Arcane•11mo ago
@Sam has reached level 3. GG!
MarkusT
MarkusT•11mo ago
Oh I recon that could work lol. Thanks
Want results from more Discord servers?
Add your server