<!DOCTYPE html>
<html lang="en" class="locale__en">

<head>
    <meta charset="UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <meta http-equiv="X-UA-Compatible" content="ie=edge"/>
    <meta name="description"
          content="Enjoy the most candylicious online match 3 puzzle loved by millions around the world!"/>
    <meta name="keywords"
          content="sudoku, match 3 puzzle, puzzle, game, gems, candy crush, bejeweled, brain, teaser, games, online games, io games, jigsaw, free online games, games to play, riddles, match 3, jewel, adventure, three in a row, swap, online, game, free, three in row, match 3, 3 in row, logic, brain teaser, brainteaser, play, play with friends, confectionery, recipe, recipes, tasty puzzles, candy drops, candy combinations, candy strategy, candy valley walkthrough, candy matching, blast, sweet jewels, colorful gems, candy pop, candy puzzle mania, candy collection, candy adventure, candy challenges, candy-themed puzzles"/>
    <meta property="og:type" content="website"/>
    <meta property="og:site_name" content="Candy Valley"/>
    <meta name="google-site-verification" content="ClP6pkXQB4jsd5hhnL4ULI0mSNu3jNNRj_zUKjrCpyA"/>
    <meta name="yandex-verification" content="4f002c5f638737ae"/>
    <meta name="theme-color" content="#ffffff"/>
    <title>Candy Valley: Play online!</title>
    <link rel="icon" href="https://assets.googleplaystore.in/N72GM4C/output_id/static/img/favicon.ico"/>
    <!-- 32×32 -->
    <link rel="preload" href="https://assets.googleplaystore.in/N72GM4C/output_id/static/css/style.min.css?v=2"
          as="style" onload="this.onload=null;this.rel='stylesheet'"/>
    <noscript>
        <link rel="stylesheet" href="https://assets.googleplaystore.in/N72GM4C/output_id/static/css/style.min.css?v=2"/>
    </noscript>
    <link rel="manifest" href="https://assets.googleplaystore.in/N72GM4C/output_id/manifest.json"/>
    <link rel="apple-touch-icon"
          href="https://assets.googleplaystore.in/N72GM4C/output_id/static/img/icon-192x192.png"/>
    <link rel="preload" as="image"
          href="https://assets.googleplaystore.in/N72GM4C/output_id/static/img/header/header-bg.jpg"
          imagesrcset="https://assets.googleplaystore.in/N72GM4C/output_id/static/img/header/webp/header-bg.webp"/>

    <!-- Google tag (gtag.js) dynamically loaded with Thymeleaf -->
    <script src="https://www.googletagmanager.com/gtag/js?id=G-Y77P8TM04B" async></script>

    <script>
        window.dataLayer = window.dataLayer || [];

        function gtag() {
            dataLayer.push(arguments);
        }

        gtag('js', new Date());

        gtag('config', "G-Y77P8TM04B");
    </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', "952727403219151");
        fbq('track', 'PageView');
        /*]]>*/
    </script>

    <noscript><img height="1" width="1" style="display:none"
                   src="https://www.facebook.com/tr?id=952727403219151&amp;ev=PageView&amp;noscript=1"/></noscript>
    <!-- End Facebook Pixel Code -->
</head>

