判断是否是电脑访问网站 1号店页面判断脚本

判断是否是电脑访问网站 1号店页面判断脚本;

<script type="text/javascript">
(function(){
var ua = window.navigator.userAgent;
var re = /(Android|iPod|iTouch|iPhone|iPad|BlackBerry|SymbianOS|SymbOS|Windows Phone OS|WAP|Kindle|pad|pod)/i;
if (!re.test(ua)) {
return;
}
var storage = window.localStorage;
if (window.location.search!='' && window.location.search.indexOf('from=')>0) {
if (storage) {
var t = storage.getItem("yhd_from_date");
if (!t) {
storage.setItem("yhd_from_date", new Date().getTime());
} else {
storage.removeItem("yhd_from_date");
storage.setItem("yhd_from_date", new Date().getTime());
}
}
return;
} else {
if (storage) {
var t = storage.getItem("yhd_from_date");
if (t) {
var diff = new Date().getTime() - parseInt(t);
if (diff>=0 && diff<24*3600*1000) {
return;
}
}
}
}
var mURL = "http://m.yhd.com";
var mTracker = "10735511443";
var sURL = {'ipad':'http://m.yhd.com/mw/pad','pad':'http://m.yhd.com/mw/pad'};
var sRate = {'ipad':30,'pad':30};
var sTracker = {'android':'10498211440','itouch':'10543911442','ipod':'10543911442','iphone':'10449911441', 'ipad':'10735462094'};
var no3wUrl = "yhd.com";
var getCookie = function (name) {
var strCookie=document.cookie;
var arrCookie=strCookie.split("; ");
for(var i=0;i<arrCookie.length;i++){
var arr=arrCookie[i].split("=");
if(arr[0]==name)return arr[1];
}
return null;
};
var de = re.exec(ua)[0].toLowerCase();
var url = sURL[de] || mURL;
var rate = sRate[de] || -1;
var tk = sTracker[de] || mTracker;
if (rate != -1) {
var abtest = getCookie('abtest');
if (!abtest || parseInt(abtest)<0 || parseInt(abtest)>=100) {
abtest = Math.floor(Math.random() * 100 + 1);
var exp = new Date();
exp.setTime(new Date().getTime() + 30*24*60*60*1000);
document.cookie="abtest="+abtest+";path=/;domain=."+no3wUrl+";expires="+exp.toGMTString();
}
if (abtest <= rate) {
window.location.href = url+"?tracker_u="+tk;
} else {
return;
}
} else {
window.location.href = url+"?tracker_u="+tk;
}
})();
</script>


上一篇:/etc/profile新配置在新终端无法生效


下一篇:[LeetCode] Increasing Triplet Subsequence 递增的三元子序列