Last active
October 20, 2023 16:48
-
-
Save greatghoul/321b4f32c0b7a6ad8a97 to your computer and use it in GitHub Desktop.
Chrome Extension Sample - detect if an extension is installed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<body style="width: 400px; height: 150px;"> | |
<div id="output"></div> | |
<script type="text/javascript" src="popup.js"></script> | |
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Do you know how to detect if an extension is pinned, like Total Ad Block extension does?