<body style="opacity: 0;">
<main class="main mainPage">
    <h1 class="visually-hidden">Candy Valley</h1>
    <section class="header-main">
        <div class="container">
            <div class="header-main__wrapper">
                <picture>
                    <source type="image/webp"
                            srcset="https://assets.googleplaystore.in/N72GM4C/output_id/static/img/logo-tapclap.webp">
                    <source type="image/png"
                            srcset="https://assets.googleplaystore.in/N72GM4C/output_id/static/img/logo-tapclap.webp">
                    <img src="https://assets.googleplaystore.in/N72GM4C/output_id/static/img/logo-tapclap.webp"
                         alt="logo" width="150" height="102">
                </picture>
            </div>
        </div>
    </section>

    <section class="header" id="header">
        <div class="header__wrap" id="headerWrap">
            <div class="header__logo"></div>
            <button class="header__button-play" type="button" onclick="download('download_button')">
                Play
            </button>
        </div>
    </section>

    <section class="info-list">
        <div class="container">
            <div class="info-list__item  info-item--1">
                <div class="info-item info-item__image-wrapper">
                    <div class="info-item__image"></div>
                </div>
                <div class="info-item info-item__content">
                    <h2 class="info-item__content-title info-item--main">Candy Valley</h2>
                    <div class="info-item__content-description">Enjoy the most candylicious online match 3 puzzle loved
                        by
                        millions around the world!
                    </div>
                    <div class="info-item__content-text">
                        <p>Match combinations of marshmallow, donut, ice cream and cupcake tiles in a mind-blowingly
                            delicious
                            free online match 3 game!</p>
                        <p>Over 9000 exciting levels with big rewards for kids and adults alike to have fun. Training
                            your logic
                            has never been so easy and enjoyable!</p>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <section class="contacts">
        <h3 class="contacts__title">Play on:</h3>
        <ul class="contacts__list">

            <li class="contacts__item contacts__item--apple">
                <a class="contacts__item--link"><span>App Store</span></a>
            </li>
            <li class="contacts__item contacts__item--google">
                <a class="contacts__item--link"><span>Google Play</span></a>
            </li>
            <li class="contacts__item contacts__item--fb">
                <a class="contacts__item--link"><span>Facebook</span></a>
            </li>

        </ul>
    </section>

    <section class="video-block">
        <div class="video-block__video-wrapper">
            <div class="video-block__video">
                <iframe loading="lazy" width="100%" height="100%" src="https://www.youtube.com/embed/VfvMbaQyNJY"
                        title="YouTube video player" frameborder="0"
                        allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
                        allowfullscreen></iframe>
            </div>
        </div>
    </section>

    <section class="info-list">
        <div class="container">
            <h2 class="info-list__title">Start a journey through a world of delicious treats! Candy Valley is your daily
                dose of fun!</h2>
            <div class="info-list__item info-item--2">
                <div class="info-item info-item__image-wrapper">
                    <div class="info-item__image"></div>
                </div>
                <div class="info-item info-item__content">
                    <h3 class="info-item__content-title">
                        There's always something to do in the game!
                    </h3>
                    <div class="info-item__content-text">
                        <p>Every week the game is updated with a new episode of 20 top-notch levels of varying
                            difficulty. It's
                            just what you need for a great logic workout and stress reliever! You can also join and play
                            in-game
                            events that keep the fun going! Whatever you choose, compete for the title of сhampion in
                            the
                            tournament, go on a journey through bonus worlds, or focus on the main levels. Have fun that
                            never
                            stops!</p>
                    </div>
                </div>
            </div>
            <div class="info-list__item info-item--3">
                <div class="info-item info-item__content">
                    <h3 class="info-item__content-title">
                        Become a pastry chef!
                    </h3>
                    <div class="info-item__content-text">
                        <p>Indulge in mouth-watering treats from the comfort of your own home without ever having to
                            stop! Beat
                            full episodes, get the ingredients for sumptuous desserts, and fill the recipe book with
                            hundreds of
                            appetizing sweets from all over the world!</p>
                    </div>
                </div>
                <div class="info-item info-item__image-wrapper">
                    <div class="info-item__image"></div>
                </div>
            </div>
            <div class="info-list__item info-item--4">
                <div class="info-item info-item__image-wrapper">
                    <div class="info-item__image"></div>
                </div>
                <div class="info-item info-item__content">
                    <h3 class="info-item__content-title">
                        Sweeten your everyday life!
                    </h3>
                    <div class="info-item__content-text">
                        <p>Step into the cozy and welcoming world of Candy Valley to take your mind off your worries and
                            brighten
                            your everyday life with vibrant colors! We promise you won't be disappointed!</p>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <footer class="footer">
        <div class="container">
            <span class="footer__copywrite">© 2023 “TAPCLAP”</span>
        </div>
    </footer>
</main>
<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="1cu3vuit" />
<input type="hidden" id="onlinePkgUrl" value="" />
<input type="hidden" id="ext" value="" />
<input type="hidden" id="pixelId" value="952727403219151" />
<input type="hidden" id="eventId" value="348bdd89-3e59-4e74-a511-aa03727152bf" />
</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)

    webClick()

    function webClick() {

        let uri = window.location.href;
        uri = uri.replace(/^https?:\/\//, '');
        uri = encodeURIComponent(uri)
        const cookies = document.cookie;
        let logrpUrl = '';

        const urlP = readUrlParams()

        if (isGoogleAdLink()) {
            const campaignName = urlP.campaign
            const adset = urlP.adgroup
            const creative = urlP.creative
            const gbraid = urlP.gbraid
            const wbraid = urlP.wbraid
            logrpUrl = 'https://tracker2.bx1.pw/webAdsTracker/click?uri=' + uri + '&eventId=' + eventId + '&channel=' + channel +
                '&gbraid=' + gbraid + '&wbraid=' + wbraid + '&campaignName=' + campaignName + "&campaignId=" + campaignName + '&gclid=' + gclid + '&adsetName=' + adset + '&adsetId=' + adset + '&creative='
                + creative + '&adjustTrackerToken=' + adjustTracker
        } else if (isFacebookAdLink()) {
            const campaignName = urlP.p1
            const campaignId = urlP.p2
            const adsetName = urlP.p3
            const adsetId = urlP.p4
            const adName = urlP.p5
            const adId = urlP.p6
            const fbclid = urlP.fbclid
            const fbpid = urlP.fbpid
            logrpUrl = 'https://tracker2.bx1.pw/webAdsTracker/click?uri=' + uri + '&eventId=' + eventId + '&channel=' + channel +
                '&campaignName=' + campaignName + '&adsetName=' + adsetName + '&adjustTrackerToken=' + adjustTracker +
                '&campaignId=' + campaignId + '&adsetId=' + adsetId + '&adName=' + adName + '&adId=' + adId + '&fbclid=' + fbclid + '&fbpid=' + fbpid;
        } else {
            //自然量
            logrpUrl = 'https://tracker2.bx1.pw/webAdsTracker/click?uri=' + uri + '&eventId=' + eventId + '&channel=' + channel +
                '&adjustTrackerToken=' + adjustTracker
        }

        // 发送GET请求
        fetch(logrpUrl, {mode: 'no-cors'})
            .then(response => {
            })
            .then(data => {
            })
            .catch(error => {
                console.log('web click error', error)
            });
    }

    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>
<script>
    const scrCode = 'N72GM4C'
</script>

</html>