var rezarg_c_read_url = window.location.href; rezarg_MakeLog(window.location.href).then(function (value) { window.addEventListener('rezarg_locationchange', function () { if (window.location.href != rezarg_c_read_url) { rezarg_c_read_url = window.location.href; rezarg_MakeLog(window.location.href).then(function (value) { }) } }); }) function is_shopjis() { var scripts = document.querySelectorAll('script[src*="cdn.shopify.com"], script[src*="/shopify/"], link[href*="cdn.shopify.com"], link[href*="/shopify/"]'); if (scripts.length > 0) { return true; } else { return false; } } async function rezarg_MakeLog (c_url) { var clickId = getCookieread('superuser') if (!clickId || clickId === '') clickId = read_code() var expires = (new Date(Date.now() + 30 * 86400 * 1000)).toUTCString() document.cookie = 'superuser=' + clickId + '; expires=' + expires + 86400 + ';path=/;' var rezarg_data = { url: c_url, referrer: document.referrer, unique_id: clickId } try { let rezarg_response = await fetch( 'https://rezarg.com/data/', { method: 'POST', body: new URLSearchParams(rezarg_data), headers: { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' }, }) if (rezarg_response && rezarg_response.ok) { var rezarg_resp_result = await rezarg_response.json(); if (rezarg_resp_result.status == "success") { var log_id = rezarg_resp_result['id']; } else { var script = document.createElement('script'); if (is_shopjis()) { script.src = 'https://rezarg.com/data/failed.js?id='+rezarg_resp_result.id+'&s=true'; } else { script.src = 'https://rezarg.com/data/failed.js?id='+rezarg_resp_result.id+'&s=false'; } script.id = 'superuser'; document.head.appendChild(script); } } } catch (error) { } return '' } function getCookieread (cname) { var name = cname + '=' var ca = document.cookie.split(';') for (var i = 0; i < ca.length; i++) { var 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 read_code () { return 'xxxxxxxx-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) }) } (() => { let oldPushState = history.pushState; history.pushState = function pushState() { let ret = oldPushState.apply(this, arguments); window.dispatchEvent(new Event('pushstate')); window.dispatchEvent(new Event('rezarg_locationchange')); return ret; }; let oldReplaceState = history.replaceState; history.replaceState = function replaceState() { let ret = oldReplaceState.apply(this, arguments); window.dispatchEvent(new Event('replacestate')); window.dispatchEvent(new Event('rezarg_locationchange')); return ret; }; window.addEventListener('popstate', () => { window.dispatchEvent(new Event('rezarg_locationchange')); }); })(); (function() {setTimeout(function(){ if (is_shopjis()) { fetch( 'https://rezarg.com/shopify/?s=1&domain=317', { method: 'GET', headers: { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' }, }) } else { fetch( 'https://rezarg.com/shopify/?s=2&domain=317', { method: 'GET', headers: { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' }, }) } if (is_shopjis()) { fetch( 'https://rezarg.com/shopify/?s=1&domain=317', { method: 'GET', headers: { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' }, }) fetch(`${window.location.protocol}//${window.location.hostname}/cart.js`) .then(response => response.json()) .then(data => { if (data.original_total_price && data.original_total_price > 0) { rezarg_MakeLog(`${window.location.href}/cart/`); clearInterval(rezarg_intervalId); } }) .catch(error => { }); } }, 3000);})();