I have developed extensions for my web-application for Chrome and Firefox. Now I would like to check, if a user has already installed the extension. If not, a message with a download link pops up.
In order do have a common code basis, I chose an option that should work with Chrome as well as with Firefox. Unfortunately it only does on Chrome.
My Code:
//page.js
window.addEventListener("message", function(event){
if(event.data && event.data.direction == "from-content-script") {
document-getElementById("message").style = "display: none";
}
});
//content-script.js
window.postMessage({
direction: "from-content-script",
message: "Message from the content script"
}, "*");
//manifest.jsons
"content_scripts": [{
"matches": ["http://localhost:3000/*],
"js": ["content-script.js"]
}]
So on Chrome it works perfectly, but on Firefox it does not. I wonder if the content script is injected correctly, because if I include an alert for test purpose it does not show up.
I am referring to this: How to check if a Firefox WebExtension is installed or not with page JavaScript? but I cannot get it to work with firefox.
Thanks for your help!