Last active
November 8, 2019 09:50
-
-
Save pushandplay/9740636 to your computer and use it in GitHub Desktop.
Detect Browser version (Yandex.Browser support)
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
navigator.checkBrowser = -> | |
ua = navigator.userAgent | |
M = ua.match(/(opera|yabrowser|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) | |
if /trident/i.test(M[1]) | |
tem = /\brv[ :]+(\d+)/g.exec(ua) or [] | |
return name: 'ie', version: (tem[1] or '') | |
if M[1] is 'Chrome' | |
if (tem = ua.match(/\bOPR\/(\d+)/))? | |
return name: 'opera', version: tem[1] | |
if (tem = ua.match(/\bYaBrowser\/(\d+)/))? | |
return name: 'yabrowser', version: tem[1] | |
M = if M[2] then [M[1], M[2]] else [navigator.appName, navigator.appVersion, '-?'] | |
if (tem = ua.match(/version\/(\d+)/i))? | |
M.splice(1, 1, tem[1]) | |
name: M[0].toLowerCase() | |
version: M[1] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment