runtime.onUserScriptConnect
Please help us by answering a few questions.
Fired when a connection is made with a user script from one of the extension's USER_SCRIPT
worlds.
In Firefox, this event requires the userScripts
permission. In Chrome, the event is always present, including in extensions that don't declare the userScripts
permission.
A user script can only connect and then sent messages from a USER_SCRIPT
world that is configured by userScripts.configureWorld()
with messaging
set to true
.
Syntax
browser.runtime.onUserScriptConnect.addListener(listener)
browser.runtime.onUserScriptConnect.removeListener(listener)
browser.runtime.onUserScriptConnect.hasListener(listener)
Events have three functions:
addListener(listener)
-
Adds a listener to this event.
removeListener(listener)
-
Stop listening to this event. The
listener
argument is the listener to remove. hasListener(listener)
-
Checks whether a
listener
is registered for this event. Returnstrue
if it is listening,false
otherwise.
addListener syntax
Parameters
function
-
The function called when this event occurs. The function is passed this argument:
port
-
runtime.Port
. An object connecting the current script to the other context.
Browser compatibility
Report problems with this compatibility data on GitHubdesktop | mobile | ||||||
---|---|---|---|---|---|---|---|
onUserScriptConnect |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
- See implementation notes.