mirror of
https://github.com/mdn/webextensions-examples.git
synced 2026-04-24 02:02:53 +02:00
Updated for review comments
This commit is contained in:
@@ -1,23 +1,24 @@
|
||||
|
||||
/*
|
||||
Define a function in the content script's scope, then export it
|
||||
into the page script's scope.
|
||||
*/
|
||||
/**
|
||||
* Define a function in the content script's scope, then export it
|
||||
* into the page script's scope.
|
||||
*/
|
||||
function notify(message) {
|
||||
chrome.runtime.sendMessage({content: "Function call: " + message});
|
||||
browser.runtime.sendMessage({content: "Function call: " + message});
|
||||
}
|
||||
|
||||
exportFunction(notify, window, {defineAs:'notify'});
|
||||
/*
|
||||
Create an object that contains functions in the content script's scope,
|
||||
then clone it into the page script's scope.
|
||||
|
||||
Because the object contains functions, the cloneInto call must include
|
||||
the `cloneFunctions` option.
|
||||
*/
|
||||
/**
|
||||
* Create an object that contains functions in the content script's scope,
|
||||
* then clone it into the page script's scope.
|
||||
*
|
||||
* Because the object contains functions, the cloneInto call must include
|
||||
* the `cloneFunctions` option.
|
||||
*/
|
||||
var messenger = {
|
||||
notify: function(message) {
|
||||
chrome.runtime.sendMessage({content: "Object method call 1: " + message});
|
||||
browser.runtime.sendMessage({content: "Object method call: " + message});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user