I am sending a message from the contentscript to popup and trying to show the received message when the extension is clicked.
I can see that the message is being received only when I Inspect popup
contentscript.js
console.log("content script");
chrome.runtime.sendMessage("hello",function(response)
{
console.log("sending message");
});
popup.js
console.log("popup script");
function onReq(request, sender, sendResponse)
{
ph=request;
console.log("msg: "+request);
document.getElementById("para").innerHTML = "msg: "+request;
}
chrome.runtime.onMessage.addListener(onReq);
popup.html
<!doctype html>
<html>
<head>
<title>Example</title>
</head>
<body>
<div id="status"></div>
<p id="para">shows received message here</p>
</body>
<script src="popup.js"></script>
</html>
I want to receive the message and show the message when clicked without having to open the console. How can I achieve this.