Created
March 28, 2017 04:02
-
-
Save kukfa/4cdcdf3942500f9bbda9fae56ed0408b to your computer and use it in GitHub Desktop.
Detect Chrome extensions using blocked requests
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
<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