mirror of
https://github.com/lancedikson/bowser
synced 2024-10-27 20:34:22 +00:00
9 lines
1.6 KiB
JavaScript
9 lines
1.6 KiB
JavaScript
/*!
|
|
* Bowser - a browser detector
|
|
* https://github.com/ded/bowser
|
|
* MIT License | (c) Dustin Diaz 2011
|
|
*/
|
|
!function(a,d){"function"==typeof define?define(d):"undefined"!=typeof module&&module.exports?module.exports.browser=d():this[a]=d()}("bowser",function(){var a=navigator.userAgent,d=/msie/i.test(a),f=/chrome/i.test(a),g=/phantom/i.test(a),k=/safari/i.test(a)&&!f&&!g,h=/iphone/i.test(a),j=/ipad/i.test(a),l=/touchpad/i.test(a),m=/android/i.test(a),n=/opera/i.test(a),p=/firefox/i.test(a),q=/gecko\//i.test(a),r=/seamonkey\//i.test(a),e=/version\/(\d+(\.\d+)?)/i,c,b=function(){if(d)return{msie:!0,version:a.match(/msie (\d+(\.\d+)?);/i)[1]};
|
|
if(f)return{webkit:!0,chrome:!0,version:a.match(/chrome\/(\d+(\.\d+)?)/i)[1]};if(g)return{webkit:!0,phantom:!0,version:a.match(/phantomjs\/(\d+(\.\d+)+)/i)[1]};if(l)return{webkit:!0,touchpad:!0,version:a.match(/touchpad\/(\d+(\.\d+)?)/i)[1]};if(h||j)return c={webkit:!0,mobile:!0,ios:!0,iphone:h,ipad:j},e.test(a)&&(c.version=a.match(e)[1]),c;if(m)return{webkit:!0,android:!0,mobile:!0,version:a.match(e)[1]};if(k)return{webkit:!0,safari:!0,version:a.match(e)[1]};if(n)return{opera:!0,version:a.match(e)[1]};
|
|
if(q)return c={gecko:!0,mozilla:!0,version:a.match(/firefox\/(\d+(\.\d+)?)/i)[1]},p&&(c.firefox=!0),c;if(r)return{seamonkey:!0,version:a.match(/seamonkey\/(\d+(\.\d+)?)/i)[1]}}();b.msie&&7<=b.version||b.chrome&&10<=b.version||b.firefox&&4<=b.version||b.safari&&5<=b.version||b.opera&&10<=b.version?b.a=!0:b.msie&&7>b.version||b.chrome&&10>b.version||b.firefox&&4>b.version||b.safari&&5>b.version||b.opera&&10>b.version?b.c=!0:b.x=!0;return b});
|