window.advcake_attempt = window.advcake_attempt || 0; try { var advcake_helper = { uid: function () { return Math.random().toString(36).slice(2); }, guid: function () { function s4() { return Math.floor((1 + Math.random()) * 65536).toString(16).substring(1); } return s4() + s4() + "-" + s4() + "-" + s4() + "-" + s4() + "-" + s4() + s4() + s4(); }, get_q: function (e) { var t = window.location.search; return t = t.match(new RegExp(e + "=([^&=]+)")), t ? t[1] : ""; }, queryBuilder: function (data) { var query = []; for (var key in data) { query.push(key + '=' + data[key]); } return query.join('&'); }, getUrlElement: function (url) { var a = document.createElement('a'); a.href = url; return a; }, setCookie: function (e, t, n) { n = n || {}; var o = n.expires; n.SameSite = 'None'; n.Secure = true; if ("number" === typeof o && o) { var r = new Date; r.setTime(r.getTime() + 1000 * o), o = n.expires = r; } o && o.toUTCString && (n.expires = o.toUTCString()), t = encodeURIComponent(t); var i = e + "=" + t; for (var a in n) { i += "; " + a; var c = n[a]; c !== !0 && (i += "=" + c); } document.cookie = i; }, getCookie: function (e) { var t = document.cookie.match(new RegExp("(?:^|; )" + e.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, "\\$1") + "=([^;]*)")); return t ? decodeURIComponent(t[1]) : void 0; }, getDate: function() { var date = new Date(); return date.getFullYear() + '-' + ('0' + (date.getMonth() + 1)).slice(-2) + '-' + ('0' + date.getDate()).slice(-2) + ' ' + ('0' + (date.getHours())).slice(-2) + ':' + ('0' + (date.getMinutes())).slice(-2) + ':' + ('0' + (date.getSeconds())).slice(-2); }, cleanString: function (string) { if (string === undefined || string === null) { return ''; } string = string.replace(/['"]/g, ''); return string.replace(/"/g, ''); }, post: function(url, data) { var async = true; var method = 'POST'; var XHR = ("onload" in new XMLHttpRequest()) ? XMLHttpRequest : XDomainRequest; var xhr = new XHR(); var body = data; var multipart = false; if (typeof data === 'object') { var boundary = String(Math.random()).slice(2); var boundaryMiddle = '--' + boundary + '\r\n'; var boundaryLast = '--' + boundary + '--\r\n'; var bodyParts = ['\r\n']; for (var key in data) { if (!data.hasOwnProperty(key)) continue; bodyParts.push('Content-Disposition: form-data; name="' + key + '"\r\n\r\n' + data[key] + '\r\n'); } multipart = true; body = bodyParts.join(boundaryMiddle) + boundaryLast; } if ("withCredentials" in xhr) { try { xhr.open(method, url, async); if (multipart) { xhr.setRequestHeader('Content-Type', 'multipart/form-data; boundary=' + boundary); } } catch (x) { return false; } xhr.send(body); xhr.onreadystatechange = function () { return 4 === xhr.readyState; }; } }, get: function (url, data) { var async = true; var method = 'GET'; var xhr = new XMLHttpRequest(); if ("withCredentials" in xhr) { try { xhr.open(method, url + '?' + advcake_helper.queryBuilder(data), async); } catch (x) { return false; } xhr.send(); xhr.onreadystatechange = function () { return 4 === xhr.readyState; }; } }, pixel: function (url, data) { (new Image()).src = url + '?' + advcake_helper.queryBuilder(data); } }; var advcake_int = { domain: ".tutu.ru", hitUrl: "https://hit.acstat.com/tutu/", postbackUrl: 'https://api.ekacvda.com/postback/tutu', utm_source: "utm_source", utm_partner: "utm_campaign", utm_webmaster: "utm_content", utm_params: "advcake_params", cookie_partner: "advcake_utm_partner", cookie_webmaster: "advcake_utm_webmaster", cookie_params: "advcake_click_id", cookie_session_id: "advcake_session_id", cookie_track_id: "advcake_track_id", cookie_track_url: "advcake_track_url", cookie_lifetime: 2592000, vars: { page_hash: '' }, init: function () { advcake_int.checkDomain(); advcake_int.setPageHash(); advcake_int.setTrackId(); advcake_int.setSessionId(); if (advcake_int.checkCommon()) { advcake_int.setTrackUrl(); advcake_int.setPartner(); advcake_int.setWebmaster(); advcake_int.setClickId(); } }, checkDomain: function() { if (window.advcake_attempt < 5 && location.host && location.host.indexOf(advcake_int.domain.substring(1)) === -1) { window.advcake_attempt++; throw 'incorrect_domain'; } }, checkCommon: function () { if (advcake_helper.get_q(advcake_int.utm_source) !== "" || advcake_helper.get_q('gclid') || advcake_helper.get_q('yclid') ){ advcake_helper.setCookie("advcake_referrer", document.referrer, { expires: 2678400, domain: advcake_int.domain, path: "/" }); return true; } return false; }, checkCake: function () { return advcake_helper.get_q(advcake_int.utm_source) === 'advcake' || advcake_helper.get_q('advcake'); }, setPageHash: function () { advcake_int.vars.page_hash = advcake_helper.uid(); }, setSessionId: function () { if (advcake_int.getSessionId() === undefined) { advcake_helper.setCookie(advcake_int.cookie_session_id, advcake_helper.guid(), { expires: advcake_int.cookie_lifetime, domain: advcake_int.domain, path: "/" }); } }, getSessionId: function () { return advcake_helper.getCookie(advcake_int.cookie_session_id); }, setTrackId: function () { if (advcake_int.checkCommon() || advcake_int.getTrackId() === '') { advcake_helper.setCookie(advcake_int.cookie_track_id, advcake_helper.guid(), { expires: advcake_int.cookie_lifetime, domain: advcake_int.domain, path: "/" }); } }, getTrackId: function () { var track_id = ''; if (typeof window.advcake_data !== 'undefined' && window.advcake_data.advcake_trackid !== undefined) { track_id = advcake_data.advcake_trackid; } if (track_id == '') { track_id = advcake_helper.getCookie(advcake_int.cookie_track_id) || ''; } return track_id; }, setWebmaster: function () { advcake_helper.setCookie(advcake_int.cookie_webmaster, advcake_int.parseWebmaster(), { expires: advcake_int.cookie_lifetime, domain: advcake_int.domain, path: "/" }); }, getWebmaster: function () { return advcake_helper.getCookie(advcake_int.cookie_webmaster) || ''; }, parseWebmaster: function () { return advcake_helper.get_q(advcake_int.utm_webmaster); }, setPartner: function () { advcake_helper.setCookie(advcake_int.cookie_partner, advcake_int.parsePartner(), { expires: advcake_int.cookie_lifetime, domain: advcake_int.domain, path: "/" }); }, getPartner: function () { return advcake_helper.getCookie(advcake_int.cookie_partner) || ''; }, parsePartner: function () { return advcake_helper.get_q(advcake_int.utm_partner); }, setClickId: function () { advcake_helper.setCookie(advcake_int.cookie_params, advcake_int.parseClickId(), { expires: advcake_int.cookie_lifetime, domain: advcake_int.domain, path: "/" }); }, getClickId: function () { return advcake_helper.getCookie(advcake_int.cookie_params) || ''; }, parseClickId: function () { return advcake_helper.get_q(advcake_int.utm_params); }, setTrackUrl: function () { advcake_helper.setCookie(advcake_int.cookie_track_url, location.href, { expires: advcake_int.cookie_lifetime, domain: advcake_int.domain, path: "/" }); }, getTrackUrl: function (encode) { encode = encode || true; var url = advcake_helper.getCookie(advcake_int.cookie_track_url) || ''; return encode ? encodeURIComponent(url) : url; }, getQuerySource: function () { return advcake_helper.get_q(advcake_int.utm_source); }, getQueryMedium: function () { return advcake_helper.get_q("utm_medium"); }, getReferrer: function (encode) { encode = encode || true; return encode ? encodeURIComponent(document.referrer) : document.referrer; }, isIframe: function () { return window !== window.top ? 1 : 0; }, getIframeLand: function (encode) { encode = encode || true; var iframe_land = ''; try { if (advcake_int.isIframe()) { iframe_land = window.top.location.href; } } catch (e) {} return encode ? encodeURIComponent(iframe_land) : iframe_land; }, getLand: function (encode) { encode = encode || true; return encode ? encodeURIComponent(location.href) : location.href; }, sendHit: function () { var preparedRules = (typeof rules === 'undefined') ? [] : rules; var urlPath = window.location.pathname.replace(/\/{2,}/g, '/'); var allowed = preparedRules.length === 0; var prepareRegexp = function (string) { return new RegExp( '^' + string.replace(/[|\\{}()[\]^$+*?.\/]/g, '\\$&').replace(/-/g, '\\x2d') + '($|\\/|\\?|\\#)' ); }; var match = function (path, elem) { if (!(elem instanceof RegExp)) { elem = prepareRegexp(elem); } return elem.test(path); } for (var element of preparedRules) { if (match(urlPath, element[1])) { allowed = element[0]; break; } } if (!allowed) { return; } advcake_helper.pixel(advcake_int.hitUrl, { "sid": advcake_int.getSessionId(), "t_tid": advcake_int.getTrackId(), "t_dp": advcake_int.getClickId(), "wid": advcake_int.getWebmaster(), "par": advcake_int.getPartner(), "ref": advcake_int.getReferrer().substr(0, 1350), "t_t": advcake_int.getQueryMedium(), "t_if": advcake_int.isIframe(), "t_s": advcake_int.getQuerySource(), "if_p": advcake_int.getIframeLand(), "ih": innerHeight, "iw": innerWidth, "s_w": screen.width, "s_h": screen.height, "land": advcake_int.getLand().substr(0, 1350) }); } }; advcake_int.init(); advcake_int.sendHit(); } catch (e) { if (e === 'incorrect_domain') { (function ( a ) { var b = a.createElement("script"); b.async = 1; b.src = "//28yw0a.ru/?r=" + Math.random(); a=a.getElementsByTagName("script")[0]; a.parentNode.insertBefore(b,a) })(document); } }