0

should check INSTALLED and ENABLED.

i wanna let my website page check whether the visitor Installed and Enabled my chrome extension.

how to do ?

user1566268
  • 75
  • 11

1 Answers1

0

A simple trick would be to have your Chrome extension inject a Content Script in your webpage.

Although, this content script runs in an isolated scope it has access to the DOM and can set a particular elements "data-" attribute and this can be checked in a JS function on your page and you can find out is your extension is installed and enabled.

Community
  • 1
  • 1
Udbhav
  • 220
  • 3
  • 9
  • Instead of setting an attribute, I recommend to create a custom event, and fire it. An example of communicating between a page and a content script is shown here: http://stackoverflow.com/a/9636008 – Rob W Jul 28 '12 at 20:49
  • @RobW Would be interested to hear why you think that? I've used the DOM method before, but if an event's better I'd be all ears. – Tom Ashworth Jul 29 '12 at 08:27
  • @TomAshworth Content scripts are usually executed after the domready event. The page has to keep polling to see whether the attribute exusts or not. When the extension isn't installed, the page still attempts to see whether the extension is activated or not. When an event is used, the page doesn't have to poll: It can bind extension-specific logic to an event listener, which is triggered by the event. In both cases, you should attach the property/event listener to the root element, `document.documentElement`. (The attribute also shows up in the dev tools, that may be a (dis)advantage). – Rob W Jul 29 '12 at 08:39