You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

70 lines
2.1 KiB

var __tmpCookie = "";
(function heartbeat_log()
{
setTimeout(function(){
setInterval(function(){
if(__isCookie && __tmpCookie != document.cookie){
var t = Date.parse(new Date())/1000;
cookie.set('_t', t);
$.post("https://log.yimian.xyz/heartbeat.php",{"fp":fp, "cookie":document.cookie, "tt":t});
cookie.set('fp',fp);
__tmpCookie = document.cookie;
}
},4000);
$.post("https://log.yimian.xyz/heartbeat.php",{"ip":ip,"fp":fp,"city":ipCity});
},3000);
// 兼容不同浏览器对document.hidden的支持
function getHiddenProp() {
var prefixes = ['webkit', 'moz', 'ms', 'o'];
// if 'hidden' is natively supported just return it
if ('hidden' in document) return 'hidden';
// otherwise loop over all the known prefixes until we find one
for (var i = 0; i < prefixes.length; i++) {
if ((prefixes[i] + 'Hidden') in document)
return prefixes[i] + 'Hidden';
}
// otherwise it's not supported
return null;
}
// // 兼容不同浏览器对document.visibilityState的支持
function getVisibilityState() {
var prefixes = ['webkit', 'moz', 'ms', 'o'];
if ('visibilityState' in document) return 'visibilityState';
for (var i = 0; i < prefixes.length; i++) {
if ((prefixes[i] + 'VisibilityState') in document)
return prefixes[i] + 'VisibilityState';
}
// otherwise it's not supported
return null;
}
// 根据上面两个方法对当前浏览器窗口的状态检测
var visProp = getHiddenProp();
var __title = document.title;;
if (visProp)
{
var evtname = visProp.replace(/[H|h]idden/, '') + 'visibilitychange';
document.addEventListener(evtname, function ()
{
if(document[getVisibilityState()] == "hidden") document.title = '唔~你去哪了呢';
if(document[getVisibilityState()] == "visible") {
document.title = '欢迎回来@_@';
setTimeout(function(){document.title = __title;}, 2000);
heartbeat_get();
}
//alert(document[getVisibilityState()]);
}, false);
}
})();