-
Notifications
You must be signed in to change notification settings - Fork 1
/
browsercheck.min.js
1 lines (1 loc) · 3.79 KB
/
browsercheck.min.js
1
window.PlivoCheck=class{constructor(){this._version="2.0",e.init(),this.browser=e.browser,this.browserVersion=e.version,this.browserFullVersion=e.fullVersion,this.OS=e.OS,this.fullOS=e.fullOS}version(){return this._version}checkWebSocket(){return"WebSocket"in window&&"function"==typeof WebSocket}checkFlash(){return console.log("checkFlash function is deprecated."),!1}getFlashVer(){return console.log("getFlashVer function is deprecated."),"0.0.0"}checkBrowser(){return[this.browser,this.browserFullVersion]}checkOS(){return this.OS}checkMic(){return console.log("checkMic function is deprecated."),!0}checkWebRTC(){return!!(navigator.mediaDevices.getUserMedia||navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia||window.RTCPeerConnection||window.PeerConnection||window.webkitRTCPeerConnection||window.mozRTCPeerConnection)}checkMediaDevices(){return!!(navigator.mediaDevices&&navigator.mediaDevices.enumerateDevices&&navigator.mediaDevices.getUserMedia)}listMediaDevices(){return this.checkMediaDevices()?navigator.mediaDevices.getUserMedia({audio:!0,video:!1}).then((e=>navigator.mediaDevices.enumerateDevices())).catch((e=>(console.log("navigator.mediaDevices.getUserMedia failed: "+e),Promise.reject("navigator.mediaDevices.getUserMedia failed: "+e)))):(console.log("navigator.mediaDevices is not supported by your browser."),Promise.reject("navigator.mediaDevices is not supported by your browser."))}};var e={init:function(){this.browser=this.searchString(this.dataBrowser)||"An unknown browser",this.version=this.searchVersion(navigator.userAgent)||this.searchVersion(navigator.appVersion)||"an unknown version",this.fullVersion=this.searchFullVersion(navigator.userAgent)||this.searchVersion(navigator.appVersion)||"an unknown version",this.OS=this.searchString(this.dataOS)||"an unknown OS",this.fullOS=this.searchOSVersion()||void 0},searchString:function(e){for(var i=0;i<e.length;i++){var r=e[i].string,n=e[i].prop;if(this.versionSearchString=e[i].versionSearch||e[i].identity,r){if(-1!=r.indexOf(e[i].subString))return e[i].identity}else if(n)return e[i].identity}},searchOSVersion:function(){var e,i,r,n=navigator.userAgent.indexOf(this.OS);return i=r=navigator.userAgent.indexOf(")",n),"Windows"==this.OS&&(e=navigator.userAgent.indexOf(";",n))>0&&(i=e<r?e:r),navigator.userAgent.substring(n,i)},searchVersion:function(e){var i=e.indexOf(this.versionSearchString);if(-1!=i)return parseFloat(e.substring(i+this.versionSearchString.length+1))},searchFullVersion:function(e){var i=e.indexOf(this.versionSearchString);if(-1!=i){var r=e.substring(i+this.versionSearchString.length+1),n=r.indexOf(" ");return n<=0?r:r.substring(0,n)}},dataBrowser:[{string:navigator.userAgent,subString:"Chrome",identity:"Chrome"},{string:navigator.userAgent,subString:"OmniWeb",versionSearch:"OmniWeb/",identity:"OmniWeb"},{string:navigator.vendor,subString:"Apple",identity:"Safari",versionSearch:"Version"},{prop:window.opera,identity:"Opera",versionSearch:"Version"},{string:navigator.vendor,subString:"iCab",identity:"iCab"},{string:navigator.vendor,subString:"KDE",identity:"Konqueror"},{string:navigator.userAgent,subString:"Firefox",identity:"Firefox"},{string:navigator.vendor,subString:"Camino",identity:"Camino"},{string:navigator.userAgent,subString:"Netscape",identity:"Netscape"},{string:navigator.userAgent,subString:"MSIE",identity:"Explorer",versionSearch:"MSIE"},{string:navigator.userAgent,subString:"Gecko",identity:"Mozilla",versionSearch:"rv"},{string:navigator.userAgent,subString:"Mozilla",identity:"Netscape",versionSearch:"Mozilla"}],dataOS:[{string:navigator.platform,subString:"Win",identity:"Windows"},{string:navigator.platform,subString:"Mac",identity:"MacOS"},{string:navigator.userAgent,subString:"iPhone",identity:"iPhone/iPad"},{string:navigator.platform,subString:"Linux",identity:"Linux"}]};