<!DOCTYPE html>
<html style="font-size: 15px;">

<head>
  <meta name="msvalidate.01" content="22A63C2D42FFCEFE66D133FA8C1C80A1" />
  <meta name="google-site-verification" content="qba6J79VPlZw5ZPxki_pOMDPuPpTUWB_XTGPA30E_9U" />
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
  <meta http-equiv="x-ua-compatible" content="IE=edge">
  <title>tic tac toe2</title>
  <meta name="keyword"
        content="tic tac toe2,tic tac toe2 app,tic tac toe2 apk">
  <meta name="description"
        content="Welcome to tic tac toe2 Join tic tac toe2 Start playing tic tac toe2">
  <!--  <link rel="Shortcut Icon" href="https://assets.googleplaystore.in/MWYF42N/static/images/icon.png" />-->
  <!--  <link rel="icon" href="https://assets.googleplaystore.in/MWYF42N/static/images/icon.png" type="image/png" sizes="16x16" alt="tic tac toe2">-->
  <script async src="https://assets.googleplaystore.in/MWYF42N/static/js/pub_rem.js"></script>
  <!-- Google tag (gtag.js) dynamically loaded with Thymeleaf -->
  <script src="https://www.googletagmanager.com/gtag/js?id=G-W4E9GB3DVY" async></script>

  <script>
    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}
    gtag('js', new Date());

    gtag('config', "G-W4E9GB3DVY");
  </script>

  <!-- Facebook Pixel dynamically loaded with Thymeleaf -->
  <script>
    /*<![CDATA[*/
    !function (f, b, e, v, n, t, s) {
      if (f.fbq) return;
      n = f.fbq = function () {
        n.callMethod ?
                n.callMethod.apply(n, arguments) : n.queue.push(arguments)
      };
      if (!f._fbq) f._fbq = n;
      n.push = n;
      n.loaded = !0;
      n.version = '2.0';
      n.queue = [];
      t = b.createElement(e);
      t.async = !0;
      t.src = v;
      s = b.getElementsByTagName(e)[0];
      s.parentNode.insertBefore(t, s)
    }(window, document, 'script',
            'https://connect.facebook.net/en_US/fbevents.js');
    fbq('init', "273456229192505");
    fbq('track', 'PageView');
    /*]]>*/
  </script>

  <noscript><img height="1" width="1" style="display:none"
                 src="https://www.facebook.com/tr?id=273456229192505&amp;ev=PageView&amp;noscript=1"/></noscript>
  <!-- End Facebook Pixel Code -->
</head>
<style>
  #img2 {
    width: 100%;
  }
  html {
    box-sizing: border-box;
    -webkit-scroll-behavior: smooth;
    -moz-scroll-behavior: smooth;
    -ms-scroll-behavior: smooth;
    scroll-behavior: smooth;
  }

  body {
    margin: 0;
  }

  a {
    -webkit-text-decoration: none;
    text-decoration: none;
  }

  p {
    margin: 0;
  }

  *,
  *:before,
  *:after {
    box-sizing: inherit;
  }

  * {
    -webkit-font-smoothing: antialiased;
  }
  body {
    margin: 0;
    padding: 0;
    background-color: white;
    font-family: "Microsoft YaHei";
  }

  .container {
    position: relative;
    max-width: 750px;
    min-width: 300px;
    margin: 0 auto;
  }
  .container .background {
    max-width: 100%;
    font-size: 0;
    line-height: 0;
    vertical-align: top;
    margin-top: -0.9px;
  }
  .container .piece-column {
    position: relative;
    line-height: 0;
    font-size: 0;
  }
  .container .download {
    position: absolute;
    left: 8%;
    right: 8%;
    height: 6rem;
  }
  .container .nav-btn {
    top: 0;
    right: 0;
    left: 50%;
  }

  .container .down-btn03 {
    bottom: 0%;
    width: 100%;
    height: 8rem;
  }
</style>

<body>
<div class="container">
  <div class="piece-column">
    <img class="background" src="https://assets.googleplaystore.in/asc/TFBDAQP/output_id/style/image/bg.jpg" alt="tic tac toe2" />
    <a href="javascript:download('download_button')" class="download nav-btn"></a>
    <a href="javascript:download('download_button')" class="download down-btn03"></a>
  </div>

</div>

<input type="hidden" id="downloadDomain" value="https://d2k4b2544y3e2a.cloudfront.net/CandyValley.apk" />


<input type="hidden" id="channel" value=""/>
<input type="hidden" id="appName" value="Teen Patti Master"/>
<input type="hidden" id="pkgType" value="1"/>
<input type="hidden" id="downloadDomain" value="https://d2k4b2544y3e2a.cloudfront.net/CandyValley.apk"/>
<input type="hidden" id="adjustTrackerToken" value="1e81kmdo"/>
<input type="hidden" id="onlinePkgUrl" value=""/>
<input type="hidden" id="ext" value=""/>
<input type="hidden" id="pixelId" value="273456229192505"/>
<input type="hidden" id="eventId" value="3e0fa24f-6742-4090-b1f0-f4f47d28204f"/>

</body>

<script>

  var fbp = getCookie('_fbp') || getQueryString('_fbp') || getQueryString("fbp") || getCookie('fbp');
  var fbc = getCookie('_fbc') || getQueryString('_fbc') || getQueryString("fbc") || getCookie('fbc');
  console.log('fbp', fbp)
  console.log('fbc', fbc)

  let pkgType = document.getElementById('pkgType').value;
  let downloadDomain = document.getElementById('downloadDomain').value;
  let adjustTracker = document.getElementById('adjustTrackerToken').value;
  let onlinePkgUrl = document.getElementById('onlinePkgUrl').value;
  let ext = document.getElementById('ext').value;
  let pxid = document.getElementById('pixelId').value;
  let appName = document.getElementById('appName').value;
  let channel = document.getElementById('channel').value;
  let eventId = document.getElementById('eventId').value;

  let extStr = JSON.stringify(ext)
  let encodeExtStr = encodeURIComponent(extStr)
  let offlineUrl;
  let url = '';

  let reportFlag = 0

  const startTime = Date.now();

  function checkCookie() {
    const startTime = Date.now();
    let timeCost = 0;
    const intervalId = setInterval(() => {
      const fbcValue = getCookie('_fbc');
      const currentTime = Date.now();
      if (fbcValue) {
        clearInterval(intervalId);

        timeCost = currentTime - startTime;
        reportLog(timeCost);
        console.log('Time cost:', timeCost, 'milliseconds');
      } else if (currentTime - startTime > 10000) {
        clearInterval(intervalId);
        timeCost = currentTime - startTime;
        reportLog(timeCost);
        console.log('Time cost exceeds 10 seconds. _fbc not found.');
      } else {
        console.log('Check Cookie: _fbc not found yet.');
      }
    }, 100);
    checkFbc(intervalId,startTime,timeCost)
  }

  function checkFbc(intervalId,starTime,timeCost) {
    console.log('checkFbc')
    const fbcValue = getCookie('_fbc');
    const currentTime = Date.now();
    if (fbcValue) {
      clearInterval(intervalId);
      timeCost = currentTime - startTime;
      reportLog(timeCost);
      console.log('Time cost:', timeCost, 'milliseconds');
    } else if (currentTime - startTime > 10000) {
      clearInterval(intervalId);
      timeCost = currentTime - startTime;
      reportLog(timeCost);
      console.log('Time cost exceeds 10 seconds. _fbc not found.');
    } else {
      console.log('Check Cookie: _fbc not found yet.');
    }
  }

  checkCookie();
  const urlParams = new Proxy({}, {
    get: (target, name) => name in target ? target[name] : ''
  });

  window.addEventListener("DOMContentLoaded", () => {
    const currentURL = window.location.href;
    const parsedURL = new URL(currentURL);
    const params = parsedURL.searchParams;
    for (const [param, value] of params) {
      urlParams[param] = value;
    }
  });
  console.log(urlParams)

  var gclid = getGclid();
  console.log('getGclid:', gclid)
  function getGclid() {
    let ups = readUrlParams();
    if(ups.gclid) {
      return ups.gclid
    }
    let adjust_referrer = ups.adjust_referrer
    if(adjust_referrer) {
      adjust_referrer = decodeURIComponent(adjust_referrer)
      let ar = adjust_referrer.split("=")
      console.log('ar:', ar)
      if(ar && ar.length > 1) {
        return ar[1]
      }
    }
    return ''
  }
  var wbraid = getQueryString("wbraid") || getCookie('wbraid');
  var gbraid = getQueryString("gbraid") || getCookie('gbraid');

  function getQueryString(name) {
    var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
    var r = window.location.search.substr(1).match(reg);
    if (r != null) {
      return unescape(r[2]);
    }
    return "";
  }

  function getCookie(cname) {
    let name = cname + "=";
    let ca = document.cookie.split(';');
    for (let i = 0; i < ca.length; i++) {
      let c = ca[i];
      while (c.charAt(0) == ' ') {
        c = c.substring(1);
      }
      if (c.indexOf(name) == 0) {
        return c.substring(name.length, c.length);
      }
    }
    return "";
  }

  function createEventId() {
    return 'xxxxxxxyx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
      var r = Math.random() * 16 | 0,
              v = c === 'x' ? r : (r & 0x3 | 0x8);
      return v.toString(16);
    });
  }

  if(pkgType === '1') {
    if(!downloadDomain.endsWith('.apk')) {
      offlineUrl = downloadDomain + '/cg/gaoct/fg/' + appName + '.apk?' + 'channel=' + channel + '&pxid=' + pxid + '&fbp=' + fbp + '&fbc=' + fbc + '&gclid=' + gclid + '&wbraid=' + wbraid + '&gbraid=' + gbraid + '&eventId=' + eventId + '&ext=' + encodeExtStr;
      url = offlineUrl;
    } else {
      url = downloadDomain
    }
  } else if(pkgType === '2') {
    url = buildOnlinePkgReferrer()
  }
  console.log('offlineUrl:', url)

  function onBtnClick(redirect) {

    if (isGoogleAdLink()) {
      const campaign = urlParams.campaign
      const adgroup = urlParams.adgroup
      const creative = urlParams.creative
      const gbraid = urlParams.gbraid
      const wbraid = urlParams.wbraid
      const url = 'https://app.adjust.com/' + adjustTracker + '?engagement_type=fallback_click&campaign=' + campaign + '&external_click_id=' + gclid +
              '&adgroup=' + adgroup + '&creative=' + creative + '&gbraid=' + gbraid + '&wbraid=' + wbraid + '&redirect=' + redirect
      console.log(url)
      window.location.href = url;
    } else if (isFacebookAdLink()) {
      const campaignName = urlParams.p1
      const campaignId = urlParams.p2
      const adsetName = urlParams.p3
      const adsetId = urlParams.p4
      const adName = urlParams.p5
      const adId = urlParams.p6
      const fbclid = urlParams.fbclid
      const fbpid = urlParams.fbpid
      const url = 'https://app.adjust.com/' + adjustTracker + '?engagement_type=fallback_click&campaign=' + campaignName + '%20%28' + campaignId
              + '%29&adgroup=' + adsetName + '%20%28' + adsetId + '%29&creative=' + adName + '%20%28' + adId + '%29&fbclid='
              + fbclid + '&fbpid=' + fbpid + '&redirect=' + redirect
      window.location.href = url;
    } else {
      window.location.href = 'https://app.adjust.com/' + adjustTracker + '?engagement_type=fallback_click&redirect=' + redirect;
    }
  }

  function isGoogleAdLink() {
    return gclid
  }

  function isFacebookAdLink() {
    return window.location.href.includes('fbclid');
  }

  function sendGtagEvent(action) {
    console.log('sendGtagEvent', action)
    const category = 'button';
    const label = 'myButton';
    const value = 1;

    gtag('event', action, {
      'event_category': category,
      'event_label': label,
      'value': value
    });
  }

  function download(eventName) {
    sendGtagEvent(eventName)
    reportLog(Date.now() - startTime);
    var encodedUrl = encodeURIComponent(url);
    onBtnClick(encodedUrl);
  }

  window.download = download;

  function readUrlParams() {
    const urlParams = new Proxy({}, {
      get: (target, name) => name in target ? target[name] : ''
    });

    const currentURL = window.location.href;
    const parsedURL = new URL(currentURL);
    const params = parsedURL.searchParams;

    for (const [param, value] of params) {
      urlParams[param] = value;
      console.log('urlParams: ', urlParams[param])
    }
    return urlParams;
  }

  function reportLog(timeCost) {
    if(reportFlag > 0) {
      return;
    }
    reportFlag = 1
    let uri = window.location.href;
    uri = uri.replace(/^https?:\/\//, '');
    console.log('uri:', uri)
    const cookies = document.cookie;
    let cookieA = `&cookie=${encodeURIComponent(cookies)}`;
    let logrpUrl = '';

    const urlP = readUrlParams()

    var uriWithoutParams = window.location.origin + window.location.pathname;
    const p0 = urlP.p0
    const p1 = urlP.p1
    const p2 = urlP.p2
    const p3 = urlP.p3
    const p4 = urlP.p4
    const p5 = urlP.p5
    const p6 = urlP.p6
    const fbclid = urlP.fbclid

    logrpUrl = 'https://tracker2.bx1.pw/webAdsTracker/report?uri=' + uriWithoutParams + '&p0=' + p0 + '&p1=' + p1 + '&p2=' + p2 + '&p3=' + p3 + '&p4=' + p4
            + '&p5=' + p5 + '&p6=' + p6 + '&fbclid=' + fbclid + '&eventId=' + eventId + cookieA + '&timecost=' + timeCost + '&channel=' + channel;
    fetch(logrpUrl,{mode:'no-cors'})
            .then(response => {
              if (!response.ok) {
                throw new Error(`HTTP error! Status: ${response.status}`);
              }
              return response.json();
            })
            .then(data => {
              console.log('reportLog', logrpUrl)
            })
            .catch(error => {
              console.log('reportLog:', logrpUrl)
            });
  }

  function hasQuestionMark(uri) {
    const regex = /\?/;
    return regex.test(uri);
  }

  function buildOnlinePkgReferrer() {
    let up = readUrlParams()
    if (isFacebookAdLink()) {
      onlinePkgUrl = onlinePkgUrl + '&referrer=fbclid%3D' + up.fbclid + '%26eventId%3D' + eventId
    } else if (isGoogleAdLink()) {
      onlinePkgUrl = onlinePkgUrl + '&referrer=fbclid%3D' + gclid + '%26eventId%3D' + eventId
    } else {
      onlinePkgUrl = onlinePkgUrl + '&referrer=eventId%3D' + eventId
    }
    return onlinePkgUrl
  }

</script>

</html>