0

The Safari extension framework explicitly does not support message passing between extensions. I'm looking for a workable hack to get around this, without letting the page know that extensions are running.

Suggestions (not tested):

  1. One extension opens a hidden tab to about:blank#extension-channel with openTab(). The other searches for that tab by URL and finds it. They produce and consume elements on that page to communicate.

  2. If extensions can read cookies across domains, one sets a cookie with a random ID at extension-homepage.com and the other reads it. They then create DOM events with the name extension-message-[the random ID]", so the page can't listen in.

  3. Petition the Safari developers to add onRequestExternal to their API ;)

Can you think of another approach? Have you gotten any of the above to work?

Michael Gundlach
  • 106,555
  • 11
  • 37
  • 41
  • I haven't tried this myself, but might [window.postMessage](https://developer.mozilla.org/en/DOM/window.postMessage) be of help? – chulster Apr 17 '12 at 21:38

2 Answers2

0

It is possible to use window.postMessage to pass messages between extensions, with the page in the current tab as an intermediary.

I've shared two very simple demo extensions as a proof of concept at https://github.com/canisbos/ClickClack. If you install them, you'll see that clicking one extension's toolbar button will cause the other's button image to flip.

chulster
  • 2,809
  • 15
  • 14
0

Let extension A open up a WebSocket connection to a WebSocket server implemented in Javascript by extension B. See socket.io, WebSocket-Node, etc. Allows robust bidirectional comm between two extensions, or between an extension and the outside world.