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;
});
});