chrome.runtime.sendMessage not working as expected
问题 I am writing a Chrome plugin with a content script and a background script, and I am trying to make the two communicate. In my content script, I am doing chrome.runtime.sendMessage({greeting: "hello"}, function(response) { console.log(response.farewell); }); and in my background script, I am doing chrome.runtime.onMessage.addListener( function(request, sender, sendResponse) { console.log(sender.tab ? "from a content script:" + sender.tab.url : "from the extension"); if (request.greeting ==