Skip to content

Instantly share code, notes, and snippets.

@greatghoul
Last active October 20, 2023 16:48
Show Gist options
  • Save greatghoul/321b4f32c0b7a6ad8a97 to your computer and use it in GitHub Desktop.
Save greatghoul/321b4f32c0b7a6ad8a97 to your computer and use it in GitHub Desktop.
Chrome Extension Sample - detect if an extension is installed.
{
"name": "Detect if an extension installed",
"description": "Detect if an extension installed",
"version": "0.1",
"manifest_version": 2,
"permissions": [
"management"
],
"browser_action": {
"default_popup": "popup.html"
}
}
<body style="width: 400px; height: 150px;">
<div id="output"></div>
<script type="text/javascript" src="popup.js"></script>
</body>
var extensionIds = [
["Session Buddy", "edacconmaakjimmfgnblocblbcdcpbko"],
["Readability", "oknpjjbmpnndlpmnhmekjpocelpnlfdi"]
];
extensionIds.forEach(function(extension) {
var output = document.getElementById('output');
chrome.management.get(extension[1], function(result) {
var extensionElement = document.createElement('div');
console.log(result);
if (result) {
extensionElement.innerHTML = ""
+ "<h3>" + result.name + " (" + result.id + ")</h3>"
+ "<p>" + result.description + "</p>";
} else {
extensionElement.innerHTML = ""
+ "<h3>" + extension[0] + " (" + extension[1] + ")</h3>"
+ "<p style=\"color: red;\">Not installed</p>";
}
output.appendChild(extensionElement);
});
});
@volomike
Copy link

Do you know how to detect if an extension is pinned, like Total Ad Block extension does?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment