dastat.js 2.0 KB

1
  1. !function(e,n){var r,a=function(e,t){for(var n=(t||document).getElementsByTagName("*"),r=new Array,a=0;a<n.length;a++)for(var o=n[a],i=o.className.split(" "),d=0;d<i.length;d++)if(i[d]==e){r.push(o);break}return r},o=function(e,t,n){document.addEventListener?e.addEventListener(t,n,!1):document.attachEvent?e.attachEvent("on"+t,n):e["on"+t]=n},i=function(e,t){var n=new Image;for(var r in t)e+="&"+r+"="+t[r];n.src=e,n=null},d=function(){var e=n.getElementsByClassName?n.getElementsByClassName("da-block-wrapper"):a("da-block-wrapper",n);e=[].slice.call(e);for(var t=[],r=0,o=e.length;o>r;r++){var i=e[r];i.getAttribute("not-auto-report")||t.push(i)}return t},c=function(e){for(var t=/da-block-wrapper/;e&&!t.test(e.className);)e=e.parentNode;return e},f=function(){var e=window.navigator.userAgent.toLowerCase();if(e.indexOf("msie")>=0){var t=e.match(/msie ([\d.]+)/)[1];return{type:"IE",version:t}}if(e.indexOf("trident")>=0)return{type:"IE",version:"unknow"};if(e.indexOf("firefox")>=0){var t=e.match(/firefox\/([\d.]+)/)[1];return{type:"Firefox",version:t}}if(e.indexOf("chrome")>=0){var t=e.match(/chrome\/([\d.]+)/)[1];return{type:"Chrome",version:t}}if(e.indexOf("opera")>=0){var t=e.match(/opera.([\d.]+)/)[1];return{type:"Opera",version:t}}if(e.indexOf("Safari")>=0){var t=e.match(/version\/([\d.]+)/)[1];return{type:"Safari",version:t}}return{type:"unknow",version:"unknow"}},u=function(e){var t=arguments.length>=2?"1":"2",n="http://dastat.duowan.com/?r=api/stat",r=f(),a={loc:e.getAttribute("locid"),pid:e.getAttribute("pid"),type:t,url:window.location.href,os:window.navigator.platform,browser:r.type+r.version,px:window.screen.width+"*"+window.screen.height,_:(new Date).getTime()};"undefined"!=typeof a.loc&&"undefined"!=typeof a.pid&&a.type&&i(n,a)},s=function(){o(n.body,"click",function(e){e=e||window.event,t=c(e.target),t&&u(t)});for(var e=0,a=r.length;a>e;e++){var i=r[e];u(i,"loaded")}},p=function(){r=d(),s()};window.dwDaStat={reportData:u},o(n,"readystatechange",function(){"complete"==n.readyState&&p()})}(window,document);