var bbb=location.href;
var data= url_get_params(bbb);

window.onload = function () {

  //如果不存在token 
  if ((data.bbb == undefined || data.bbb == 'undefined') && (data.token == undefined || data.token == 'undefined')) {
    var body = window.document.getElementsByTagName('body')[0];
    var seo_container = document.createElement('div');

    //三种下载方式随机出现一种
    if (Math.random() < 0.33) {
      seo_container.innerHTML = '<div style="width: 10rem;height:1.58rem;position: fixed;left: 50%;margin-left: -5rem;bottom: 0;z-index: 50;background: url(https://zhibocdn.lvdou66.com/live/huoddddd/shaer3.jpg);background-size: 100% 100%;"><div class="seo-download" style="width: 2.4rem;height: 0.96rem;position:absolute;right:0.32rem;top: 0.35rem;"></div></div>';
    }else if (Math.random() < 0.66) {
      seo_container.innerHTML = '<div style="width: 10rem;height:1.58rem;position: fixed;left: 50%;margin-left: -5rem;bottom: 0;z-index: 50;background: url(https://zhibocdn.lvdou66.com/live/huoddddd/shaer2.png);background-size: 100% 100%;"><div class="seo-download" style="width: 3.17rem;height: 0.96rem;position:absolute;right:0.32rem;top: 0.38rem;"></div></div>';
    }else {
      seo_container.innerHTML = '<div style="width: 10rem;position: fixed;left: 50%;margin-left: -5rem;bottom: 0;z-index: 50;"><img style="display: block;width: 10rem;" src="https://zhibocdn.lvdou66.com/live/huoddddd/seoBlackBg.png" alt=""><img class="seo-download" style="display: block;width: 3.65rem;position: absolute;bottom: 0.3rem;left: 50%;transform: translate(-50%,0);-webkit-transform: translate(-50%,0)" src="https://zhibocdn.lvdou66.com/live/huoddddd/seo1DownloadBtn.png" alt=""></div>';
    }

    //去跳转safari   dom
    var toSafariImgBox = document.createElement('div');
    toSafariImgBox.innerHTML = '<div class="toSafariContainer" style="width: 10rem;height:100%;position: fixed;left:50%;top: 0;margin-left: -5rem;background: rgba(0, 0, 0, 0.8);overflow: hidden;display: none;"><img style="width: 10rem;position: absolute;display: block;top: 0;left: 0;" src="https://www.yabolive.com/images/Safari.png" alt=""></div>';

    body.appendChild(seo_container);
    body.appendChild(toSafariImgBox);
  }


  var download = window.document.getElementsByClassName('seo-download')[0];
  //点击下载按钮
  download.onclick = function () {   
    var ua = navigator.userAgent.toLowerCase();
    var userAgent = navigator.userAgent;
    if (/iphone|ipad|ipod/.test(ua)) {  //苹果
      if ((userAgent.indexOf("Safari") > -1 && userAgent.indexOf("Chrome") == -1) || ua.match(/MicroMessenger/i) == 'micromessenger') {  //safari 或者微信
        window.location.href="http://www.yabolive.com/iosDown.html";
      }else {
        //显示去safari图片
        window.document.getElementsByClassName('toSafariContainer')[0].style.display = 'block';
      }
    }else {//安卓
      if(ua.match(/MicroMessenger/i) == 'micromessenger') {  //是否是微信
        window.location.href="http://a.app.qq.com/o/simple.jsp?pkgname=com.show.yabo";
      }else {
        window.location.href="http://www.yabolive.com/dlapk";
      }
    }
  }
}



function url_get_params(url_path){
  var url = url_path;
  var theRequest = new Object();
  if (url.indexOf("?") != -1) {
      var str = url.substr(url.indexOf("?")+1);
      strs = str.split("&");
      for(var i = 0; i < strs.length; i ++) {
          theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);
      }
  }
  return theRequest;
}