I’m trying to build a Chrome extension. However, I’m running into a problem. To reload the UI of the popup when a webpage is loaded. I wanted to realize this by adding a listener to popup.js and sending a message from content.js. The problem is that the message is sent but not received. Can someone help me?
popup.js:
chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
document.body.innerHTML = "";
if (request.text == "reloadSiteTab") {
reloadSiteTab(request.url);
}
});
content.js:
chrome.runtime.sendMessage(
{
"text": "reloadSiteTab",
"url": location.href
}
);