mirror of
https://github.com/mdn/webextensions-examples.git
synced 2026-04-16 06:18:35 +02:00
* Replace var with let in examples store-collected-images/webextension-plain/deps/uuidv4.js * Reverted third–party code
20 lines
415 B
JavaScript
20 lines
415 B
JavaScript
/*
|
|
On startup, connect to the "ping_pong" app.
|
|
*/
|
|
let port = browser.runtime.connectNative("ping_pong");
|
|
|
|
/*
|
|
Listen for messages from the app.
|
|
*/
|
|
port.onMessage.addListener((response) => {
|
|
console.log("Received: " + response);
|
|
});
|
|
|
|
/*
|
|
On a click on the browser action, send the app a message.
|
|
*/
|
|
browser.browserAction.onClicked.addListener(() => {
|
|
console.log("Sending: ping");
|
|
port.postMessage("ping");
|
|
});
|