runtime.onUserScriptConnect
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
listenerargument is the listener to remove. hasListener(listener)-
Checks whether a
listeneris registered for this event. Returnstrueif it is listening,falseotherwise.
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
Loading…