5

I was looking for a way to detect the browser extension I am building from my website and I need to alert my users in-case they are viewing my site without it. I have been able to do this in firefox, but I want to know is there a way I can do this in Google Chrome? Even if there is a hack to get this going I am fine.

JJJ
  • 32,902
  • 20
  • 89
  • 102

2 Answers2

2

Sure. Create a content script specific to you site in the extension, and make it add an invisible marker in the DOM, eg:

$('body').append('<div style="display: none;" class="extension_enabled" />');

In the page, set a short timeout to check for this after the document is fully loaded, eg:

$(function() {
  setTimeout(function() {
    if ($('.extension_enabled').length > 0) {
      alert('Installed!');
    } else {
      alert('Not installed.');
    }
  }, 500);
});

NOTE: Code in jQuery format for simplicity. You can do it with raw javascript, of course.

Max Shawabkeh
  • 37,799
  • 10
  • 82
  • 91
2

The official Google Chrome Extensions Developers' Guide has an item covering exactly this.

Community
  • 1
  • 1
Scott Wolchok
  • 506
  • 3
  • 5
  • 1
    Unfortunately that link no longer works. This answer works as of 2/27/2014: http://stackoverflow.com/a/13734347/2266428 with Version 32.0.1700.107 m of Chrome. – J E Carter II Feb 27 '14 at 17:47