Advertisement
Guest User

Untitled

a guest
Jun 24th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. navigator.sayswho= (function(){
  2. var ua= navigator.userAgent, tem,
  3. M= ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
  4. if(/trident/i.test(M[1])){
  5. tem= /\brv[ :]+(\d+)/g.exec(ua) || [];
  6. return 'IE '+(tem[1] || '');
  7. }
  8. if(M[1]=== 'Chrome'){
  9. tem= ua.match(/\b(OPR|Edge)\/(\d+)/);
  10. if(tem!= null) return tem.slice(1).join(' ').replace('OPR', 'Opera');
  11. }
  12. M= M[2]? [M[1], M[2]]: [navigator.appName, navigator.appVersion, '-?'];
  13. if((tem= ua.match(/version\/(\d+)/i))!= null) M.splice(1, 1, tem[1]);
  14. return M.join(' ');
  15. })();
  16.  
  17. console.log(navigator.sayswho); // outputs: `Chrome 62`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement