message passing between background and content
This commit is contained in:
parent
d169661e03
commit
e73d405c56
6 changed files with 19 additions and 23 deletions
9
src/content/index.js
Normal file
9
src/content/index.js
Normal file
|
@ -0,0 +1,9 @@
|
|||
window.addEventListener("keypress", (e) => {
|
||||
browser.runtime.sendMessage({
|
||||
which: e.which || e.keyCode,
|
||||
}).then((msg) => {
|
||||
console.log(`Message from the background script: ${msg.response}`);
|
||||
}, (err) => {
|
||||
console.log(`Error: ${err}`);
|
||||
});
|
||||
});
|
Reference in a new issue