My problem is that I can't seem to get the message chrome.extension.sendMessage("on");
from my popup.js transfer to my content.js.
Code from the popup.js:
function click(e) {
if ( e.target.id == "green"){
chrome.extension.sendMessage("start");
console.info("oN");
return;
}
if ( e.target.id == "red"){
chrome.extension.sendMessage("stop");
console.info("oFF");
return;
}
}
The popup.js receives the message perfectly well when i add a listener to the code. But my content.js can't seem to get it.
Code from the content.js:
chrome.extension.onMessage.addListener(
function(request, sender, sendResponse) {
console.info("ok");
}
);
Manifest:
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["content.js"],
"run_at": "document_end"
}
],
Any help is greatly appreciated.