Reputation: 61
I want to show custom bar ( notification like: Install our plugin. ) on our site if extension is not installed for Chrome, Firefox and Opera. None will be displayed if extension is installed.
The idea is:
1. User visits our site and a bar with message appears - "Hey, install our extensions".
2. User clicks on install and extension is installed. No need for the user to open it.
3. User visit our site again and the bar does not appear again as the extension is installed.
We talk only for installation check, not cookies.
So far I was able to find solutions only for Chrome: http://blog.kotowicz.net/2012/02/intro-to-chrome-addons-hacking.html
and Firefox: http://webdevwonders.com/detecting-firefox-add-ons/
Opera is never mentioned.
Is there a way to do it for Opera, based on the idea of checking for a local resource which is part of the extension:
chrome-extension://--Extension ID--/blank.gif
Firefox chrome://firebug/content/blank.gif
Or else: Is there a simple way to check if extension is installed for Chrome, Firefox and Opera?
Upvotes: 6
Views: 8059
Reputation: 27277
If the extension is willing to cooperate, it could advertise its presence to the document easily. For example:
The extension could do
window.$$myExt = ...
Then you can detect the extension by
if(typeOf $$myExt !== 'undefined'){...
(or any variation thereof)
Obtaining the page window
is somewhat tricky at least
The extension could do
document.body.classList.add("myExt-visited")
Then you could detect the extension by
if(document.body.classList.contains("myExt-visited")){...
The extension could do
document.body.innerHTML += "<div id='myExt-toolbar'>..."
// or $('body').append("<div id='myExt-toolbar'>...");
then you could detect the extension by
if(document.getElementByID("myExt-toolbar")){...
// or if($("#myExt-toolbar").length){...
alternatively, you could do
<div id="myExt-replacement">
...
and the extension would do
var replacement = document.getElementByID("myExt-replacement");
replacement && replacement.remove();
or you could do
function onMyExtExists(){
...
}
and the extension would do
onMyExtExists && onMyExtExists();
Upvotes: 4