I want to be able to log the tagname of the button which is clicked. If I try to log something in my content.js
nothing gets displayed. The content.js
is executed because I can see my log from background.js
. Why logs from my content.js
arent displayed?
background.js
chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
if (request.type == "click_event") {
console.log("click event captured in current webpage");
//Call the callback passed to chrome.action.onClicked
}
});
content.js
document.addEventListener("click", () => {
console.log("some log which is not displayed")
chrome.runtime.sendMessage({
type: "click_event"
});
})