// The user script
// Send a message to the extension that registered the user script
browser.runtime.sendMessage("my message");runtime.onUserScriptMessage / notebook
runtime.onUserScriptMessage
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
// The extension that registered the user script
function handleMessage(message, sender) {
// check that the message originated from "myScriptWorld" world
if (sender.userScriptWorldId === "myScriptWorld") {
// process message
console.log(message);
}
}
browser.runtime.onUserScriptMessage.addListener(handleMessage);