forked from miluluyo/cute-cnblogs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmonitoring.js
1 lines (1 loc) · 3.63 KB
/
monitoring.js
1
window.logInfo={};window.logInfo.openTime=performance.timing.navigationStart;window.logInfo.whiteScreenTime=+new Date()-window.logInfo.openTime;document.addEventListener("DOMContentLoaded",function(a){window.logInfo.readyTime=+new Date()-window.logInfo.openTime});window.onload=function(){window.logInfo.allloadTime=+new Date()-window.logInfo.openTime;window.logInfo.nowTime=new Date().getTime();var a={whiteScreenTime:"白屏时间",readyTime:"用户可操作时间",allloadTime:"总下载时间",mobile:"使用设备",nowTime:"时间",};var b="";console.clear();console.info("前端可视化监控如下:");for(var c in a){console.info(a[c]+":"+window.logInfo[c]+"ms");if(c==="mobile"){b+="&"+c+"="+window.logInfo[c]}else{b+="&"+c+"="+window.logInfo[c]}}console.info("%c ","background: url(https://images.cnblogs.com/cnblogs_com/miluluyo/1493340/o_a.gif) no-repeat center;padding-left:400px;padding-bottom: 160px;background-size:400px");console.info("\n %c %c %c cute-cnblogs GitHub - %c %c https://github.com/miluluyo/cute-cnblogs/ %c \n\n","background: #fadfa3; padding:5px 0;","background: #fadfa3; padding:5px 0;","color: #fadfa3; background: #030307; padding:5px 0;","background: #fadfa3; padding:5px 0;","background: #FCEDC9; padding:5px 0;","background: #fadfa3; padding:5px 0;")};window.logInfo.mobile=mobileType();function mobileType(){var b=navigator.userAgent,e=navigator.appVersion;var d={ios:!!b.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),iPad:b.indexOf("iPad")>-1,android:b.indexOf("Android")>-1||b.indexOf("Linux")>-1,iPhone:b.indexOf("iPhone")>-1||b.indexOf("Mac")>-1,trident:b.indexOf("Trident")>-1,presto:b.indexOf("Presto")>-1,webKit:b.indexOf("AppleWebKit")>-1,gecko:b.indexOf("Gecko")>-1&&b.indexOf("KHTML")==-1,mobile:!!b.match(/AppleWebKit.*Mobile/i)||!!b.match(/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/),webApp:b.indexOf("Safari")==-1};var a=Object.keys(d);for(var c=0;c<a.length;c++){if(d[a[c]]){return a[c]}}}window.onload=function(){window.logInfo.allloadTime=+new Date()-window.logInfo.openTime;window.logInfo.nowTime=new Date().getTime();var a={whiteScreenTime:"白屏时间",readyTime:"用户可操作时间",allloadTime:"总下载时间",mobile:"使用设备",nowTime:"时间",};var b="";console.clear();console.info("前端可视化监控如下:");for(var c in a){console.info(a[c]+":"+window.logInfo[c]+"ms");if(c==="mobile"){b+="&"+c+"="+window.logInfo[c]}else{b+="&"+c+"="+window.logInfo[c]}}console.info("%c ","background: url(https://images.cnblogs.com/cnblogs_com/miluluyo/1493340/o_a.gif) no-repeat center;padding-left:400px;padding-bottom: 160px;background-size:400px");console.info("\n %c %c %c cute-cnblogs GitHub - %c %c https://github.com/miluluyo/cute-cnblogs/ %c \n\n","background: #fadfa3; padding:5px 0;","background: #fadfa3; padding:5px 0;","color: #fadfa3; background: #030307; padding:5px 0;","background: #fadfa3; padding:5px 0;","background: #FCEDC9; padding:5px 0;","background: #fadfa3; padding:5px 0;")};var defaults={msg:"",url:"",line:"",col:"",nowTime:"",};window.onerror=function(c,a,k,d,h){d=d||(window.event&&window.event.errorCharacter)||0;defaults.url=a;defaults.line=k;defaults.col=d;defaults.nowTime=new Date().getTime();if(h&&h.stack){defaults.msg=h.stack.toString()}else{if(arguments.callee){var b=[];var j=arguments.callee.caller;var f=3;while(j&&(--f>0)){b.push(j.toString());if(j===j.caller){break}j=j.caller}b=b.join(",");defaults.msg=h.stack.toString()}}var g="";for(var e in defaults){if(defaults[e]===null||defaults[e]===undefined){defaults[e]="null"}g+="&"+e+"="+defaults[e].toString()}srt=g.replace("&","").replace("\n","").replace(/\s/g,"")};