Skip to content

Instantly share code, notes, and snippets.

@kukfa
Created March 28, 2017 04:02
Show Gist options
  • Save kukfa/4cdcdf3942500f9bbda9fae56ed0408b to your computer and use it in GitHub Desktop.
Save kukfa/4cdcdf3942500f9bbda9fae56ed0408b to your computer and use it in GitHub Desktop.
Detect Chrome extensions using blocked requests
<script>
var extensions = {
'fngmhnnpilhplaeedifhccceomclgfbg': 'EditThisCookie',
'aohghmighlieiainnegkcijnfilokake': 'Google Docs',
'kajibbejlbohfaggdiogboambcijhkke': 'Mailvelope',
'badTestID': 'fakePlugin'
};
var detectedPlugins = [];
for (var extensionID in extensions) {
var testImage = new Image();
testImage.onerror = function() {
// if plugin is installed, chrome will block the request and change the src
if (this.currentSrc == "chrome-extension://invalid/") {
// extract the extension ID from the original source
var extID = this.src.match(/^chrome-extension?\:\/\/([^\/?#]+)(?:[\/?#]|$)/i)[1];
detectedPlugins.push(extensions[extID]);
}
};
testImage.src = "chrome-extension://" + extensionID + "/manifest.json";
}
window.onload = function() {
console.log(detectedPlugins);
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment