I am trying to find an easy way to detect if my extension is installed in Firefox 3.6. This should be done from a webpage, probably using javascript.
I've read a lot of blogs that says that I should try loading an image from my extension. Since I own the extension, and I can write the code, that seems like an unnecessary hack.
I've also thought about setting a global variable to the web document, but I havn't been able to achieve this. I thought I would be able to write:
top.window.content.document.hasMyPlugin = true
but this is doesn't seem to work (hasMyPlugin is not defined). I only add this variable when visiting my domain (I have added a WebProgressListener and check the host property), so global namespace pollution shouldn't be a problem.
Any ideas?
UPDATE
The way I try to access the variable is simply if(hasMyPlugin)
or if(document.hasMyPlugin)
... Perhaps I'm accessing it the wrong way?
One simple way is to make your extension react to a user-defined event. Your web page dispatches the event on an appropriate event target (you can use the document if you have nothing better) and then your extension's event listener can verify the web page address and perform an action. At the very minimum your event listener could call preventDefault() on the event; the web page could then call getPreventDefault() to see whether your extension is present.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With