You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey, I'm a ViolentMonkey user, and I'm suggesting a new API GM_messageExtension,
which wrap the browser.runtime.sendMessage for userscript,
so they can send message to other extensions.
(Few people know that pass other extension's id as first argument
to browser.runtime.sendMessage will send message to other extension's onMessageExternal handler.)
API design
The userscript have to @grant GM_messageExtension.
The userscript have to declare the extension id they want to connect with @connect web-extension://[email protected] or web-extension://*
I make use of the existing @connect meta field in TamperMonkey (API).
Currently, the @connect only affect the GM_xmlHttpRequest.
In future, GM_messageExtension will require the userscript to specify the extension id it want to connect in it, too.
use case
Some extensions like TreeStyleTab (api), WebScrapbook or SingleFile
do accept message from other extensions.
E.g, we can trigger WebScrapbook or SingleFile to save a page by sending they a message. (its API)
For myself, I need this API because I want to trigger SingleFile download the webpage easily on android.
Eg, I can put a display:fixed button on some domain with userscript, and click it to trigger the downloading.
Without this, I have to open the browser menu / (scroll and) open extension list / click SingleFile .
who can send message
To accept external message, an extension have to listening on the browser.runtime.onMessageExternal event.
By default, message from all the other extensions and the website specified in the externally_connectable.matches[] (API) will fire this event,
though Firefox does not support sending message from website now.
Seldom extensions accept message from website, but some accept message from other extensions.
Basically, which website will try to call WebScrapbook or TreeStyleTab?
Extensions can explicitly restrict the source of message by set the externally_connectable.ids[] , too.
about this issue
I have draft a PR for ViolentMonkey.
I just wondering whether other UserScript add-on will interested in this API.
Any comment is welcome!
The text was updated successfully, but these errors were encountered:
Hey, I'm a ViolentMonkey user, and I'm suggesting a new API
GM_messageExtension
,which wrap the
browser.runtime.sendMessage
for userscript,so they can send message to other extensions.
(Few people know that pass other extension's id as first argument
to browser.runtime.sendMessage will send message to other extension's
onMessageExternal
handler.)API design
@grant GM_messageExtension
.@connect web-extension://[email protected]
orweb-extension://*
I make use of the existing
@connect
meta field in TamperMonkey (API).Currently, the
@connect
only affect the GM_xmlHttpRequest.In future,
GM_messageExtension
will require the userscript to specify the extension id it want to connect in it, too.use case
Some extensions like TreeStyleTab (api), WebScrapbook or SingleFile
do accept message from other extensions.
E.g, we can trigger WebScrapbook or SingleFile to save a page by sending they a message. (its API)
For myself, I need this API because I want to trigger SingleFile download the webpage easily on android.
Eg, I can put a
display:fixed
button on some domain with userscript, and click it to trigger the downloading.Without this, I have to open the browser menu / (scroll and) open extension list / click SingleFile .
who can send message
To accept external message, an extension have to listening on the browser.runtime.onMessageExternal event.
By default, message from all the other extensions and the website specified in the
externally_connectable.matches[]
(API) will fire this event,though Firefox does not support sending message from website now.
Seldom extensions accept message from website, but some accept message from other extensions.
Basically, which website will try to call WebScrapbook or TreeStyleTab?
Extensions can explicitly restrict the source of message by set the
externally_connectable.ids[]
, too.about this issue
I have draft a PR for ViolentMonkey.
I just wondering whether other UserScript add-on will interested in this API.
Any comment is welcome!
The text was updated successfully, but these errors were encountered: