mirror of
https://github.com/lancedikson/bowser
synced 2024-10-27 20:34:22 +00:00
Add support for detecting PhantomJS
This commit is contained in:
parent
975a408f15
commit
26b760b0b1
@ -19,13 +19,15 @@
|
|||||||
* iPad: "Mozilla/5.0 (iPad; U; CPU OS 4_3_2 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8H7 Safari/6533.18.5",
|
* iPad: "Mozilla/5.0 (iPad; U; CPU OS 4_3_2 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8H7 Safari/6533.18.5",
|
||||||
* Android: "Mozilla/5.0 (Linux; U; Android 2.3.4; en-us; T-Mobile G2 Build/GRJ22) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"
|
* Android: "Mozilla/5.0 (Linux; U; Android 2.3.4; en-us; T-Mobile G2 Build/GRJ22) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"
|
||||||
* Touchpad: "Mozilla/5.0 (hp-tabled;Linux;hpwOS/3.0.5; U; en-US)) AppleWebKit/534.6 (KHTML, like Gecko) wOSBrowser/234.83 Safari/534.6 TouchPad/1.0"
|
* Touchpad: "Mozilla/5.0 (hp-tabled;Linux;hpwOS/3.0.5; U; en-US)) AppleWebKit/534.6 (KHTML, like Gecko) wOSBrowser/234.83 Safari/534.6 TouchPad/1.0"
|
||||||
|
* PhantomJS: "Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.5.0 Safari/534.34"
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var ua = navigator.userAgent
|
var ua = navigator.userAgent
|
||||||
, t = true
|
, t = true
|
||||||
, ie = /msie/i.test(ua)
|
, ie = /msie/i.test(ua)
|
||||||
, chrome = /chrome/i.test(ua)
|
, chrome = /chrome/i.test(ua)
|
||||||
, safari = /safari/i.test(ua) && !chrome
|
, phantom = /phantom/i.test(ua)
|
||||||
|
, safari = /safari/i.test(ua) && !chrome && !phantom
|
||||||
, iphone = /iphone/i.test(ua)
|
, iphone = /iphone/i.test(ua)
|
||||||
, ipad = /ipad/i.test(ua)
|
, ipad = /ipad/i.test(ua)
|
||||||
, touchpad = /touchpad/i.test(ua)
|
, touchpad = /touchpad/i.test(ua)
|
||||||
@ -48,6 +50,11 @@
|
|||||||
, chrome: t
|
, chrome: t
|
||||||
, version: ua.match(/chrome\/(\d+(\.\d+)?)/i)[1]
|
, version: ua.match(/chrome\/(\d+(\.\d+)?)/i)[1]
|
||||||
}
|
}
|
||||||
|
if (phantom) return {
|
||||||
|
webkit: t
|
||||||
|
, phantom: t
|
||||||
|
, version: ua.match(/phantomjs\/(\d+(\.\d+)+)/i)[1]
|
||||||
|
}
|
||||||
if (touchpad) return {
|
if (touchpad) return {
|
||||||
webkit: t
|
webkit: t
|
||||||
, touchpad: t
|
, touchpad: t
|
||||||
|
Loading…
Reference in New Issue
Block a user