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:Jump to 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.
4 Replies
@MarkusT has reached level 1. GG!
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.
@Sam has reached level 3. GG!
Oh I recon that could work lol. Thanks