I am trying to do my first addon which sends messages. I run into problems to recieve the message by the Content Script.
[pre]
chrome.commands.onCommand.addListener(
function(command) {
console.log("onCommand event received for message: ", command);
browser.tabs.sendMessage(
tabs[0].id, // tab id integer
command, // message
{} // options optional object
// , function(response) {…} // optional function
)
}
);
[/pre]
In the console I see that the message was send. In the content script which is connected using manifest.json
[pre]
“content_scripts”: [
{
“matches”: ["://.mozilla.org/*"],
“js”: [
“content_scripts/jquery-3.0.0.js”,
“content_scripts/easy.js”]
}
],
[/pre]
I have:
[pre]
chrome.runtime.onMessage.addListener(
function (m){
console.log(“Recieved message:”);
console.log(m);
}
);
[/pre]
After I loaded mozilla site and pressed shift+ctrl+U, I do not see the message “Recieved message” in the console.
All I see is:
onCommand event received for message: easy (background.js:46:5)
Please help