Last active
December 19, 2015 15:19
-
-
Save karlcow/5975683 to your computer and use it in GitHub Desktop.
LINKEDIN detection of User Agent in their main site.
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
YAHOO.env.ua = function() { | |
var D = function(H) { | |
var I = 0; | |
return parseFloat(H.replace(/\./g, function() { | |
return (I++ == 1) ? "" : "."; | |
})); | |
}, G = navigator, | |
F = { | |
ie: 0, | |
opera: 0, | |
gecko: 0, | |
webkit: 0, | |
mobile: null, | |
air: 0, | |
caja: G.cajaVersion, | |
secure: false, | |
os: null | |
}, C = navigator && navigator.userAgent, | |
E = window && window.location, | |
B = E && E.href, | |
A; | |
F.secure = B && (B.toLowerCase().indexOf("https") === 0); | |
if (C) { | |
if ((/windows|win32/i).test(C)) { | |
F.os = "windows"; | |
} else { | |
if ((/macintosh/i).test(C)) { | |
F.os = "macintosh"; | |
} | |
} if ((/KHTML/).test(C)) { | |
F.webkit = 1; | |
} | |
A = C.match(/AppleWebKit\/([^\s]*)/); | |
if (A && A[1]) { | |
F.webkit = D(A[1]); | |
if (/ Mobile\//.test(C)) { | |
F.mobile = "Apple"; | |
} else { | |
A = C.match(/NokiaN[^\/]*/); | |
if (A) { | |
F.mobile = A[0]; | |
} | |
} | |
A = C.match(/AdobeAIR\/([^\s]*)/); | |
if (A) { | |
F.air = A[0]; | |
} | |
} | |
if (!F.webkit) { | |
A = C.match(/Opera[\s\/]([^\s]*)/); | |
if (A && A[1]) { | |
F.opera = D(A[1]); | |
A = C.match(/Opera Mini[^;]*/); | |
if (A) { | |
F.mobile = A[0]; | |
} | |
} else { | |
A = C.match(/MSIE\s([^;]*)/); | |
if (A && A[1]) { | |
F.ie = D(A[1]); | |
} else { | |
A = C.match(/Gecko\/([^\s]*)/); | |
if (A) { | |
F.gecko = 1; | |
A = C.match(/rv:([^\s\)]*)/); | |
if (A && A[1]) { | |
F.gecko = D(A[1]); | |
} | |
} | |
} | |
} | |
} | |
} | |
return F; | |
}(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment