最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

JavaScript check if browser extension is installed for Chrome, Firefox and Opera - Stack Overflow

programmeradmin4浏览0评论


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: .html
and Firefox: /
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?


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/2012/02/intro-to-chrome-addons-hacking.html
and Firefox: http://webdevwonders./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?

Share Improve this question edited Jan 18, 2013 at 12:32 user1990249 asked Jan 18, 2013 at 12:02 user1990249user1990249 611 silver badge4 bronze badges 10
  • 1 It's quite easy if the extension is willing to cooperate – John Dvorak Commented Jan 18, 2013 at 12:03
  • Or if that extension leaves traceable info like some unique element or attributes in DOM. – nil Commented Jan 18, 2013 at 12:05
  • Or if that extension leaves something in the global scope - that's what I meant by cooperation – John Dvorak Commented Jan 18, 2013 at 12:06
  • If you're trying to autodetect adblock, you could give it a honeypot - or just test the presence of the real ads you've added. – John Dvorak Commented Jan 18, 2013 at 12:11
  • So, what is the extension you're trying to detect? – John Dvorak Commented Jan 18, 2013 at 12:11
 |  Show 5 more ments

1 Answer 1

Reset to default 4

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();
发布评论

评论列表(0)

  1. 暂无评论