(function(){
"use strict";
function Loading()
{
this.obj = document.getElementById("loading_icon");
this.obj2 = document.getElementById("loadbox");
this.obj3 = document.getElementById("loading_bar1");
this.jc = this.obj2.clientWidth*0.2/2;
this.max = this.obj2.clientWidth*0.9;
this.obj.style.left = this.jc + "px";
this.begin = 0;
this.timeNum = 0;
};
Loading.prototype.init = function(_back,_this)
{
var verText = document.getElementById("verText");
verText.innerText = "3.0";
var speed = (window.innerWidth*0.8)/207;
var py = (50/414)*window.innerWidth;
this.back = _back;
this._this = _this;
console.log(this.obj2.clientWidth,this.a);
var thisa = this;
this.timeNum = setInterval(function (){
thisa.begin += speed;
var cur = (thisa.begin + thisa.jc) ;
if(cur >= thisa.max)
{
console.log("进度条完毕");
thisa.hit(true);//隐藏显示
return;
}
thisa.obj.style.left = (cur - py) + "px";
thisa.obj3.style.width = thisa.begin + "px";
},20);
};
Loading.prototype.show = function (){
};
Loading.prototype.hit = function (b){
var googleAdBoxNew = document.getElementById("googleAdBoxNew");
if(window.isopenads == 0)
{
googleAdBoxNew && (googleAdBoxNew.style.display = "none");
}
var verText = document.getElementById("verText");
verText.style.display = "none";
this.obj2.style.display="none";
clearInterval(this.timeNum);
b && this.back && this.back.call(this._this);
// this.back(true).bind(_this);
this.back = null;
this._this = null;
};
window.Loading = Loading;
}());
//AFC封装广告系统
(function (){
"use strict";
function GoogleAfcFull(_globalData,_gameFrame)
{
this.jd = 0;
this.timeNum = 0;
this.loadingBar = document.getElementById("ad_loading"); //进度条
this.playText = document.getElementById("ad_loading_text");//开始按钮提示文字
this.googleAdBox = document.getElementById("googleAdBox");
this.adBox = document.getElementById("ad_box");
this.gameFrame = _gameFrame;//document.getElementById("gameFrame");
this.googleAdBoxNew1 = document.getElementById("googleAdBoxNew"); //进度条
this.googleAdBox1 = document.getElementById("googleAdBox"); //进度条
this.initAfc_num = 0;
this.afcInit = false;
this.initAfc_num2 = 0;
this.afcInit2 = false;
this.globalData = _globalData;
//this.playText.style.display = "none";
var thisa = this;
if(this.globalData.Tools.GetUrlParams().platform == "shareit")
{
//this.isShareit = true;
}
/* this.loadingBar.onclick = function (){
thisa.jd +=1;
if(thisa.jd >= 100)
{
if(thisa.isShareit)
{
if(Math.floor( Math.random() * 10) > 5)
{
thisa.playText.innerText = "Quick Click";
return;
}
}
// thisa.googleAdBoxNew1.style.top = "90%";
thisa.clickBack(true);
}
console.log("被点击");
}*/
if(window.addEventListener!= void 0)
{
window.addEventListener("message", this.UpdataState.bind(this));
}
else
{
window.attachEvent && window.attachEvent("message", this.UpdataState.bind(this));
}
};
GoogleAfcFull.prototype.GameLoadingAfc = function(_globalData){
var refreshAfcNum = _globalData.appInfoData.refreshAfcNum;
if(this.initAfc_num >= refreshAfcNum)
{
this.initAfc_num = 0;
}else
{
this.initAfc_num++;
if(this.afcInit)
return;
}
let i = this.adBox.getElementsByClassName("adsbygoogle")[0];
i && i.remove();
let d = document.createElement("ins");
d.setAttribute("class", "adsbygoogle banner-ins");
d.setAttribute("data-ad-client", "ca-pub-" + _globalData.appData.adsenseid);
d.setAttribute("data-ad-slot", _globalData.appInfoData.bannerId_load);
d.setAttribute("data-ad-format", "auto");
d.setAttribute("data-full-width-responsive", "true");
this.adBox.append(d);
setTimeout(()=>{openads
window.adsbygoogle.push({})
},500)
this.afcInit = true;
// this.googleAdBox.style.display = "none";
};
GoogleAfcFull.prototype.GameAfc = function(_globalData,bannerBox){
//bannerBox.innerHTML = "";
bannerBox.innerHTML = "";
var o = document.createElement("script");
o.innerHTML = "(adsbygoogle = window.adsbygoogle || []).push({});";
bannerBox.appendChild(o);
};
GoogleAfcFull.prototype.playAds = function (_globalData,_back ){
this._back = _back;
this.googleAdBox.style.display = "block";
this.adBox.style.display = "block";
this.GameLoadingAfc(_globalData);
//this.googleAdBox.style.visibility = "visible";
this.jd =0;
this.loadingBar.style.width = "0px";
this.playText.style.visibility = "hidden";
//初始化广告系统
// this.googleAdBoxNew1.style.top = "100%";
this.googleAdBox1.style.height = "100%";
var thisa = this;
this.timeNum = setInterval(function ()
{
thisa.jd += 1;
if(thisa.jd >= 100)
{
thisa.jd = 100;
clearInterval(thisa.timeNum);
//thisa.playText.style.display = "";
thisa.playText.style.visibility = "visible";
}
thisa.loadingBar.style.width = thisa.jd+"%";
},70)
};
GoogleAfcFull.prototype.initIframe = function(_globalData)
{
let op1 = _globalData.appData.adBanner_game;
let op2 = _globalData.appInfoData.adBanner_game;
let topB = _globalData.appData.banner_bottom=="False"?true:false;
let gv = document.getElementById('GameDiv');
let hei = window.innerHeight;
var isopen_ads = _globalData.appInfoData.openAds;
if(op1 == 1 && op2 == 1 && isopen_ads != 0)
{
hei = window.innerHeight * window.bl_uptap;
gv.style.height = (window.bl_uptap*100)+"%";
this.googleAdBox.style.height = "90%";
this.gameFrame.style.height = "100%"
this.gameFrame.style.marginTop = "0px";
let isFull = _globalData.appUrlData.fullScr=="True"?true:false;
if(isFull== false)
{
if(hei / window.innerWidth < 1.7777)
{
this.gameFrame.style.width =(hei*0.5625) + "px";
this.gameFrame.style.left = ((window.innerWidth-(hei*0.5625)) /2) + "px";
}
else
{
this.gameFrame.style.width = "100%"
var hei1 = window.innerWidth*1.77778;
this.gameFrame.style.height = hei1 + "px";
this.gameFrame.style.top = ((hei - hei1)/2) + "px";
}
}
else
{
this.gameFrame.style.width = window.innerWidth + "px";
this.gameFrame.style.left = "0px";
}
return true;
}
else
{
hei = window.innerHeight;
this.gameFrame.style.height = (hei) + "px";
this.gameFrame.style.marginTop = "0px";
let isFull = _globalData.appUrlData.fullScr=="True"?true:false;
if(isFull== false)
{
if(hei / window.innerWidth < 1.7777)
{
this.gameFrame.style.width =(hei*0.5625) + "px";
this.gameFrame.style.left = ((window.innerWidth-(hei*0.5625)) /2) + "px";
}
else
{
this.gameFrame.style.width = "100%"
var hei1 = window.innerWidth*1.77778;
this.gameFrame.style.height = hei1 + "px";
this.gameFrame.style.top = ((hei - hei1)/2) + "px";
}
}
else
{
this.gameFrame.style.width = window.innerWidth + "px";
this.gameFrame.style.left = "0px";
}
return false;
}
}
GoogleAfcFull.prototype.GameAfcNew = function(_globalData,_back,jili,newafg,_type)
{
var newadbox = document.getElementById("newadbox");
// newadbox.style.height = "0%";
newadbox.style.top="42%";
newadbox.style.left = "50%";
newadbox.style.transform="translateX(-50%) translateY(-50%)";
jili = true;
if(window.isVidmate)
{
try{
_clog.sendLog('ad_req');
_clog.sendLog('ad_show');
}catch(e){};
}
var d1 = document.getElementById("ad_loading_bar");
var newloadingBox = document.getElementById("newloadingBox");
newloadingBox.style.display = "block";//显示
newloadingBox.style.visibility = "visible";
var newloadingBox_1 = document.getElementById("newloadingBox_1");
newloadingBox_1.style.display = "block";//显示
newloadingBox_1.style.visibility = "visible";
var topB = _globalData.appData.banner_bottom=="False"?true:false;
var gv = document.getElementById('GameDiv');
var googleAdBoxNew = document.getElementById("googleAdBoxNew");
googleAdBoxNew.style.display = "block";//显示
googleAdBoxNew.style.paddingTop = "";
if(!window.ad_start)
{
}
googleAdBoxNew.style.height = "100%";
googleAdBoxNew.style.top = "0px";
//var newloadingText = document.getElementById("newloadingText");
var loadingAdBg = document.getElementById("loadingAdBg");
var newadbox = document.getElementById("newadbox");
var refreshAfcNum = _globalData.appInfoData.refreshAfcNum;
var platform = _globalData.Tools.GetUrlParams().platform;
let d;
if(_type != "game_cy")
{
if(this.initAfc_num2 >= refreshAfcNum)
{
this.initAfc_num2 = 0;
console.log("刷新ADS!!!")
let i = newadbox.getElementsByClassName("adsbygoogle")[0];
i && i.remove();
d = document.createElement("ins");
d.setAttribute("class", "adsbygoogle banner-ins");
d.setAttribute("data-ad-client", "ca-pub-" + _globalData.appData.adsenseid);
d.setAttribute("data-ad-slot", _globalData.appInfoData.bannerId_load);
d.setAttribute("data-ad-format", "auto");
d.setAttribute("data-full-width-responsive", "true");
if(window.testAds)
{
d.setAttribute("data-adtest", "on");
}
// d.style = "display:block;width:100%;height:280px;";
newadbox.append(d);
setTimeout(()=>{
window.adsbygoogle.push({})
},500);
this.afcInit2 = true;
}
else
{
this.initAfc_num2++;
if(!this.afcInit2)
{
let i = newadbox.getElementsByClassName("adsbygoogle")[0];
i && i.remove();
d = document.createElement("ins");
d.setAttribute("class", "adsbygoogle banner-ins");
d.setAttribute("data-ad-client", "ca-pub-" + _globalData.appData.adsenseid);
d.setAttribute("data-ad-slot", _globalData.appInfoData.bannerId_load);
d.setAttribute("data-ad-format", "auto");
// d.style = "display:block;width:100%;height:280px;";
d.setAttribute("data-full-width-responsive", "true");
if(window.testAds)
{
d.setAttribute("data-adtest", "on");
}
newadbox.append(d);
setTimeout(()=>{
window.adsbygoogle.push({})
},500);
this.afcInit2 = true;
}
}
}
else
{//传音特殊处理
//newloadingBox margin-top: ;bottom: 70%;
//newloadingBox_1 bottom: 30%; height: 200px;
//ad_loading_bar bottom: 15%;
//googleAdBoxNew height: 88%; window.bl_uptap
newloadingBox.style.marginTop = "",newloadingBox.style.bottom = "70%";
newloadingBox_1.style.bottom = "30%", newloadingBox_1.style.height = "200px";
d1.style.bottom = "15%";
googleAdBoxNew.style.height = (window.bl_uptap*100)+"%";
newadbox.style.display = "none";
}
console.log("广告填充完毕=======================================广告填充完毕=======================================广告填充完毕=======================================广告填充完毕=======================================广告填充完毕=======================================广告填充完毕=======================================广告填充完毕=======================================广告填充完毕=======================================广告填充完毕=======================================")
if(d1.style.display == "none")
{
var newloadingBox_1 = document.getElementById("newloadingBox_1");
newloadingBox_1.style.display = "none";//显示
newloadingBox_1.style.visibility = "";
setTimeout(()=>{
d1.style.display = "block";
newloadingBox_1.style.display = "block";//显示
newloadingBox_1.style.visibility = "visible";
},1500);
}
if(_globalData.appInfoData.open_home == "True")//交叉推广
{
begin(_globalData.appInfoData.open_home_ids,_globalData.Tools.GetUrlParams().platform);
}
// jili = false;
if(platform == "gamebox")
{
newadbox.style.transform = "translateX(-50%)";
newadbox.style.height = "200px";
newadbox.style.top=(window.innerHeight-200)+"px";
newloadingBox_1.style.bottom = "";
newloadingBox_1.style.top = "18%";
newloadingBox_1.style.height = "180px";
d1.style.bottom = "";
d1.style.top = "53%";
if(d)
{
d.setAttribute("data-ad-format", "");
d.setAttribute("data-full-width-responsive", "false");
d.style.width= "100%";
d.style.height= "200px";
}
}
if(_globalData.Tools.GetUrlParams().platform == "shareit")
{
//this.isShareit = true;
}
if(_globalData.Tools.GetUrlParams().platform.indexOf("mi_") != -1)
{
return;
}
//newloadingText.innerText = "0%";
if(newafg != 1)
this.startLoadings(_globalData,newafg,_back,_type);
};
GoogleAfcFull.prototype.UpdataState = function(e)
{
var t = e.data;
var n = t.cmd;
switch (n) {
case "SetLoadingProgress1":
this.UpdataLoadingProgress(t.pro);
break;
case "LoadingComplete1":
this.LoadingComplete();
break;
}
};
GoogleAfcFull.prototype.UpdataLoadingProgress = function(pro)
{
var d3 = document.getElementById("ad_loading1")
var newloadingText = document.getElementById("ad_loading_text");
newloadingText && (newloadingText.style.visibility = "visible");
d3 && (d3.style.width = Math.floor(pro) + "%");
newloadingText && (newloadingText.innerText = Math.floor(pro) + "%");
}
GoogleAfcFull.prototype.LoadingComplete = function()
{
var d1 = document.getElementById("ad_loading_bar");
var d2 = document.getElementById("ad_loading_bg");
var d3 = document.getElementById("ad_loading1");
var d4 = document.getElementById("ad_loading_text");
document.body.style.background = "#ffffff";
try{
d4.innerText = "PLAY";
d4.style.visibility = "visible";
if( window._type == "title")
{
d4.innerText = "TRY NOW";
}
}catch (e){}
if(_globalData.Tools.GetUrlParams().platform == "cy")//传音特殊处理
{
googleAdBoxNew.removeChild(d1);
this.googleAdBoxNew1.style.display = "none";//显示
return;
}
d1 && (d1.onclick = ()=>
{
if(this.isShareit)
{
var k = Math.floor( Math.random() * 10);
console.log("click---->" + k);
if(k <= 5)
{
d4.innerText = "Quick Click";
return;
}
}
d1.onclick = null;
googleAdBoxNew.removeChild(d1);
if( window._globalData.Tools.GetUrlParams().platform != "pb" && window._globalData.Tools.GetUrlParams().platform != "pbbrowser")
{
this.GameAfcNewToGameBanner(false,window._globalData);
}
else
{
this.googleAdBoxNew1.style.display = "none";//显示
}
window._back && window._back();
if(window.newafg &&( window._globalData.Tools.GetUrlParams().platform != "rt_main" &&
window._globalData.Tools.GetUrlParams().platform != "pb" &&
window._globalData.Tools.GetUrlParams().platform != "shareit" ))
{
var time_id = setInterval(function (){
if(window.show_openad1 == 1)
{
window.show_openad1 = 2;
clearInterval(time_id);
window.adBreak({
type: 'start',
name: 'game_started',
adBreakDone:(EE)=>{
console.log("-->" + JSON.stringify(EE));
}
});
}
},50)
}
});
d3 && (d3.style.width = Math.floor(100) + "%");
};
GoogleAfcFull.prototype.startLoadings = function(_globalData,newafg,_back,_type,titles)
{
window._globalData = _globalData;
window.newafg = newafg;
window._back = _back;
window._type = _type;
var jili = true;
var d1,d2,d3,d4;
if(jili)
{
//newloadingBox.style.visibility = "hidden";//显示
var cc = document.getElementById("ad_loading_bar");
if(cc)
{
googleAdBoxNew.removeChild(cc);
}
d1 = document.createElement("div");
d1.id = "ad_loading_bar"
d1.style.zIndex = '999';
d2 = document.createElement("div");
d2.id = "ad_loading_bg"
d1.appendChild(d2);
d3 = document.createElement("div");
d3.id = "ad_loading1"
d2.appendChild(d3);
d4 = document.createElement("p");
d4.id = "ad_loading_text"
d3.appendChild(d4);
googleAdBoxNew.appendChild(d1);
if(_globalData.Tools.GetUrlParams().platform == "gamebox")
{
d1.style.bottom = "";
d1.style.top = "53%";
}
if(_globalData.Tools.GetUrlParams().platform == "mi_bs")
{
//d1.style.bottom = '';
//d1.style.top = '0%';
}
}
else
{
newloadingBox.style.visibility = "visible";//显示
newloadingBox_1.style.visibility = "visible";//显示
}
var jd1 = 0;
var thisa = this;
var timeout = 16;
var sd = 99 / (8000 / timeout)
if(_type == "title")
{
d3.innerHTML = "
\n" +
" T\n" +
" r\n" +
" y\n" +
" \n" +
" N\n" +
" o\n" +
" w\n" +
"
"
jd1 = 100;
d1.style.display = "none";
}
var timeNum2 = setInterval( ()=>
{
jd1 += sd;
if(_globalData.appUrlData && _globalData.appUrlData.zip == "True" && titles)
{
clearInterval(timeNum2);
d3 && (d3.style.width = Math.floor(0) + "%");
d4.innerText == "loading……"
return;
}
if(jd1>= 100)
{
// newloadingBox.style.visibility = "hidden";
//隐藏百分比
jd1 = 100;
clearInterval(timeNum2);
document.body.style.background = "#ffffff";
if(_globalData.Tools.GetUrlParams().platform == "cy")//传音特殊处理
{
googleAdBoxNew.removeChild(d1);
this.googleAdBoxNew1.style.display = "none";//显示
return;
}
if(jili)
{
d4.innerText = "PLAY";
d4.style.visibility = "visible";
if(_type == "title")
{
d4.innerText = "TRY NOW";
}
d1 && (d1.onclick = ()=>
{
if(this.isShareit)
{
var k = Math.floor( Math.random() * 10);
console.log("click---->" + k);
if(k <= 5)
{
d4.innerText = "Quick Click";
return;
}
}
d1.onclick = null;
d1.style.display = "none";
// googleAdBoxNew.removeChild(d1);
if( _globalData.Tools.GetUrlParams().platform != "pb" && _globalData.Tools.GetUrlParams().platform != "pbbrowser")
{
this.GameAfcNewToGameBanner(false,_globalData);
}
else
{
this.googleAdBoxNew1.style.display = "none";//显示
}
_back && _back();
if(newafg &&( _globalData.Tools.GetUrlParams().platform != "rt_main" &&
_globalData.Tools.GetUrlParams().platform != "pb" &&
_globalData.Tools.GetUrlParams().platform != "shareit" ))
{
var time_id = setInterval(function (){
if(window.show_openad1 == 1)
{
window.show_openad1 = 2;
clearInterval(time_id);
window.adBreak({
type: 'start',
name: 'game_started',
adBreakDone:(EE)=>{
console.log("-->" + JSON.stringify(EE));
}
});
}
},50)
}
});
}
else
{
_back && _back();
this.GameAfcNewToGameBanner(false,_globalData);
}
}
//newloadingText.innerText = Math.floor(jd1) + "%";
if(jili)
{
d3 && (d3.style.width = Math.floor(jd1) + "%");
}
},timeout)
}
GoogleAfcFull.prototype.GameAfcNewToGameBanner = function(bool,_globalData)
{
var googleAdBoxNew = document.getElementById("googleAdBoxNew");
let newLoadAfc = _globalData.appInfoData.newLoadAfc == "True"?true:false;
let banner_open = _globalData.appData.banner_open=="False"?false:true;
if(!window.ad_start/* || !newLoadAfc */|| !banner_open)
{
googleAdBoxNew.style.display = "none";//显示
return;
}
//return;
//游戏loading广告 转换 为游戏底部banner
console.log("GameAfcNewToGameBanner将loading广告转换成底部banner")
var newloadingBox = document.getElementById("newloadingBox");
newloadingBox.style.display = "none";//显示
var newloadingBox_1 = document.getElementById("newloadingBox_1");
newloadingBox_1.style.display = "none";//显示
googleAdBoxNew.style.top = ((window.bl_uptap+window.bl_uptap_py) * 100)+"%"
var newadbox = document.getElementById("newadbox");
newadbox.style.top="";
newadbox.style.left = "";
newadbox.style.transform="";
newadbox.style.height= ""
googleAdBoxNew.style.height = "auto";
};
/*
* 初始化banner
* */
GoogleAfcFull.prototype.initBanner = function(_globalData)
{
var googleAdBoxNew = document.getElementById("googleAdBoxNew");
googleAdBoxNew.style.display = "none";
var bannerDiv = document.createElement("div");
bannerDiv.style.width = "100%";
bannerDiv.style.position = "absolute";
bannerDiv.style.zIndex = 98;
//bannerDiv.style.top = ((window.bl_uptap+window.bl_uptap_py) * 100)+"%"
var hei = (window.innerHeight - (window.innerHeight*(window.bl_uptap+window.bl_uptap_py)));
bannerDiv.style.height = hei+"px";
window.document.body.append(bannerDiv);
let d2 = document.createElement("ins");
d2.setAttribute("class", "adsbygoogle banner-ins");
d2.setAttribute("data-ad-client", "ca-pub-" + _globalData.appData.adsenseid);
d2.setAttribute("data-ad-slot", _globalData.appInfoData.bannerId_load);
// d2.setAttribute("data-ad-format", "auto");
d2.setAttribute("data-full-width-responsive", "true");
bannerDiv.append(d2);
setTimeout(()=>{
window.adsbygoogle.push({})
},500);
}
GoogleAfcFull.prototype.clickBack = function ()
{
this.hit();
this._back && this._back();
};
GoogleAfcFull.prototype.hit = function(b)
{
//this.googleAdBox.style.visibility = "hidden";
this.googleAdBox.style.display = "none";
this.adBox.style.display = "none";
};
window.GoogleAfcFull = GoogleAfcFull;
}());
//谷歌广告相关 AFG
(function (){
"use strict";
function GoogleGameAds()
{
this.backFun = null;
this.adWid = window.innerWidth;
this.adHid = window.innerHeight;
this.adContainer = document.createElement("div");
this.adContainer.setAttribute("id","adContainer");
document.body.appendChild(this.adContainer);
this.adContainer.style.display = "none";
this.type = "";
};
GoogleGameAds.prototype.init = function (){
if(window.google && window.google.ima)
{
var tag = new window.google.ima.AdDisplayContainer(this.adContainer);
tag.initialize();
this.adLoader = new window.google.ima.AdsLoader(tag);
this.adLoader.addEventListener(window.google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,this.adLoaded1.bind(this));
this.adLoader.addEventListener(window.google.ima.AdErrorEvent.Type.AD_ERROR,this.googleAdvError.bind(this));
}
};
//开始播放google的游戏广告 _type 广告类型 插屏还是激励视频 screen:插屏 video:激励视频
GoogleGameAds.prototype.playGoogleGameAds = function (_globalData,_type)
{
if(window.isVidmate)
{
try{
_clog.sendLog('ad_req');
}catch(e){};
}
this.type = _type;
// _globalData.appData.adsenseid + "'data-ad-slot='" + _globalData.appInfoData.bannerId_load
var ad_type = _globalData.appInfoData.ad_type;
var adsenseid = _globalData.appData.adsenseid;
var url_channel = encodeURIComponent(window.location.href);//"http%3A%2F%2F" + window.location.hostname;
var afg_id = _globalData.appInfoData.afgID;
var ad_url = "";
if(_type != "video"){
ad_url = "https://googleads.g.doubleclick.net/pagead/ads?ad_type=image&client=ca-" + ad_type + "-pub-" + adsenseid + "&description_url=" + url_channel + "&channel=" + afg_id + "&videoad_start_delay=0&hl=en";
}
else{
ad_url = "https://googleads.g.doubleclick.net/pagead/ads?ad_type=video_image&client=ca-" + ad_type + "-pub-" + adsenseid + "&description_url=" + url_channel + "&channel=" + afg_id + "&videoad_start_delay=0&hl=en&max_ad_duration=33000";
}
if (this.adLoader && this.adContainer)
{
this.adContainer.style.display = "";
var adr = new window.google.ima.AdsRequest;
if (adr)
{
adr.adTagUrl = ad_url;
adr.forceNonLinearFullSlot = true;
adr.linearAdSlotWidth = this.adWid;
adr.linearAdSlotHeight = this.adHid;
adr.nonLinearAdSlotWidth = this.adWid;
adr.nonLinearAdSlotHeight = this.adHid;
this.adLoader.requestAds(adr);
} else this.googleAdvError("创建错误1");
}
else{
this.googleAdvError("创建错误2");
}
};
GoogleGameAds.prototype.adLoaded1 = function (e)
{
console.log("广告加载开始");
this.adsManager = e.getAdsManager(this.adContainer);
this.adsManager.addEventListener(window.google.ima.AdErrorEvent.Type.AD_ERROR, this.adError.bind(this));
this.adsManager.addEventListener(window.google.ima.AdEvent.Type.STARTED, this.adStart.bind(this));
this.adsManager.addEventListener(window.google.ima.AdEvent.Type.COMPLETE, this.adCompvare.bind(this));
this.adsManager.addEventListener(window.google.ima.AdEvent.Type.CLICK, this.adClick.bind(this));
this.adsManager.addEventListener(window.google.ima.AdEvent.Type.SKIPPED, this.adSkipped.bind(this));
this.adsManager.addEventListener(window.google.ima.AdEvent.Type.LOADED, this.adLoaded.bind(this));
try {
this.adsManager.init(this.adWid, this.adHid, window.google.ima.ViewMode.FULLSCREEN);
this.adsManager.start();
} catch(e) {
this.googleAdvError(e);
}
};
GoogleGameAds.prototype.adDestroy = function (){
this.adsManager && this.adsManager.destroy();
this.adContainer.style.display = "none";
};
GoogleGameAds.prototype.googleAdvError = function (err){
this.backFun && this.backFun({type: "1"});
this.adDestroy();
console.log("广告出现错误啊" + err);
};
GoogleGameAds.prototype.adError = function (err){
this.googleAdvError(err);
};
GoogleGameAds.prototype.adStart = function (){
if(window.isVidmate)
{
try{
_clog.sendLog('ad_show');
}catch(e){};
}
if(this.type == "video")
{
//用户点击了广告
try{
handleStatsEvent("ad_show","rewarded");
}catch(e){};
}
else if(this.type == "screen")
{
try{
handleStatsEvent("ad_show","Interstitial");
}catch(e){};
}
else if(this.type == "title")
{
try{
handleStatsEvent("ad_show","Openads");
}catch(e){};
}
//开始播放广告
console.log("广告开始播放");
};
GoogleGameAds.prototype.adCompvare = function (){
//广告播放完成
console.log("广告正常播放完毕");
this.adDestroy();
this.backFun && this.backFun({type: "3"});
};
GoogleGameAds.prototype.adClick = function (){
if(this.type == "video")
{
//用户点击了广告
try{
handleStatsEvent("ad_click","rewarded");
}catch(e){};
}
else if(this.type == "screen")
{
try{
handleStatsEvent("ad_click","Interstitial");
}catch(e){};
}
else if(this.type == "title")
{
try{
handleStatsEvent("ad_click","Openads");
}catch(e){};
}
};
GoogleGameAds.prototype.adSkipped = function (){
//跳过广告
console.log("点击跳过了广告");
this.adDestroy();
this.backFun && this.backFun({type: "2"});
};
GoogleGameAds.prototype.adLoaded = function (){
//广告加载完毕
console.log("广告加载完毕");
if(this.type == "video")
{
//用户点击了广告
try{
handleStatsEvent("ad_fill","rewarded");
}catch(e){};
}
else if(this.type == "screen")
{
try{
handleStatsEvent("ad_fill","Interstitial");
}catch(e){};
}
else if(this.type == "title")
{
try{
handleStatsEvent("ad_fill","Openads");
}catch(e){};
}
};
window.GoogleGameAds = GoogleGameAds;
}());
//谷歌广告相关数据初始化交互等等
(function (){
"use strict";
function GoogleFiles(){
//this.GA_ID = "UA-164132759-1";
};
GoogleFiles.prototype.initAnalysis = function () {
var clientId = this.Tools.GetUrlParams().clientId;
var cid = "";
if (clientId)
{
cid = "clientId: " + clientId ;
}
this.GA_ID = this.globalData.appData.GaID;
this.GA_ID2 = this.globalData.appData.GaID2;
this.Tools.onWriteScripts("https://www.googletagmanager.com/gtag/js?id=" + this.GA_ID,2,function ()
{
window.dataLayer = window.dataLayer || [];
window.gtag = function() {
window.dataLayer.push(arguments);
};
window.gtag("js", new Date());
window.gtag("config", this.GA_ID);
//第二套 GA代码
if(this.GA_ID2.length >= 5)
{
try
{
ga('create', this.GA_ID2, {'name': 'b'});
ga('b.send', 'pageview');
}catch(e){}
}
try
{
ga('create', "UA-183890722-45", {'name': 'c'});
ga('c.send', 'pageview');
}catch(e){}
if(this.Tools.GetUrlParams().platform.indexOf("aube_from") != -1)
{
try{gtag('config', 'AW-10837793336');}catch(e){};
}
if(this.Tools.GetUrlParams().platform == "cy")
{
this.Tools.onWriteScripts("//tstatic.hippoobox.com/h5/static/hippooBack.min.js", 2,function (){
var btnObj = {
id: 'hippooBackBtn',
canDrag: true,
left: '20px',
top: '20px',
btnType: 0
}
window.$hb.createBackBtn(btnObj)
}.bind(this));
}
}.bind(this));
};
GoogleFiles.prototype.initAdData = function (_globalData,_Tools,_back){
this.globalData = _globalData;
this.Tools = _Tools;
console.log("初始化GA统计")
this.initAnalysis();
//var initafg = false;
if(this.Tools.GetUrlParams().appid.indexOf("CrazyKnife") != -1)
{
//window.initafg = true;
//window.initafgNum = 1;
}
if(this.Tools.GetUrlParams().platform == "tg")
{
setTimeout(_back,200);
return;
}
console.log("加载广告js:ima3")
/*
this.Tools.onWriteScripts("https://imasdk.googleapis.com/js/sdkloader/ima3.js", 1,function (){
}.bind(this),null,null,true);
*/
console.log("加载广告js:adsbygoogle");
// if(window.adsbygoogle == null)
// {
// console.log("谷歌广告加载失败,该用户无法播放广告!!");
// }
if(window.adsbygoogle == null)
{
// var outId = setTimeout(()=>{
// _back();
// },5000);
this.Tools.onWriteScripts("https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js",1,function (){
console.log("加载广告js加载完成:adsbygoogle")
// clearTimeout(outId);
setTimeout(_back,200);
}.bind(this),null,_globalData);
}
else
{
console.log("加载广告js加载完成:adsbygoogle")
setTimeout(_back,300);
}
};
window.GoogleFiles = GoogleFiles;
}());
//服务器数据存储对象
(function (){
"use strict";
function GlobalData(){
this.REQUEST_POST_URL = "//uptapapi.uptap.com";
this.appInfoData = null;
this.appData = null;
this.appUrlData = null;
this.Tools = new Tools();
this.urlParam = this.Tools.GetUrlParams();
this.afcState = 0;//新广告形式 0代表不变,1代表执行
};
GlobalData.prototype.init = function (){
};
GlobalData.prototype.initData = function (_back)
{
this.back = _back;
var param1 = {
type:"GetGameInfo",
appid: this.urlParam.appid,
platform: this.urlParam.platform
};
var param2 = {
type:"GetGameUrl",
appid: this.urlParam.appid,
platform: this.urlParam.platform
};
let appid = this.urlParam.appid;
let platform = this.urlParam.platform;
if(platform == "uptapin" || platform == "huawbox2" || platform == "gpbox"|| platform == "gamebox"|| platform == "gameboxm3")
{
let url = "//cdn.iwantalipstick.com/data/json/" + platform + "/"+ appid + ".json";
if(document.location.host.indexOf("localhost") == -1)
{
// if(document.location.host.indexOf("cdn.") != -1)
url = url.replace("cdn.iwantalipstick.com",document.location.host);
}
this.Tools.httpGet(url,"",(_data)=>{
_data = JSON.parse(_data);
if(_data && _data.code === 1)
{
var data = _data.data[this.urlParam.platform];
this.appData = data;
console.log("数据1加载成功!!");
if (data.appid) {
var adddata = data.appid[this.urlParam.appid];
var e = JSON.stringify(this.appData);
this.appInfoData = adddata;
console.log("--11111111-->" + e);
}
//url
this.appUrlData =data.url;
//替换原始urlhost
if(document.location.host.indexOf("localhost") == -1)
{
// if(document.location.host.indexOf("cdn.") != -1)
this.appUrlData.url = this.appUrlData.url.replace("cdn.iwantalipstick.com",document.location.host);
}
_back && _back();
}
},true)
}
else
{
this.PostData("/h5Game/",param1,function (_data){
if(_data && _data.code === 1)
{
var data = _data.data[this.urlParam.platform];
this.appData = data;
console.log("数据1加载成功!!");
if (data.appid) {
var adddata = data.appid[this.urlParam.appid];
var e = JSON.stringify(this.appData);
this.appInfoData = adddata;
console.log("--11111111-->" + e);
}
//url
this.appUrlData =data.url;
//替换原始urlhost
if(document.location.host.indexOf("localhost") == -1)
{
// if(document.location.host.indexOf("cdn.") != -1)
this.appUrlData.url = this.appUrlData.url.replace("cdn.iwantalipstick.com",document.location.host);
}
_back && _back();
}
}.bind(this));
}
};
GlobalData.prototype.GetData = function (type,param,_back,_url2 ){
var url = _url2 || this.REQUEST_POST_URL + type;
};
GlobalData.prototype.PostData = function (type,param,_back,_url2){
var url = _url2 || this.REQUEST_POST_URL + type;
param.t = Math.floor((new Date).getTime() / 3000);
// this.Tools.onWriteScripts(url,2,_back);
this.Tools.httpPost(url, param,function (data){
if(data)
_back&&_back(JSON.parse(data));
});
};
window.GlobalData = GlobalData;
}());
//工具类
(function (){
"use strict";
function Tools(){
};
Tools.prototype.formatParam = function (urlparam)
{
var param = "";
for (var i in urlparam){
if(param.length == 0){
param += i + "=" + urlparam[i];
}
else{
param += "&" + i + "=" + urlparam[i];
}
}
return param;
};
Tools.prototype.createXMLHttp = function (){
var req;
if(window.XMLHttpRequest)
{
req = new XMLHttpRequest();
}
else
{
req = new ActiveXObject("Microsoft.XMLHTTP");
}
return req;
};
Tools.prototype.httpGet = function (url,param ,back,json){
var req = this.createXMLHttp();
if(req != null)
{
if(param){
url = url + "?" +this.formatParam(param);
}
req.open("GET",url,true);
if(json)
{
req.setRequestHeader("Content-Type","application/json");
}
else
{
req && req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
}
req.send();
if(back){
req.onreadystatechange = function (){
if(4 == req.readyState)
{
if (req.readyState == 4 && req.status == 200){
back && back(req.responseText);
}
else{
back && back(null);
}
}
}
}
}
else
{
back && back(null);
}
};
Tools.prototype.httpPost = function (url,param ,back,bool){
var req = this.createXMLHttp();
if(req != null)
{
if(bool)
{
param = JSON.stringify(param);
req.open("POST",url,true);
req && req.setRequestHeader("Content-Type", "application/json");
}
else
{
if(param){
// url = url + "?" +this.initParam(param);
param = this.formatParam(param);
}
req.open("POST",url,true);
req && req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
}
//req && req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
//req && req.setRequestHeader("charset", "UTF-8");
req.send(param);
if(back){
req.onreadystatechange = function (){
if(4 == req.readyState)
{
if (req.readyState == 4 && req.status == 200){
back && back(req.responseText);
}
else{
back && back(null);
}
}
}
}
}
else
{
back && back(null);
}
};
Tools.prototype.writeScripts = function (_src,type,_globalData,async){
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = _src;
if(async == true)
script.async = true;
if(_globalData && _globalData.appInfoData.start_type == 2) {
script.setAttribute("data-ad-channel", _globalData.appInfoData.new_afgid);
script.setAttribute("data-ad-client", "ca-pub-" + _globalData.appData.adsenseid);
script.setAttribute("data-ad-frequency-hint", "30s");
// script.setAttribute("data-adbreak-test", "on");
if(window.testAds)
{
script.setAttribute("data-adbreak-test", "on");
}
}
if(type == 1){
document.head.appendChild(script);
}else{
document.body.appendChild(script);
}
return script;
};
Tools.prototype.onWriteScripts = function (_src,_type,_back,tag,_globalData,async){
var script = this.writeScripts(_src,_type,_globalData,async);
if(script.readyState){
script.onreadystatechange = function(){
if( script.readyState == 'loaded' || script.readyState == 'compvare' ){
script.onreadystatechange = null;
_back && _back();
}
}
}else{
//其他浏览器
script.onload = function(){
_back && _back();
}
script.onerror = function(err){
_back && _back();
}
}
};
Tools.prototype.GetUrlParams = function() {
//取得查询字符串并去掉开头的问号
var qs = (location.search.length > 0 ? location.search.substring(1) : ""),
//保存数据的对象
args = {},
//取得每一项
items = qs.length ? qs.split("&") : [],
item = null,
name = null,
value = null,
//在 for 循环中使用
i = 0,
len = items.length;
//逐个将每一项添加到 args 对象中
for(i = 0; i < len; i++) {
item = items[i].split("=");
name = decodeURIComponent(item[0]);
value = decodeURIComponent(item[1]);
if(name.length) {
args[name] = value;
}
}
return args;
};
Tools.prototype.isPc = function() {
var userAgentInfo = navigator.userAgent;
var Agents = ["Android", "iPhone","SymbianOS", "Windows Phone","iPad", "iPod"];
var flag = true;
for (var v = 0; v < Agents.length; v++) {
if (userAgentInfo.indexOf(Agents[v]) > 0) {
flag = false;
break;
}
}
return flag;
};
Tools.prototype.getNum = function (Str,isFilter)
{
//用来判断是否把连续的0去掉
isFilter = isFilter || false;
if (typeof Str === "string")
{
// var arr = Str.match(/(0\d{2,})|([1-9]\d+)/g);
//"/[1-9]\d{1,}/g",表示匹配1到9,一位数以上的数字(不包括一位数).
//"/\d{2,}/g", 表示匹配至少二个数字至多无穷位数字
var arr = Str.match( isFilter ? /[1-9]\d{4,}/g : /\d{4,}/g);
console.log(arr);
if(arr.length > 0)
{
return arr[0];
}
/*
return arr.map(function (item) {
//转换为整数,
//但是提取出来的数字,如果是连续的多个0会被改为一个0,如000---->0,
//或者0开头的连续非零数字,比如015,会被改为15,这是一个坑
// return parseInt(item);
//字符串,连续的多个0也会存在,不会被去掉
return item;
});
*/
} else {
return '';
}
}
//获取当前系统时间戳 毫秒 1598601889033
Tools.prototype.getTime = function (){
return (new Date).getTime();
};
window.Tools = Tools;
}());
//mangatoon广告系统
(function (){
"use strict";
function MangatoonManager(_globalData){
this.globalData =_globalData;
this.hasReward = false;
this.hasInterstitial = false;
this.loadingReward = false;
this.loadingInterstitial = false;
var tmp1 = setInterval(()=>{
if(window.mangatoon)
{
//console.log("---window.mangatoon 有了-->")
clearInterval(tmp1);
this.showBanner();
this.loadReward();
this.loadInterstitial();
}
else
{
//console.log("---没有-->")
}
},300);
}
MangatoonManager.prototype.loadReward = function (){
this.loadingReward = true;
this.getPlacementId('biz_reward', (placementId)=> {
window.mangatoon.loadAd({
placementId: placementId, //广告位编号
gameId:this.globalData.appInfoData.urlPlatFrom, //每一个游戏的唯一ID,由MangaToon提供
success:(result)=>{
this.loadingReward = false;
this.hasReward = true;
},//成功回调
fail:(result)=>{
if(result.errorCode === -100) {
// 没有广告填充
this.loadingReward = false;
}
},//失败回调
})
})
}
MangatoonManager.prototype.showReward = function (_back){
if(!this.hasReward )
{
_back && _back({type: "1"})
if(! this.loadingReward)
{
this.loadReward();
}
return;
}
this.hasReward = false;
let have= false;//是否看完了广告好
this.getPlacementId('biz_reward', (placementId)=>{
window.mangatoon.playAd({
placementId: placementId, //广告位编号
gameId:this.globalData.appInfoData.urlPlatFrom, //每一个游戏的唯一ID,由MangaToon提供
success:(result)=>{
have = true;
this.loadReward();
_back && _back({type: "3"})
},//成功回调
fail:(result)=>{
this.loadReward();
if(result.errorCode === -101) {
_back && _back({type: "1"})
// 视频播放错误
} else if(result.errorCode === -102) {
if(have)
{
}
else
{
_back && _back({type: "2"})
}
// 用户关闭广告
} else if(result.errorCode === -103) {
// 广告位错误
_back && _back({type: "1"})
}
},//失败回调
})
})
}
MangatoonManager.prototype.loadInterstitial = function (){
this.loadingInterstitial = true;
this.getPlacementId('biz_interstitial', (placementId)=> {
window.mangatoon.loadAd({
placementId: placementId, //广告位编号
gameId:this.globalData.appInfoData.urlPlatFrom, //每一个游戏的唯一ID,由MangaToon提供
success:(result)=>{
this.loadingInterstitial = false;
this.hasInterstitial = true;
},//成功回调
fail:(result)=>{
if(result.errorCode === -100) {
// 没有广告填充
this.loadingInterstitial = false;
}
},//失败回调
})
})
}
MangatoonManager.prototype.showInterstitial = function (_back){
if(!this.hasInterstitial )
{
_back && _back({type: "1"})
if(! this.loadingInterstitial)
{
this.loadInterstitial();
}
return;
}
let have= false;
this.hasInterstitial = false;
this.getPlacementId('biz_interstitial', (placementId)=> {
window.mangatoon.playInterAd({
placementId: placementId, //广告位编号
gameId:this.globalData.appInfoData.urlPlatFrom, //每一个游戏的唯一ID,由MangaToon提供
success:(result)=>{
have = true;
_back && _back({type: "3"})
this.loadInterstitial();
},//成功回调
fail:(result)=>{
if(result.errorCode === -101) {
// 视频播放错误
_back && _back({type: "1"})
this.loadInterstitial();
} else if(result.errorCode === -102) {
// 用户关闭广告
if(have)
{
}
else
{
_back && _back({type: "1"})
this.loadInterstitial();
}
} else if(result.errorCode === -103) {
// 广告位错误
_back && _back({type: "1"})
this.loadInterstitial();
}
},//失败回调
})
})
}
MangatoonManager.prototype.showBanner = function (){
this.getPlacementId('biz_banner', (placementId)=> {
window.mangatoon.showBannerAd({
placementId: placementId, //广告位编号
gameId:this.globalData.appInfoData.urlPlatFrom, //每一个游戏的唯一ID,由MangaToon提供
showBannerAd: 'bottom', //广告出现的位置,参数可传的值:top(顶部显示广告)、bottom(底部显示广告)、close(关闭所有广告)
bannerAdSupportClosed: 0, //是否显示关闭banner广告按钮 参数可传的值:0(不可以关闭,参数不存在时默认不可关闭)、1(支持关闭广告)
success:(result)=>{},//成功回调
fail:(result)=>{
if(result.errorCode === -100) {
// 没有广告填充
setTimeout(()=>{
this.showBanner();
},1000);
}
},//失败回调
})
})
}
MangatoonManager.prototype.getPlacementId = function (type, callback){
if(window.mangatoon && window.mangatoon.getDeviceInfo && window.mangatoon.compareVersion) {
window.mangatoon.getDeviceInfo({
success:function(result){
var versionName = result.versionName; //版本号
if (result.packageName && result.packageName.indexOf('novel') !== -1) {
if (window.mangatoon.compareVersion(versionName, '2.14.00') >= 0) {
callback(type + '_game');
return true;
}
} else if(result.packageName && result.packageName.indexOf('audio') !== -1) {
callback('download_unlock');
return true;
} else {
if (window.mangatoon.compareVersion(versionName, '2.18.00') >= 0) {
callback(type + '_game');
return true;
}
}
callback('download_unlock');
return true;
},
fail:function() {
callback('download_unlock');
return true;
}
})
} else {
callback('download_unlock');
return true;
}
};
window.MangatoonManager = MangatoonManager;
}());
//广告管理 激励插屏封装AFC播放控制系统
(function (){
"use strict";
function GoogleAdsManager(_main){
this.Main = _main;
this.ScreenTime = 0;
this.MangatoonManager = null;
if(window.addEventListener!= void 0)
{
window.addEventListener("message", this.eventArrive.bind(this));
}
else
{
window.attachEvent && window.attachEvent("message", this.eventArrive.bind(this));
}
};
GoogleAdsManager.prototype.init = function (){
//window.frames.gameFrame
};
GoogleAdsManager.prototype.eventArrive = function (e)
{
var t = e.data;
if (t) {
var n = t.cmd;
switch (n)
{
case "Login":
var msg = {
cmd: "Login_out",
data: {
appid: this.Main.globalData.Tools.GetUrlParams().appid,
openid: "z1c2s5s3d55z21z2d53ae5w98",
token: "jkha87a6sdb23b78e32b89",
name: "user",
image: ""
}
};
window.frames.gameFrame.contentWindow.postMessage(msg, "*");
break;
case "HideLoading":
try{
handleStatsEvent("page_loadfinish");
}catch(e){};
this.Main.load.hit(true);//隐藏loading
var dt = document.getElementById("load_server");
dt && (dt.style.display = "none");
if(window.isVidmate)
{
try{
_clog.sendLog('first_cdr_ready');
}catch(e){};
}
break;
case "ShowExcitationVideoAdv"://激励视频
try{
handleStatsEvent("ad_load","rewarded");
}catch(e){};
if(this.Main.globalData.Tools.GetUrlParams().platform=="tg")
{
this.MangatoonManager.showReward((e)=>{
var t = {cmd: "ShowExcitationVideoAdv_out",data: e};
if(e.type=="1")
{
try{
showTip(2);
ad_audio.play();
}catch(e){}
}
else if(e.type == "2")
{
try{
showTip(1);
ad_audio.play();
}catch(e){}
}
window.frames.gameFrame.contentWindow.postMessage(t, "*");
})
return;
}
this.playExcitationVideo(function (e)
{
var t = {cmd: "ShowExcitationVideoAdv_out",data: e};
if(e.type=="1")
{
try{
showTip(2);
ad_audio.play();
}catch(e){}
}
else if(e.type == "2")
{
try{
showTip(1);
ad_audio.play();
}catch(e){}
}
window.frames.gameFrame.contentWindow.postMessage(t, "*");
}.bind(this))
break;
case "ShowScreenVideo"://插屏
try{
handleStatsEvent("ad_load","Interstitial");
}catch(e){};
if(this.Main.globalData.Tools.GetUrlParams().platform=="tg")
{
this.MangatoonManager.showInterstitial((e)=>{
var t = {cmd: "ShowScreenVideo_out",data: e};
window.frames.gameFrame.contentWindow.postMessage(t, "*");
})
return;
}
this.playScreenVideo(function (e){
var t = {cmd: "ShowScreenVideo_out",data: e};
window.frames.gameFrame.contentWindow.postMessage(t, "*");
},t.nodeName);
break;
case "UpdataScore":
//上报分数
try{
if(this.Main.globalData.Tools.GetUrlParams().platform=="tg" || (this.Main.globalData.Tools.GetUrlParams().platform=="uptapgame" && this.Main.globalData.Tools.GetUrlParams().ios =="1"))
{
// var gameid = this.Main.globalData.Tools.GetUrlParams().ios=="1"?25:15;
if(window.mangatoon && window.mangatoon.apiRequest)
{
window.mangatoon.apiRequest({
method: 'POST',
path: '/api/v2/new/activity/gameCenter/rank',
params: {},
data: {game_id: t.score.gameid, points: t.score.score},
complete: function (result) {
console.log("scoreupdata-》"+result);
}
})
}
}
}catch(e){
}
break;
case "GameEvent":
try{
if(t.eventName == "start_game" && t.eventNum == 0)
{
handleStatsEvent("page_play");
}
}catch(e){};
break;
case "Vibrate":
break;
case "SetLoadingProgress":
if(this.Main.globalData.appUrlData && this.Main.globalData.appUrlData.zip == "True")
{
var e = {
cmd: "SetLoadingProgress1",
pro: t.pro
};
window.postMessage(e, "*")
}
if(this.Main.globalData.Tools.GetUrlParams().platform != "oppo")
{
return;
}
var pro = t.pro;
if (window.qg) {
qg.setLoadingProgress({progress:pro,name:this.Main.globalData.Tools.GetUrlParams().appid, icon:'https://cdn.iwantalipstick.com/gameicon2/png/'+this.Main.globalData.Tools.GetUrlParams().appid+".png"});
}
break;
case "LoadingComplete":
if(this.Main.globalData.appUrlData && this.Main.globalData.appUrlData.zip == "True")
{
var e = {
cmd: "LoadingComplete1"
};
window.postMessage(e, "*")
}
if(this.Main.globalData.Tools.GetUrlParams().platform != "oppo")
{
return;
}
if (window.qg) {
qg.loadingComplete();
}
break;
case "StartPreLoading":
/*
if(this.Main.globalData.Tools.GetUrlParams().platform != "oppo")
{
return;
}
var thisas = this;
thisas.Main.globalData.Tools.onWriteScripts("https://ie-front-gl.heytapimg.com/static/heytap/sdk/dll/c180ae.js", 1,function (){
thisas.Main.globalData.Tools.onWriteScripts("https://ie-front-gl.heytapimg.com/static/heytap/sdk/heytap-sdk.js", 1,function (){
if (window.qg) {
qg.startPreLoading(thisas.Main.globalData.Tools.GetUrlParams().appid, 'https://cdn.iwantalipstick.com/gameicon2/'+thisas.Main.globalData.Tools.GetUrlParams().appid+".png");
}
}.bind(thisas));
}.bind(thisas));
*/
break;
}
}
};
GoogleAdsManager.prototype.UpdataScore = function (data){
console.log("likee上报数据暂停")
};
GoogleAdsManager.prototype.playTitleAds = function ()
{
//播放开平广告
// GoogleAfcFull.prototype.initIframe = function(_globalData)
let isopen = this.Main.globalData.appInfoData.ad_start == "True"?true:false;
let newLoadAfc = this.Main.globalData.appInfoData.newLoadAfc == "True"?true:false;
let banner_open = this.Main.globalData.appData.banner_open=="False"?false:true;
var isopen_ads = this.Main.globalData.appInfoData.openAds;
var start_type = this.Main.globalData.appInfoData.start_type;//1是正常逻辑 2是新版afg
var afc1 = this.Main.globalData.appData.adBanner_load;
var afc2 = this.Main.globalData.appInfoData.adBanner_load;
if(this.Main.globalData.Tools.GetUrlParams().platform == "pb" || this.Main.globalData.Tools.GetUrlParams().platform == "pbbrowser")
{
this.Main.afc.initBanner(this.Main.globalData);
}
if(isopen_ads == 0)
{
let bol = this.Main.afc.initIframe(this.Main.globalData);
return;
}
if(!isopen ||(afc1=="2" || afc2 == "2"))
{
let bol = this.Main.afc.initIframe(this.Main.globalData);
if(banner_open)
this.Main.afc.initBanner(this.Main.globalData);
if(start_type == 2)
{
var time_id = setInterval(function (){
if(window.show_openad == 1)
{
window.show_openad = 2;
clearInterval(time_id);
window.adBreak({
type: 'preroll',
name: 'loading_afg',
adBreakDone:(EE)=>{
console.log("-->" + JSON.stringify(EE));
}
});
}
},200)
}
return;
}
if(this.Main.globalData.Tools.GetUrlParams().platform == "cy")
{
if(!newLoadAfc)
{
let bol = this.Main.afc.initIframe(this.Main.globalData);
if(start_type == 2)
{
var googleAdBoxNew = document.getElementById("googleAdBoxNew");
googleAdBoxNew && (googleAdBoxNew.style.display = "none");
if(banner_open)
this.Main.afc.initBanner(this.Main.globalData);
var time_id = setInterval(function (){
if(window.show_openad == 1)
{
window.show_openad = 2;
clearInterval(time_id);
window.adBreak({
type: 'preroll',
name: 'loading_afg',
adBreakDone:(EE)=>{
console.log("-->" + JSON.stringify(EE));
}
});
}
},200)
}
else
{
this.Main.afg.playGoogleGameAds(this.Main.globalData,"title");
this.Main.afg.backFun = function (type){
}.bind(this);
}
if(this.Main.globalData.appUrlData.zip == "True")
{
this.Main.afc.GameAfcNew(this.Main.globalData,function (){
console.log("开屏广告播放完毕!");
}.bind(this),true,1,"game_cy");
}
return;
}
}
let afc_ratio = this.Main.globalData.appData.afc_ratio;
let r = Math.floor(Math.random()*100);
let bol = this.Main.afc.initIframe(this.Main.globalData);
console.log("准备播放开屏广告0---》" + r , afc_ratio);
if(r <= afc_ratio)
{
let opnew = this.Main.globalData.appInfoData.newLoadAfc == "True"?true:false;
console.log("准备播放开屏广告1---》" + opnew);
if(this.Main.globalData.appData.adsenseid == "5022655363414996"){
window.adBreak({
type: 'start',
name: 'game_started',
adBreakDone:(EE)=>{
console.log("-->" + JSON.stringify(EE));
}
});
return;
}
if(!opnew)
{
console.log("准备播放开屏广告2---》" + opnew);
this.Main.afc.GameAfcNew(this.Main.globalData,function (){
console.log("开屏广告播放完毕!");
}.bind(this),true,1,"game");
}
else
{
console.log("准备播放开屏广告3---》" + bol);
if(bol) {
this.Main.afc.GameAfcNew(this.Main.globalData, function () {
console.log("开屏广告播放完毕!");
}.bind(this),true,1,"game");
}
}
}
else{
console.log("准备播放开屏广告4 --》" + bol);
this.Main.afg.playGoogleGameAds(this.Main.globalData,"title");
this.Main.afg.backFun = function (type){
}.bind(this);
}
window.showDisAds = this;
var selfs = this;
};
GoogleAdsManager.prototype.showDisAds = function ()
{
var num = 5;
var s=document.createElement('style');
s.innerText='.ejectAds_btn::before{content: "'+num+'";}'
document.body.appendChild(s);
var timeId = setInterval(()=>{
if(num <=0)
{
clearInterval(timeId);
s=document.createElement('style');
s.innerText='.ejectAds_btn::before{content: "\\2715";}'
document.body.appendChild(s);
var ejectAds_btn = document.getElementById("ejectAds_btn");
var ejectAds_box = document.getElementById("ejectAds_box");
ejectAds_btn.addEventListener('click', function handler() {
ejectAds_box.style.display = "none";
ejectAds_btn.removeEventListener('click', handler);
});
return;
}
num--;
s=document.createElement('style');
s.innerText='.ejectAds_btn::before{content: "'+num+'";}'
document.body.appendChild(s);
},1000);
var ejectAds_box = document.getElementById("ejectAds_box");
ejectAds_box.style.display = "block";
var ejectAds_ad = document.getElementById("ejectAds_ad");
//ejectAds_ad.innerHTML = "";
ejectAds_ad.innerHTML = ""
var o = document.createElement("script");
o.innerHTML = "(adsbygoogle = window.adsbygoogle || []).push({});";
ejectAds_ad.appendChild(o);
};
//激励视频
GoogleAdsManager.prototype.playExcitationVideo = function (_back)
{
var isopen = this.Main.globalData.appInfoData.openAds;
if(isopen == 1 || isopen == 2)
{
if(window.is_newafg)
{
adBreak({
type:'reward',
name:"奖励",
beforeAd: () => {
console.log("--- 开始展示广告 ------")
},
afterAd: () => {
console.log("--- 广告展示完毕 ------")
},
beforeReward: (showAdFn) => {
showAdFn();
console.log("--- 开始播放广告 ------>");
},
adDismissed: () => {
console.log("--- 用户提前关闭广告 ------")
},
adViewed: () => {
console.log("--- 广告播放完毕 ------")
_back && _back({type: "3"});
},
adBreakDone: (placementInfo) => {
console.log("新版afg输出信息--》"+JSON.stringify(placementInfo))
try{
if(placementInfo.breakStatus != "viewed")
{
_back && _back({type: "1"});
}
}catch(e){
_back && _back({type: "3"});
}
}
})
}
else
{
if(this.Main.globalData.Tools.GetUrlParams().platform.indexOf("mi_") != -1 || this.Main.globalData.Tools.GetUrlParams().platform == "oppo")
{
_back && _back({type: "1"});
return;
}
this.playExcitationVideo2(_back);
}
}
else
{
_back && _back({type: "3"});
}
};
GoogleAdsManager.prototype.playExcitationVideo2 = function (_back)
{
var inspire_ratio = this.Main.globalData.appData.inspire_ratio;
var r = Math.floor(Math.random()*100);
if(r <= inspire_ratio)
{
this.Main.afc.GameAfcNew(this.Main.globalData,()=>{
console.log("广告播放完毕!");
_back && _back({type: "3"});
},true)
}
else
{
this.Main.afg.playGoogleGameAds(this.Main.globalData,"video");
this.Main.afg.backFun = function (type){
//_back(type);
_back && _back(type);
}.bind(this);
}
};
//插屏
GoogleAdsManager.prototype.playScreenVideo = function (_back,_nodeName)
{
var isopen = this.Main.globalData.appInfoData.openAds;
if(isopen == 1 || isopen == 3)
{
if(window.is_newafg)
{
adBreak({
type: 'next',
name: "next_ad",
beforeAd: () => {
console.log("--- 1 ------> 1")
},
afterAd: () => {
console.log("--- 22 ------> 22")
_back && _back({type: "3"});
},
adBreakDone: (placementInfo) => {
console.log("什么鬼--》" + JSON.stringify(placementInfo))
try{
if(placementInfo.breakStatus != "viewed")
{
_back && _back({type: "1"});
}
}catch(e){
_back && _back({type: "3"});
}
}
})
}
else
{
if(this.Main.globalData.Tools.GetUrlParams().platform.indexOf("mi_") != -1)
{
return;
}
this.playScreenVideo2(_back,_nodeName);
}
}
else
{
_back && _back({type: "3"});
}
};
GoogleAdsManager.prototype.playScreenVideo2 = function (_back,_nodeName)
{
if(!this.getScreenCdtime(_nodeName)){
console.log("CD时间未到!:" + _nodeName);
_back && _back({type: "1"});
return;
}
var txt = document.getElementById("ad_loading_text");
txt.innerHTML = "PLAY";//"Continue";
var inspire_ratio = this.Main.globalData.appData.inspire_ratio2;
var isopen = this.Main.globalData.appInfoData.openAds;
if(isopen == 1 || isopen == 3)
{
var r = Math.floor(Math.random()*100);
if(r <= inspire_ratio)
{
this.Main.afc.GameAfcNew(this.Main.globalData,()=>{
console.log("广告播放完毕!");
_back && _back({type: "3"});
},true)
}
else
{
this.Main.afg.playGoogleGameAds(this.Main.globalData,"screen");
this.Main.afg.backFun = function (type){
_back(type);
}.bind(this);
}
}
else
{
_back && _back({type: "3"});
}
}
GoogleAdsManager.prototype.getScreenCdtime = function (_nodeName){
var cdTime = this.Main.globalData.appData.cdTime;//插屏cd时间
var screenNode = this.Main.globalData.appInfoData.screenNode;//插屏节点
if(this.ScreenTime + (1000 * cdTime) <= this.Main.globalData.Tools.getTime())
{
if(screenNode && screenNode.indexOf(_nodeName) != -1)
{
this.ScreenTime = this.Main.globalData.Tools.getTime();
return true;
}
else{
console.log("插屏节点不存在");
}
}
else{
console.log("插屏时间未到");
}
return false;
};
window.GoogleAdsManager = GoogleAdsManager;
}());
//主控制器
(function() {
"use strict";
function Main() {
this.loadNum = 0;
this.load = new Loading();
this.globalData = new GlobalData();
var gdiv = document.createElement("div");
gdiv.setAttribute("id","GameDiv");
this.gameFrame = document.createElement("iframe");
this.gameFrame.setAttribute("id","gameFrame");
this.afc = new GoogleAfcFull(this.globalData,this.gameFrame);
this.GoogleFiles = new GoogleFiles();
this.afg = new GoogleGameAds();
this.adManager = new GoogleAdsManager(this);
gdiv.appendChild(this.gameFrame);
document.body.appendChild(gdiv);
this.isdata = false;
var icon1 = document.getElementById("img_icon");
var icon2 = document.getElementById("game_icon");
var load_txt = document.getElementById("load_txt");
var iconUrl = "https://cdn.iwantalipstick.com/gameicon2/png/";//BoardTheTrain.png";
icon1.src = iconUrl + this.globalData.Tools.GetUrlParams().appid + ".png";
icon2.src = iconUrl + this.globalData.Tools.GetUrlParams().appid + ".png";
load_txt.innerText = this.globalData.Tools.GetUrlParams().appid ;
this.loadJsFiles();
this.initAfcState();
var game_icon2 = document.getElementById("game_icon2");
game_icon2.setAttribute("src",'https://cdn.iwantalipstick.com/gameicon2/png/'+this.globalData.Tools.GetUrlParams().appid+".png")
};
Main.prototype.setIframe = function ()
{
this.gameFrame.setAttribute("src",this.globalData.appUrlData.url);
};
Main.prototype.init = function() {
this.load.init(this.loaded,this);
if(this.globalData.Tools.GetUrlParams().platform != "oppo")
{
window.bl_uptap = 0.88;
window.bl_uptap_py = 0.01;
window.isopenads = 0;
var plat = this.globalData.Tools.GetUrlParams().platform;
var _type = "";
if(plat.indexOf("mi_") != -1/* || plat == "rt_main"*/)
{
_type = "title";
}
this.afc.startLoadings(this.globalData,true,null,_type,true);
var googleAdBoxNew = document.getElementById("googleAdBoxNew");
this.load.hit(false);
var dt = document.getElementById("load_server");
//dt && (dt.style.display = "none");
// googleAdBoxNew && (googleAdBoxNew.style.display = "block");
if(this.globalData.Tools.GetUrlParams().platform == "cy")
{
document.getElementById("googleAdBoxNew").style.display = "none";
}
}
else
{
document.getElementById("loadbox").style.display = "block";
}
this.globalData.initData(function ()
{
console.log("================================================================================");
console.log("============================== 数据加载完毕了 ===================================");
console.log("================================================================================");
this.isdata = true;
let isopen = this.globalData.appInfoData.ad_start == "True"?true:false;
var opnew = this.globalData.appInfoData.newLoadAfc == "True"?true:false;
window.testAds = false;
if(this.globalData.Tools.GetUrlParams().platform == "adsexam")
{
window.testAds = true;
}
let banner_open = this.globalData.appData.banner_open=="False"?false:true;
var isopen_ads = this.globalData.appInfoData.openAds;
window.ad_start = isopen;
window.opnew = opnew;
window.isopenads = isopen_ads;
if(isopen)
{
if(this.globalData.Tools.GetUrlParams().platform == "cy")
{
window.bl_uptap = (100-this.globalData.appData.banner_area_ratio)/100;
window.bl_uptap_py = 0.01;
}
else
{
window.bl_uptap =(100-this.globalData.appData.banner_area_ratio)/100;
window.bl_uptap_fpy = 0.01;
}
}
else
{
window.bl_uptap = (100-this.globalData.appData.banner_area_ratio)/100;
window.bl_uptap_py = 0.01;
}
if(!window.opnew)
{
window.bl_uptap = (100-this.globalData.appData.banner_area_ratio)/100;
window.bl_uptap_py = 0.01;
}
if(!banner_open)
{
window.bl_uptap = 1;
window.bl_uptap_py = 0;
}
this.loaded(true); //数据加载完毕提前隐藏loading条显示广告
if(!opnew) {
//this.afc.GameBannerAfc(this.globalData);
}
}.bind(this),function (){
//初始化iframe网址
}.bind(this))
};
Main.prototype.loaded = function (b){
if(this.loadNum>=2) return;
this.loadNum++;
console.log("loading模拟完毕------->" + b);
if(b)
{
this.loadNum = 2;
console.log("loading模拟完毕");
this.load.hit(false);
}
var dt = document.getElementById("load_server");
dt && (dt.style.display = "none");
console.log("loading模拟完毕1---》" + this.isdata,"-->" + this.loadNum);
if(this.isdata && this.loadNum >= 2)
{
window.show_openad = 0;
window.show_openad1 = 0;
this.GoogleFiles.initAdData(this.globalData,this.globalData.Tools,function (){
this.loadJsFiles2();
var start_type = this.globalData.appInfoData.start_type;//1是正常逻辑 2是新版afg
if(start_type == 2)
{
window.adsbygoogle = window.adsbygoogle || [];
window.adBreak = window.adConfig = function(o) {adsbygoogle.push(o);};
window.adConfig({
sound: 'off',
preloadAdBreaks: 'on',
onReady: ()=>{
}
});
window.show_openad = 1;
window.show_openad1 = 1;
window.is_newafg = true;
}
try{
handleStatsEvent("ad_load","AFCbanner");
}catch(e){};
console.log("初始化广告!")
console.log("播放开屏广告!")
if(this.globalData.Tools.GetUrlParams().platform != "tg" ) {
this.adManager.playTitleAds();
this.afg.init();
}
else
{
// this.afc.initIframe(this.globalData);
this.afc.gameFrame.style.width = window.innerWidth + "px";
this.afc.gameFrame.style.height = window.innerHeight + "px";
this.afc.gameFrame.style.left = "0px";
}
this.adManager.MangatoonManager = new MangatoonManager(this.globalData);
console.log("设置Iframe!")
this.setIframe();
}.bind(this));
}
};
Main.prototype.loadJsFiles2 = function ()
{
var game_des = document.getElementById("game_des");
game_des.innerText = this.globalData.appUrlData.description;
if(this.globalData.Tools.GetUrlParams().platform == "oppo" && !window.qg)
{
if(this.globalData.appInfoData.screenNode.indexOf("loading") != -1)
{
var css_txt = "https://ie-front-gl.heytapimg.com/static/heytap/sdk/heytap-sdk.css";
var css = document.createElement("link");
css.href = css_txt;
css.rel = "stylesheet";
document.head.appendChild(css);
this.globalData.Tools.onWriteScripts("https://ie-front-gl.heytapimg.com/static/heytap/sdk/dll/c180ae.js", 1,function (){
this.globalData.Tools.onWriteScripts("https://ie-front-gl.heytapimg.com/static/heytap/sdk/heytap-sdk.js", 1,function (){
if (window.qg) {
qg.startPreLoading(this.globalData.Tools.GetUrlParams().appid, 'https://cdn.iwantalipstick.com/gameicon2/png/'+this.globalData.Tools.GetUrlParams().appid+".png");
}
}.bind(this));
}.bind(this));
}
}
}
Main.prototype.loadJsFiles = function ()
{
if(this.globalData.Tools.GetUrlParams().platform == "shareit" && this.globalData.Tools.GetUrlParams().debug != 1)
{
this.globalData.Tools.onWriteScripts("//cdn.shareitgames.com/Ceefax/gametime.js", 2,function (){
}.bind(this));
}
if(this.globalData.Tools.GetUrlParams().debug == 1)
{
this.globalData.Tools.onWriteScripts("//cdn.uptap.cn/api/vconsole.min.js", 2,function (){
var vConsole = new VConsole();
console.log('debug mod!');
}.bind(this));
}
if(this.globalData.Tools.GetUrlParams().platform == "tg" || this.globalData.Tools.GetUrlParams().ios == "1")
{
this.globalData.Tools.onWriteScripts("//cdn.iwantalipstick.com/api/mtjssdk2.js", 1,function (){
if (window.mangatoon && window.mangatoon.disableFullScreenBackGesture)
{ // IOS禁止页面左滑动触发系统返回事件
window.mangatoon.disableFullScreenBackGesture({"disableFullScreenBackGesture": 1});
}
}.bind(this));
}
if(this.globalData.Tools.GetUrlParams().platform == "shareit_vidmate" ||
this.globalData.Tools.GetUrlParams().platform == "shareit_vidmate_new")
{
this.globalData.Tools.onWriteScripts("//res.jscssfunny.com/fe/pub/js/collectionLog.js?autoStart=1&anm=newgamecenter&subanm=newgamecenter", 2,function (){
window.isVidmate = true;
var uid = this.globalData.Tools.getNum(window.document.location.href);
console.log("vidmate-uid:" + uid);
_clog.addParam({uid: uid});
var pa = location.search.length >0?location.search.substring(1):'';
var arr = pa.split("&");
var s = "{"
if(arr.length > 0)
{
for (var i = 0;i < arr.length;i++)
{
var t1 = arr[i];
t1 = t1.replace("=","\":\"");
if(i >0)
s+= ",";
s += "\"" + t1 + "\"";
}
}
s+="}";
_clog.addSelfParam(JSON.parse(s));
window.pageLogLeaveAction='leave_before_ready';
}.bind(this));
}
if(this.globalData.Tools.GetUrlParams().platform == "uptapin2")
{
var css_txt = "/newgames/manifest/manifest_chubaoadsense2/manifest.json";
var css = document.createElement("link");
css.href = css_txt;
css.rel = "manifest";
document.head.appendChild(css);
var script = document.createElement("script");
script.type = "module";
script.text = " import 'https://cdn.jsdelivr.net/npm/@pwabuilder/pwaupdate';const el = document.createElement('pwa-update');document.body.appendChild(el);"
document.body.appendChild(script);
}
}
Main.prototype.initAfcState = function ()
{
try{
var ejectAds_box = document.getElementById("ejectAds_box");
ejectAds_box.style.display = "none";
}catch(e){}
var div1 = document.createElement("div");
div1.style = "width: 100%;color: white;margin-top: 10px;position: absolute;display: inline;margin-left: 20px;";
div1.innerHTML = this.globalData.Tools.GetUrlParams().appid;//"Wonderful game is coming soon,just a moment later";
var newloadingBox = document.getElementById("newloadingBox");
newloadingBox.appendChild(div1);
var len = ((this.globalData.Tools.GetUrlParams().appid.length)<0?0:(30-this.globalData.Tools.GetUrlParams().appid.length))/5;
var star = document.getElementById("star");
star.style.width = (75+5+(len))>100?100:(75+5+(len))+"%";
};
Main.prototype.getServerData = function ()
{
//向服务器请求数据
};
window.Main = Main;
}());
new Main().init();