On button click, I'm trying to send message, but my listener is invoked multiple times.
popup.js:
chrome.tabs.sendMessage(tab.id, {action: "write", data: getData()}, function (response) {
console.log(response,"!!!!");});
content.js:
chrome.runtime.onMessage.addListener(test);
function test(request, sender, sendResponse) {
if (request.action === "write") {
console.log("write");
}
return true;
}
Has anyone an idea what I am doing wrong?