Add GM_messageExtension allowing userscript to trigger other WebExtension#2146
Add GM_messageExtension allowing userscript to trigger other WebExtension#2146GHolk wants to merge 4 commits intoviolentmonkey:masterfrom
Conversation
|
There's no need for GM_webextSendMessage: if another extension can listen to external messages (by declaring |
|
@tophf No it can't, browser or chrome both are undefined. I am not meaning communicate from webpage, which require specifying url in |
|
I see. We don't plan to expose WebExtensions API to userscripts. There are other extension(s) that can do it, but I don't remember the name. |
|
We already wrap and expose some, like notification and xhr to any domain. I ask and publish my fork PurpleMonkey on amo several month ago. |
|
Those are parts of the userscript API that existed for like 20 years. If you want to convince me or other userscript extension teams please provide some motivational use cases that demonstrate how it can be used. |
|
For myself, I need this API because I want to trigger the extension SingleFile download the webpage easily. I write code, so I add this feature to make my life easy. In fact, I does not use this feature often. I know tha add a new |
|
Sounds useful, but since it's the first time I see this feature being suggested, I'm not sure it should be added at all. Maybe you could open a feature request in Tampermonkey and Firemonkey? Make sure to describe the use case and the fact that this solution doesn't require I also don't like the @gera2ld, WDYT? |
ok
That's a better name than mine. I will use it before the PR get merged.
It may take large effort to wrap the connect API since it will be a long connection, |
|
|
|
I am also interested in this, the arguments against it don't appear to have solid footing. A toolbox without niche, but essential, tools doesn't make for a great toolbox. Tools will be used when made available, similarly sending runtime messages is crazy useful for "hacking" your own behavior triggers into extensions via userscripts. How it can be used is not difficult to imagine, and even then, just because you may not see why someone would need a pair of side-snips, doesn't mean the tool is useless. One hard use case for me is being able to trigger page snapshots via a userscript for an extension that only has the capability to trigger snapshots manually. I can write my own userscript to elegantly handle the automated snapshot logic, and call the extension to actually trigger the snapshot. I have a difficult time understand the argument that "It's been this way for xxx years, why change/add?" when technology, especially web, clocks ahead at a terrifying pace every year. There will always be new, evolving, use cases as the ecosystem changes and shifts. It's kind of a
|
|
For anyone interested in this: |
This API allow userscript to communicate with other extensions
if they do listen on the (browser.runtime.on)MessageExternal event.
The script should also declare the extension id it want to communicate with
in the
@connectmetadata block.Different from Tampermonkey's connect field,
the ajax will not restricted to the URL in the connect field.
These commits only check the connect field with
web-extension://prefixand restrict the GM_webextSendMessage's destination id.
I am not very familiar with this project,
any advice or improvement is wellcome!
future work
Even if they declare
web-extension://*or violentmonkey's id.so the other will not only see the sender is violent monkey.