var distributor = "lojasolar"; var codigoEmbed = "R3_TRg0DEwQ,"; /* Executa JS quando a div é encontrada (carregamento) */ function waitForElm(selector) { return new Promise(resolve => { if (document.querySelector(selector)) { return resolve(document.querySelector(selector)); } const observer = new MutationObserver(mutations => { if (document.querySelector(selector)) { resolve(document.querySelector(selector)); observer.disconnect(); } }); observer.observe(document.body, { childList: true, subtree: true }); }); } function criaDivStd(){ console.log('criaDivStd'); //Verifica se tem nossa div automática e cria/adiciona se não tiver (GTM ou LP) var divStdAuto = document.querySelectorAll('#standoutDivAutomatico'); if (divStdAuto.length <= 0) { var divStd = document.createElement("div"); divStd.setAttribute("id", "standoutDivAutomatico"); divStd.setAttribute("style", "margin-bottom: 20px;"); var divRefVarejo = document.querySelector("div.vtex-flex-layout-0-x-flexRow--container-produto"); if (divRefVarejo) { divRefVarejo.appendChild(divStd); } else { console.log('Referência não existe'); } } } setTimeout(function () { waitForElm("div.vtex-flex-layout-0-x-flexRow--container-produto").then(elm => criaDivStd()); waitForElm('#standoutDivAutomatico').then(elm => StandoutJSInit()); waitForElm('h1[class*=-components-3-x-productNameContainer]').then(elm => catchProductData()); }, 1000); /* These are the modifications: */ history.pushState = ( f => function pushState(){ var ret = f.apply(this, arguments); window.dispatchEvent(new Event('pushState')); window.dispatchEvent(new Event('locationchange')); return ret; })(history.pushState); history.replaceState = ( f => function replaceState(){ var ret = f.apply(this, arguments); window.dispatchEvent(new Event('replaceState')); window.dispatchEvent(new Event('locationchange')); return ret; })(history.replaceState); window.addEventListener('popstate',()=>{ window.dispatchEvent(new Event('locationchange')) }); window.addEventListener('locationchange', function(){ setTimeout(function () { waitForElm("div.vtex-flex-layout-0-x-flexRow--container-produto").then(elm => criaDivStd()); waitForElm('#standoutDivAutomatico').then(elm => StandoutJSInit()); waitForElm('h1[class*=-components-3-x-productNameContainer]').then(elm => catchProductData()); }, 1000); }); // NOTE: Descomentar em caso de chamada de JS em duplicidade (descomentar linhas: 27 a 39 e 329 a 330) function StandoutJSInit(){ setTimeout(function(){ //console.log('StandoutJSInit'); if(sessionStorage.getItem('StandoutSession') == 'true' && sessionStorage.getItem('StandoutUrl') == window.location.href){ console.log('StandoutJSInit - Chamada duplicada'); } else { console.log('StandoutJSInit - Chamada'); sessionStorage.setItem('StandoutSession', 'true'); sessionStorage.setItem('StandoutUrl', window.location.href); StandoutJS(); } }, 1000); } function StandoutJS(){ var bot=false; var botPattern = "(googlebot\/|Googlebot-Mobile|Googlebot-Image|Google favicon|Mediapartners-Google|bingbot|slurp|java|wget|curl|Commons-HttpClient|Python-urllib|libwww|httpunit|nutch|phpcrawl|msnbot|jyxobot|FAST-WebCrawler|FAST Enterprise Crawler|biglotron|teoma|convera|seekbot|gigablast|exabot|ngbot|ia_archiver|GingerCrawler|webmon |httrack|webcrawler|grub.org|UsineNouvelleCrawler|antibot|netresearchserver|speedy|fluffy|bibnum.bnf|findlink|msrbot|panscient|yacybot|AISearchBot|IOI|ips-agent|tagoobot|MJ12bot|dotbot|woriobot|yanga|buzzbot|mlbot|yandexbot|purebot|Linguee Bot|Voyager|CyberPatrol|voilabot|baiduspider|citeseerxbot|spbot|twengabot|postrank|turnitinbot|scribdbot|page2rss|sitebot|linkdex|Adidxbot|blekkobot|ezooms|dotbot|Mail.RU_Bot|discobot|heritrix|findthatfile|europarchive.org|NerdByNature.Bot|sistrix crawler|ahrefsbot|Aboundex|domaincrawler|wbsearchbot|summify|ccbot|edisterbot|seznambot|ec2linkfinder|gslfbot|aihitbot|intelium_bot|facebookexternalhit|yeti|RetrevoPageAnalyzer|lb-spider|sogou|lssbot|careerbot|wotbox|wocbot|ichiro|DuckDuckBot|lssrocketcrawler|drupact|webcompanycrawler|acoonbot|openindexspider|gnam gnam spider|web-archive-net.com.bot|backlinkcrawler|coccoc|integromedb|content crawler spider|toplistbot|seokicks-robot|it2media-domain-crawler|ip-web-crawler.com|siteexplorer.info|elisabot|proximic|changedetection|blexbot|arabot|WeSEE:Search|niki-bot|CrystalSemanticsBot|rogerbot|360Spider|psbot|InterfaxScanBot|Lipperhey SEO Service|CC Metadata Scaper|g00g1e.net|GrapeshotCrawler|urlappendbot|brainobot|fr-crawler|binlar|SimpleCrawler|Livelapbot|Twitterbot|cXensebot|smtbot|bnf.fr_bot|A6-Indexer|ADmantX|Facebot|Twitterbot|OrangeBot|memorybot|AdvBot|MegaIndex|SemanticScholarBot|ltx71|nerdybot|xovibot|BUbiNG|Qwantify|archive.org_bot|Applebot|TweetmemeBot|crawler4j|findxbot|SemrushBot|yoozBot|lipperhey|y!j-asr|Domain Re-Animator Bot|AddThis)"; var re = new RegExp(botPattern, 'i'); var userAgent = navigator.userAgent; if (re.test(userAgent)) { bot=true; } var nVer = navigator.appVersion; var nAgt = navigator.userAgent; var browserName = navigator.appName; var fullVersion = ''+parseFloat(navigator.appVersion); var majorVersion = parseInt(navigator.appVersion,10); var nameOffset,verOffset,ix; if ((verOffset=nAgt.indexOf('OPR/'))!=-1) { browserName = 'Opera'; fullVersion = nAgt.substring(verOffset+4); } else if ((verOffset=nAgt.indexOf('Opera'))!=-1) { browserName = 'Opera'; fullVersion = nAgt.substring(verOffset+6); if ((verOffset=nAgt.indexOf('Version'))!=-1) { fullVersion = nAgt.substring(verOffset+8); } } else if ((verOffset=nAgt.indexOf('MSIE'))!=-1) { browserName = 'Microsoft Internet Explorer'; fullVersion = nAgt.substring(verOffset+5); } else if ((verOffset=nAgt.indexOf('Chrome'))!=-1) { browserName = 'Chrome'; fullVersion = nAgt.substring(verOffset+7); } else if ((verOffset=nAgt.indexOf('Safari'))!=-1) { browserName = 'Safari'; fullVersion = nAgt.substring(verOffset+7); if ((verOffset=nAgt.indexOf('Version'))!=-1) { fullVersion = nAgt.substring(verOffset+8); } } else if ((verOffset=nAgt.indexOf('Firefox'))!=-1) { browserName = 'Firefox'; fullVersion = nAgt.substring(verOffset+8); } else if ( (nameOffset=nAgt.lastIndexOf(' ')+1) < (verOffset=nAgt.lastIndexOf('/')) ){ browserName = nAgt.substring(nameOffset,verOffset); fullVersion = nAgt.substring(verOffset+1); if (browserName.toLowerCase()==browserName.toUpperCase()) { browserName = navigator.appName; } } if ((ix=fullVersion.indexOf(';'))!=-1) { fullVersion=fullVersion.substring(0,ix); } if ((ix=fullVersion.indexOf(' '))!=-1) { fullVersion=fullVersion.substring(0,ix); } majorVersion = parseInt(''+fullVersion,10); if (isNaN(majorVersion)) { fullVersion = ''+parseFloat(navigator.appVersion); majorVersion = parseInt(navigator.appVersion,10); } var url = window.location.href; var urlNew = url.replace("/#/", "/"); var sku = ''; var action = 'PageView'; var browserName = browserName; var browserVersion = fullVersion; var geolocation = navigator.geolocarion; var language = navigator.language; var plataform = navigator.plataform; var retailerDomain = window.location.hostname; var monitored = 'false'; var preco = ''; var disponibilidade = ''; try { var precoRef = document.querySelectorAll('div[class*=--container-produto] span.vtex-product-price-1-x-spotPriceValue'); if(precoRef.length > 0){ preco = Number(precoRef[0].textContent.replace(/[^0-9-]+/g,""))/100; } } catch (error) { } try { var dispRef = document.querySelectorAll('.vtex-availability-notify-1-x-title') if(dispRef.length > 0){ disponibilidade = 0; } else { disponibilidade = 1; } } catch (error) { } console.log('preço ', preco); console.log(disponibilidade ? 'disponibilidade 🟢disponivel' : 'disponibilidade 🟡indisponivel'); var data = "distributor="+distributor+"&sku="+sku+"&url="+encodeURIComponent(urlNew)+"&action="+action+"&browserName="+browserName+"&browserVersion="+browserVersion+"&geolocation="+geolocation+"&language="+language+"&plataform="+plataform+"&monitored="+monitored+"&bot="+bot; var urlCatch = 'https://standout.com.br/'+distributor+'/catchtagGeralExata.php?'+data; setTimeout(function () { var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200) { var myObj = JSON.parse(this.responseText); console.log(myObj); //Isolando somente uma URL (MV) if (url.indexOf("https://www.urldoproduto?stdteste=1") >= 0) { console.log(myObj.mv); // VERIFICA SE TEM MINI VITRINE if ((!myObj.mv == "" || !myObj.mv == null) && (myObj.mv.length > 0)) { var stdMVBTSContainer = document.getElementById("std-mv-bts-container"); if (stdMVBTSContainer == null) { function getScript(url, callback) { var scriptMVStd = document.createElement('script'); scriptMVStd.type = 'text/javascript'; scriptMVStd.src = url; scriptMVStd.onload = callback; document.getElementsByTagName('head')[0].appendChild(scriptMVStd); } getScript("https://s3-sa-east-1.amazonaws.com/assets.standout.com.br/js/scripts-minivitrines.js", function () { //Adiciona CSS das MINI Vitrines stdAddCssMV("https://s3-sa-east-1.amazonaws.com/assets.standout.com.br/css/style-mv-assets.css"); // Custom CSS Botões das MINI Vitrines var MVCustomstyles = ".btn-open-special-container{max-width: 160px; z-index: 12;} .btn-open-special-container.horizontal {width: 160px; margin: 6px 0 0 6px;} .btn-open-special-container.horizontal.mobile {margin: 78px 0 0 6px;} .btn-open-special-animated {width: 36px; height: 36px; border: 3px solid rgb(31, 112, 136, .8); background: #1F7088; animation: iconPulse 0.7s ease-out 0s infinite alternate running;} @keyframes iconPulse { 0% { box-shadow: 0 0 0px #1F7088; } 50% { box-shadow: 0 0 16px #1F7088;} 100% { box-shadow: 0 0 20px #1F7088;}} .btn-audio svg g path {animation: iconPulseInner 0.7s ease-out 0s infinite alternate running;} @keyframes iconPulseInner { 0% {fill: #ffffff;} 100% {fill: #DCDCDC;}}" var styleSheet = document.createElement("style"); styleSheet.type = "text/css"; styleSheet.innerText = MVCustomstyles; document.head.appendChild(styleSheet); //Variável para guardar a referência de onde deve entrar "geralmente desktop" //Botões var refIDStdProd = document.querySelector('-----div.nomedaclasse-----'); //Mini Vitrines var refIDStdProdMV = document.querySelector('-----tag header ou logo apos body-----'); //Verifica se as referências Desktop existem, pois elas podem mudar quando estão na versão mobile if (refIDStdProd == null) { //Se vazia, faz tratamentos para versão mobile, buscando nova referência e setando "MVCustomMobile" true var refIDStdProd = document.querySelector('-----div.nomedaclasse-----'); var MVCustomMobile = true; } if (refIDStdProdMV == null) { var refIDStdProdMV = document.querySelector('-----tag header ou logo apos body-----'); } //Criando a DIV de marcação da Standout com ID para inserir os botões das mini vitrines var divSTDProductID = document.createElement('div'); divSTDProductID.id = "productStdID"; divSTDProductID.setAttribute("style", "position: relative;"); //Criando a DIV de marcação da Standout com ID para inserir os conteúdos das mini vitrines var divSTDProductIDMV = document.createElement('div'); divSTDProductIDMV.id = "productStdIDMV"; //Insere conteúdos na DIV da Standout antes da DIV de referência function insertBefore(el, referenceNode) { referenceNode.parentNode.insertBefore(el, referenceNode); } if(refIDStdProd == null || refIDStdProdMV == null) { console.log('não foi possivel inserir MVs.'); } else { insertBefore(divSTDProductID, refIDStdProd); insertBefore(divSTDProductIDMV, refIDStdProdMV); } //Adicionando o container dos botões das MINI Vitrines (Desktop ou Mobile) if (!MVCustomMobile) { var MVBTS = "
"; } else { var MVBTS = "
"; } if(document.getElementById("productStdID")) { document.getElementById("productStdID").innerHTML += MVBTS; } else { console.log('não foi possivel embedar MVs.'); } //Adicionando os botões das MINI Vitrines setTimeout(function () { for (var i = 0; i < myObj.mv.length; i++) { var stdMVSlug = myObj.mv[i].slug; if(document.getElementById("std-mv-bts-container")){ //Verifica e adiciona so botões if (myObj.mv[i].tipo == "mv-foto") { var MVBtFoto = "
Clique para ver mais informações
"; document.getElementById("std-mv-bts-container").innerHTML += MVBtFoto; } else if (myObj.mv[i].tipo == "mv-video") { var MVBtVideo = "
"; document.getElementById("std-mv-bts-container").innerHTML += MVBtVideo; } else if (myObj.mv[i].tipo == "mv-audio"){ var MVBtAudio = "
Clique para ouvir a descrição
"; document.getElementById("std-mv-bts-container").innerHTML+=MVBtAudio; } //Adiciona os conteúdos das DIVs document.getElementById("productStdIDMV").innerHTML += myObj.mv[i].div; //Imprime o conteúdo das MINI Vitrines writeStandoutMV(myObj.mv[i].tipo); //Remove botões e DIVs duplicadas se houver var divMVProductRemove = document.querySelectorAll('#productStdID'); if (divMVProductRemove.length > 1) { divMVProductRemove[1].remove(); } var btnMVRemove = document.querySelectorAll('#btn-' + stdMVSlug); if (btnMVRemove.length > 1) { btnMVRemove[1].remove(); } var divMVRemove = document.querySelectorAll('#' + stdMVSlug); if (divMVRemove.length > 1) { divMVRemove[1].remove(); } var containerMVRemove = document.querySelectorAll('#std-mv-bts-container'); if (containerMVRemove.length > 1) { containerMVRemove[1].remove(); } console.log(stdMVSlug); } else { console.log('não foi possivel adicionar os botões MVs.'); } } }, '1000'); }); } } } if (!myObj.div == "") { var divStandoutAutomatico = document.getElementById("standoutDivAutomatico"); if (divStandoutAutomatico) { divStandoutAutomatico.innerHTML = myObj.div; writeStandoutCBP(); } } } }; xmlhttp.open("GET", urlCatch, true); xmlhttp.send(); }, 1000); function writeStandoutMV(tipo) { var elem = document.getElementById("standoutDivMV-" + tipo); var w = parseInt(window.innerWidth); var h = parseInt(elem.getAttribute("h")); var hmv = parseInt(h - (h * 0.14)); //console.log('w/h/hmv:', w, h, hmv); if ( w > 768) { w = "768"; } else if ((w <= 768) && (w > 475)) { w = w-40; } else if ((w <= 475) && (w > 320)) { w = w-40; h = hmv; } else { w = w-40; } var p = ((elem.getAttribute("p") === null) ? codigoEmbed : elem.getAttribute("p")) + '/' + elem.getAttribute("x") + '/' + elem.getAttribute("y"); var c = elem.getAttribute("i"); elem.style.height = h + 'px'; elem.innerHTML = ''; } function writeStandoutCBP() { if (document.getElementById("standoutDiv") != null) { if (document.getElementById("standoutDiv").getAttribute("h") != null || document.getElementById("standoutDiv").getAttribute("h") != "undefined") { var elem = document.getElementById("standoutDiv"); var w = (elem.getAttribute("x") == "landing-page") ? '100%' : (parseInt(window.innerWidth) >= 1200) ? '1200px' : '100%'; var h = parseInt(elem.getAttribute("h")); var p = ((elem.getAttribute("p") === null) ? codigoEmbed : elem.getAttribute("p")) + '/' + elem.getAttribute("x") + '/' + elem.getAttribute("y"); var c = elem.getAttribute("i"); elem.innerHTML = ''; if (elem.getAttribute("x") == "landing-page") { //Adiciona Scrolling "No" na DIV de iframe da Standout var elemIframeNoScroll = document.getElementById("frameStandout"); elemIframeNoScroll.setAttribute("scrolling", "no"); } } } // NOTE: Descomentar em caso de chamada de JS em duplicidade //libera session para funcionamento correto do carregamento das vitrines sessionStorage.setItem('StandoutSession', ''); sessionStorage.setItem('StandoutUrl', ''); } } //MENSAGERIA if (document.getElementById('frameStandout') != null || document.getElementById('frameStandout') != 'undefined') { standoutMensageria(); function standoutMensageria() { var myMensageriaVitrine = document.getElementById('frameStandout'); var myMensageriaOrigin = '*'; //var myMensageriaHeight = document.getElementById("frameStandout").height; console.log("MSG 2.0 - JS"); // Listen for messages if (window.addEventListener) { window.addEventListener('message', onMessageReceived, false); } else { window.attachEvent('onmessage', onMessageReceived, false); } // Handle messages received from origin only function onMessageReceived(event) { //console.log("origin: "+event.origin); if ((event.origin == "https://www.drsystems.com.br") || (event.origin == "https://www.standout.com.br")) { //Se origem for as esperadas, continue... //console.log("Origem Valida"); //console.log("origin: "+event.origin); } else { //Se origem NAO for as esperadas, PARE... //console.log("Origem Invalida"); return false; } if (myMensageriaOrigin === '*') { myMensageriaOrigin = event.origin; } if (event.data.stdToken) { // console.log('eventJS', event); // console.log("originJS: "+event.origin); if (event.data.stdToken == codigoEmbed) { var myMensageriaVitrine = document.getElementById('frameStandout'); if (event.data.method == "getMensageriaAccordion") { // console.log("JS getMensageriaAccordion: "+event.data.value); // console.log(event.data.value); console.log("JS getMensageriaAccordionALTURA: " + event.data.value.alturaInicial); console.log("JS getMensageriaAccordionPOSICAO: " + event.data.value.posicaoAtual); if (parseInt(window.innerWidth) <= 475) { //console.log('mobile'); myMensageriaVitrine.setAttribute('height', parseInt(event.data.value.alturaInicial + 80)); myMensageriaVitrine.setAttribute('style', 'height:' + parseInt(event.data.value.alturaInicial + 80) + 'px;'); window.scrollTo({ 'behavior': 'smooth', 'left': 0, 'top': event.data.value.posicaoAtual + 56 }); } else { //console.log('desktop'); myMensageriaVitrine.setAttribute('height', event.data.value.alturaInicial); myMensageriaVitrine.setAttribute('style', 'height:' + event.data.value.alturaInicial + 'px;'); window.scrollTo({ 'behavior': 'smooth', 'left': 0, 'top': event.data.value.posicaoAtual + 50 }); } } if (event.data.method == "getMensageriaFirstHeight") { console.log("JS getMensageriaFirstHeight: " + event.data.value); if(event.data.value <= 20) { if(document.querySelector("#standoutDivAutomatico")){ event.data.value = document.querySelector("div#standoutDiv").getAttribute("h"); } else { event.data.value = 700; } console.log("JS getMensageriaFirstHeight reset: "+event.data.value); } myMensageriaVitrine.setAttribute('height', event.data.value); myMensageriaVitrine.setAttribute('style', 'height:' + event.data.value + 'px;'); } if (event.data.method == "getMensageriaHeight") { //console.log("getHeight: "+event.data.value); myMensageriaVitrine.setAttribute('height', event.data.value); myMensageriaVitrine.setAttribute('style', 'height:' + event.data.value + 'px;'); } if (event.data.method == "getMensageriaMobileHeight") { //console.log("getMobileHeight: "+event.data.value); myMensageriaVitrine.setAttribute('height', parseInt(event.data.value + 20)); myMensageriaVitrine.setAttribute('style', 'height:' + parseInt(event.data.value + 20) + 'px;'); //faz smooth scroll (top) var style = document.createElement('style'); style.innerHTML = 'html { scroll-behavior: smooth; }'; var ref = document.querySelector('script'); ref.parentNode.insertBefore(style, ref); document.getElementById("standoutDivAutomatico").scrollIntoView({ block: "start", behavior: "smooth" }); } if (event.data.method == "getMensageriaPromo") { console.log("JS getMensageriaPromo: " + event.data.value); myMensageriaVitrine.setAttribute('height', event.data.value); myMensageriaVitrine.setAttribute('style', 'height:' + event.data.value + 'px;'); } } } } } } function catchProductData(){ if(sessionStorage.getItem('StandoutSessionCPD') == 'true' && sessionStorage.getItem('StandoutUrlCPD') == window.location.href){ console.log('StandoutJSInitCPD - Chamada CPD duplicada'); //libera session // sessionStorage.setItem('StandoutSessionCPD', ''); // sessionStorage.setItem('StandoutUrlCPD', ''); } else { console.log('StandoutJSInitCPD - Chamada CPD'); sessionStorage.setItem('StandoutSessionCPD', 'true'); sessionStorage.setItem('StandoutUrlCPD', window.location.href); setTimeout(function () { console.log("CPD location",window.location); if (window.location.href.indexOf("busca") >= 0 || window.location.href.indexOf("search") >= 0) { //nao executa } else { console.log("--- CPD INIT ---"); var validaCPD = 1; var preco = ''; var disponibilidade = ''; var prodId = ''; var titulo = ''; var descricaoHtml = ''; var descricaoText = ''; var fullPrice = ''; var skuCPD = ''; // CATCH EAN /************************* try { var varejoEANRef = dataLayer[0]; if (varejoEANRef) { var varejoEANRefDATA = varejoEANRef.EAN; if (varejoEANRefDATA) { skuCPD = varejoEANRefDATA; } } } catch (e) { console.log('Não conseguiu pegar o SKU-CPD', e); } // CATCH EAN /************************* //CATCH PRECO BENEFICIO var precoBeneficioCPD = ''; //CATCH PRECO BENEFICIO // CATCH SELLER var SellerCPD = ''; // CATCH SELLER // IMG DEFAULT /************************* var imgDefaultPD = ''; try { var imgDefaultRef = document.querySelectorAll('.vtex-store-components-3-x-productImageTag--main') if (imgDefaultRef.length > 0) { imgDefaultPD = imgDefaultRef[0].getAttribute('src').replaceAll('&',encodeURIComponent('&')); } } catch (e) { console.log('Não conseguiu pegar o imgDefaultPD', ); } // IMG DEFAULT /************************* // IMG Outras /************************* var imgsPD = []; try { var imgOutrasRef = document.querySelectorAll(".vtex-store-components-3-x-productImageTag--main"); if (imgOutrasRef.length > 0) { imgOutrasRef.forEach(image => { imgsPD.push(image.src.replaceAll('&',encodeURIComponent('&'))) }) } else { imgsPD.push(imgDefaultPD); } } catch (e) { console.log('Não conseguiu pegar o imgsPD', ); } // IMG Outras /************************* try { var precoRef = document.querySelectorAll('div[class*=--container-produto] span.vtex-product-price-1-x-spotPriceValue'); if(precoRef.length > 0){ preco = Number(precoRef[0].textContent.replace(/[^0-9-]+/g,""))/100; } } catch (error) { } try { var dispRef = document.querySelectorAll('.vtex-availability-notify-1-x-title') if(dispRef.length > 0){ disponibilidade = 0; } else { disponibilidade = 1; } } catch (error) { } try { var varejoPIDRef = document.querySelector('.vtex-product-identifier-0-x-product-identifier__value') if (varejoPIDRef) { prodId = varejoPIDRef.textContent; } } catch (e) { console.log("PRODUCTID", e); } try { var tituloRef = document.querySelector('h1[class*=-components-3-x-productNameContainer]') if (tituloRef) { titulo = tituloRef.textContent; } } catch (e) { } try { var DescricaoVarejoRef = document.querySelectorAll('[class*=-x-productDescriptionContainer]') if(DescricaoVarejoRef.length > 0){ var elemDescricao = DescricaoVarejoRef[0]; descricaoText = elemDescricao.innerText; descricaoHtml = elemDescricao.innerHTML.trim(); } } catch (e) { } try { var fullPriceRef = document.querySelectorAll('[class*=-container-produto] [class*=-listPrice-priceSavings] .vtex-product-price-1-x-spotPriceSavings') if(fullPriceRef.length > 0){ fullPrice = Number(fullPriceRef[0].textContent.replace(/[^0-9-]+/g,""))/100; } else { var precoRef = document.querySelectorAll('div[class*=--container-produto] span.vtex-product-price-1-x-spotPriceValue'); if(precoRef.length > 0){ fullPrice = Number(precoRef[0].textContent.replace(/[^0-9-]+/g,""))/100; } } } catch (error) { } var url = window.location.href; var urlNew = url.replace("/#/", "/"); if(validaCPD){ setTimeout(function () { var dataPd = "distributor="+distributor+"&sku="+skuCPD+"&url="+encodeURIComponent(urlNew)+"&preco="+preco+"&preco_beneficio="+precoBeneficioCPD+"&product_id_distributor="+prodId+"&seller="+SellerCPD+"&disponibilidade="+disponibilidade+"&TituloPd="+titulo+"&imgDefaultPD="+imgDefaultPD+"&imgsPD="+imgsPD.toString()+"&DescricaoTextPd="+encodeURIComponent(descricaoText)+"&DescricaoHtmlPd="+encodeURIComponent(descricaoHtml)+"&preco_sem_desconto="+fullPrice; //console.log('dataPd', dataPd); var urlCatchProductData = 'https://www.standout.com.br/'+distributor+'/catchProductData.php'; var paramsCatchProductData = dataPd; var xmlhttpCPD = new XMLHttpRequest(); xmlhttpCPD.addEventListener("readystatechange", function() { if(this.readyState === 4 && this.status === 200) { if (this.responseText != '') { var myObjCPD = JSON.parse(this.responseText); console.log('STD-CPD => True', myObjCPD); } else { console.log('STD-CPD => True', skuCPD); } } }); xmlhttpCPD.open("POST", urlCatchProductData, true); xmlhttpCPD.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); xmlhttpCPD.send(paramsCatchProductData); }, 1000); } else { console.log('STD-CPD => False'); } } }, 1000); } }