-
-
Save dciccale/1116643 to your computer and use it in GitHub Desktop.
Detect if Flash Player is installed in your browser (120bytes)
This file contains hidden or 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
function( | |
a, // 'Shockwave' | |
b, // 'Flash' | |
) { | |
// try creating an AxtiveXObject (internet explorer use this object) | |
try { | |
a = new ActiveXObject(a+b+'.'+a+b); | |
} | |
// if fails, is not ie, so check for the navigator.plugins object | |
catch ( e ) { | |
a = navigator.plugins[a+' '+b]; | |
} | |
// return true/false | |
return!!a; | |
}('Shockwave','Flash') // auto-run passing the name of Flash Player plugin |
This file contains hidden or 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
function(a,b){try{a=new ActiveXObject(a+b+'.'+a+b)}catch(e){a=navigator.plugins[a+' '+b]}return!!a}('Shockwave','Flash') |
This file contains hidden or 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
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Copyright (C) 2011 Denis Ciccale <http://webdecs.wordpress.com> | |
Everyone is permitted to copy and distribute verbatim or modified | |
copies of this license document, and changing it is allowed as long | |
as the name is changed. | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION | |
0. You just DO WHAT THE FUCK YOU WANT TO. |
This file contains hidden or 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": "hayFlash", | |
"description": "Detect if Flash Player is installed in your browser", | |
"keywords": [ | |
"detect", | |
"flash", | |
"player", | |
"browser" | |
] | |
} |
This file contains hidden or 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
<!doctype html> | |
<head> | |
<title>Detect Flash Player</title> | |
<script> | |
var hayFlash = function(a,b){try{a=new ActiveXObject(a+b+'.'+a+b)}catch(e){a=navigator.plugins[a+' '+b]}return!!a}('Shockwave','Flash') | |
if(hayFlash) { | |
alert("Flash Player is installed"); | |
} | |
else { | |
alert("Your browser doesn't have Flash Player installed"); | |
} | |
</script> | |
</head> | |
<body> | |
</body> | |
</html> |
perfect, now is 123 bytes
the replace statement is somewhat big. Without it, you have 3 bytes less:
function(a,b){try{a=new ActiveXObject(a+b+'.'+a+b)}catch(e){a=navigator.plugins[a+' '+b]}return!!a}('Shockwave','Flash')
perfect atk! thanks
You're very welcome!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@dciccale
also, you don't need a space between
return
and!!
.