I'm converting an Chrome extension which works well to Edge extension, and I need to have message listener in my content script.
Here is the code in my content script:
browser.runtime.onMessage.addListener(listener);
function listener(message) {
console.log(message);
}
However, each time script executes, I get this error, pointing to first line of my content script code:
Unable to get property 'onMessage' of undefined or null reference
I've tried changing browser.runtime into chrome.runtime, but nothing changes.
Here I've found that Edge supports runtime.onMessage with some minor incompatibilities: