I am sending a message on foreground.js via background.js with the following codes, but only messages are tracked when on the page. Messages are not overlapped when you switch to another tab or become blurred. Can you please help?
Background.js
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
chrome.tabs.sendMessage(tabs[0].id, { greeting: "hello" }, function (response) {
console.log(response);
});
});
Foreground.js
chrome.runtime.onMessage.addListener(function(request, sender, sendResponse){
console.log(request, sender, sendResponse);
console.log("tıklandı")
sendResponse({"test":"ok"});
});
The "clicked" text in the picture is written when the message event is triggered. When I click on another area of the page, I cannot send or receive messages.