0

I'm developing an extension for Chrome, but I want my extension to work only if another is disabled/removed.

It means that when my users install my extension, I would like to tell them "if you install my extension, you have to accept to disable this other extension".

I don't want my extension to work if the other one is active.

Do you know how I could proceed?

Vico
  • 1,696
  • 1
  • 24
  • 57
  • 1
    https://developer.chrome.com/extensions/management#method-getAll – Marc Guiselin Mar 24 '16 at 04:51
  • 1
    this answer might be better: http://stackoverflow.com/questions/23462463/detecting-installed-chrome-extensions?rq=1 you might want to flag your question of being a duplicate. – Marc Guiselin Mar 24 '16 at 05:00

1 Answers1

2

To detect if another extension is installed:

1) Update the manifest.json to include the necessary management permission:

{
    "name": "My extension",
    ...
    "permissions": [
      "management"
    ],
    ...
}

2) To check if the extension is installed exist 2 options:

a) If you know the extension id, use the chrome.management.get(extensionId, function callback) method:

 var extensionId = '<the_extension_id>';
 chrome.management.get(extensionId, function(extensionInfo) {
    var isInstalled;
    if (chrome.runtime.lastError) {
      //When the extension does not exist, an error is generated
      isInstalled = false;
    } else {
      //The extension is installed. Use "extensionInfo" to get more details
      isInstalled = true;
    }
  });

b) If you know the extension name (or any other parameter), you can use chrome.management.getAll(function callback):

var extensionName = '<the_extension_name>';

chrome.management.getAll(function(extensions) {
    var isInstalled = extensions.some(function(extensionInfo) {
       return extensionInfo.name === extensionName;       
    });
});
Dmitri Pavlutin
  • 18,122
  • 8
  • 37
  • 41