I have a background script where I send a message after I pressed hotkey but the content script does not intercept it. Why? I added breakpoint to the line with if (package.command) … and some other lines and nothing paused. The message is send successfully.
background script:
// Get current tab id
chrome.tabs.query(
{
active: true,
currentWindow: true // send message to the active window
},
function(tabs) {
chrome.tabs.sendMessage( tabs[0].id, package )
}
content script:
chrome.runtime.onMessage.addListener(
function(package){
if (package.command) ...
}
)
This is because yesterday or maybe today’s morning it worked. I mean I could inject css styles to web-page when I pressed the hotkey. No I cannot.