const SETTINGS = {"id_settings":1,"active":1,"title":"Platimyr - Influencers","logo_white":"https://static.influmer.com/influmer/groups/_xqu5mqa2h.png","logo_dark":"https://static.influmer.com/influmer/groups/_qb7oc8jtm.png","timezone":"Europe/Madrid","enable_taxes":1,"tax_rate":21,"retention_rate":15,"taxes_included":1,"brand_invoice_code":"LOCAL","allowed_payment_methods":"","brand_payment_code":"LOCAL","invoice_method":"influencer-request","billing_request_emails":"","invoice_name":"","invoice_vat_number":"","invoice_address_1":"","invoice_address_2":"","invoice_postcode":"","invoice_city":"","invoice_state":"","invoice_country":"","invoice_phone":"","server":"https://plastimyr.influmer.com","slug":"influmer","static_server":"https://static.influmer.com","integration":"woocommerce","default_group":"50rlAZy1NiVVkVLKDioWw","db_version":"22.02.22","app_version":"21.07.28"}; function influmer(i,n,f,l,u,m,e,r){ console.log('[influmer] '+i); let xhr = new XMLHttpRequest(); switch (i) { case 'pageview': xhr.onreadystatechange = function() {}; xhr.open('GET', SETTINGS.server + '/api/v1/script/pageview?href=' + encodeURIComponent(window.location.href)); xhr.responseType = 'application/json'; xhr.processData = false; xhr.contentType = false; xhr.onload = function() { if (xhr.status == 200) { influmer('set-cookie','INFLUMERHASH',JSON.parse(xhr.response).INFLUMERHASH,7); } }; xhr.onerror = function() { if (xhr.status === 0) { console.error(xhr); } }; xhr.crossDomain = true; xhr.withCredentials = true; xhr.send(); return null; break; case 'purchase': xhr.onreadystatechange = function() {}; xhr.open('GET', SETTINGS.server + '/api/v1/script/purchase?order_id=' + n); xhr.responseType = 'application/json'; xhr.processData = false; xhr.contentType = false; xhr.onload = function() { if (xhr.status == 200) { } }; xhr.onerror = function() { if (xhr.status === 0) { console.error(xhr); } }; xhr.crossDomain = true; xhr.withCredentials = true; xhr.send(); return null; break; case 'set-cookie': var expires = ""; if (l) { var date = new Date(); date.setTime(date.getTime() + (l*24*60*60*1000)); expires = "; expires=" + date.toUTCString(); } let domainArray = new URL(location.href).hostname.split('.') let domain = domainArray.slice(0).slice(-(domainArray.length === 4 ? 3 : 2)).join('.') console.log('domai: '+domain); document.cookie = n + "=" + (f || "") + expires + "; domain=." + domain + "; path=/"; return null; break; case 'get-cookie': var nameEQ = n + "="; 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,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; break; default: } } influmer('pageview'); // Check attribution expiration // // if has affiliation creation we need to check if has expired, if doesn't have // affiliation creation we check if has affiliation id and we start the // creation now, to prevent errors