Last active
December 19, 2015 11:59
-
-
Save gabeidx/5951233 to your computer and use it in GitHub Desktop.
Browser detection
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
/* Browser 1.2.0 | @gabrielizaias | MIT/GPL2 Licensed */ | |
(function () { | |
'use strict'; | |
var b = navigator.userAgent.toLowerCase(), | |
e = document.getElementsByTagName('html')[0], | |
c = b.indexOf('macintosh') !== -1 ? 'macintosh' : b.indexOf('windows') !== -1 ? 'windows' : b.indexOf('linux') !== -1 ? 'linux' : undefined, | |
a = /(chrome)(?:.*chrome)?[ \/]([\w.]+)/.exec(b) || /(safari)(?:.*version)?[ \/]([\w.]+)/.exec(b) || /(opera)(?:.*version)?[ \/]([\w.]+)/.exec(b) || /(ie) ([\w.]+)/.exec(b) || !/compatible/.test(b) && /(firefox)(?:.*firefox)?[ \/]([\w.]+)/.exec(b) || [], | |
f = e.className.split(' '); | |
f.push(a[1], a[1]+parseInt(a[2], 10), c, navigator.platform) | |
e.className = f.join(' ').replace(/^[\s\xA0]+|[\s\xA0]+$/g, ''); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment