var integrazap = new XMLHttpRequest(); var integrazap_link = document.querySelector('script[src^="https://integrazap.com.br/gadget-v.1/wapp-flutuante"]').src; var integrazap_y = integrazap_link.substr(integrazap_link.indexOf('y=') + 2); var getParamUrl = (location.search != "") ? location.search : ""; integrazap.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { var dados = JSON.parse(integrazap.response); var body = document.body; var checkUrl = dados.checkUrl.split(',').map(function(el){ return el.trim(); }); var url = window.location.pathname.split("/"); var found = url.some(function(r){ return checkUrl.indexOf(r) >= 0; }); if(found === false){ var styleElement = document.createElement('style'); styleElement.innerHTML = dados.styleForm; var divElement = document.createElement('div'); divElement.setAttribute('class', "integrazap"); divElement.innerHTML = dados.content; var scriptElement = document.createElement('script'); scriptElement.setAttribute('src', dados.script); if(dados.scriptGoogle !== ''){ var scriptGoogleAnalytics = document.createElement('script'); scriptGoogleAnalytics.setAttribute('src', dados.scriptGoogle); body.appendChild(scriptGoogleAnalytics); } if(dados.googleAnalytics !== ''){ var google_analytics = document.createElement('script'); google_analytics.innerHTML = dados.googleAnalytics; body.appendChild(google_analytics); } body.appendChild(styleElement); body.appendChild(divElement); body.appendChild(scriptElement); if(dados.interesse !== ''){ var scriptInteresse = document.createElement('script'); scriptInteresse.innerHTML = dados.interesse; scriptInteresse.innerHTML += "document.querySelector('#wappBox form textarea').value = 'Interesse: ' + myWappItem"; body.appendChild(scriptInteresse); } if(dados.codJsPersonalizado !== '' && dados.interesse === ''){ var scriptInteresse = document.createElement('script'); scriptInteresse.innerHTML = dados.codJsPersonalizado; body.appendChild(scriptInteresse); } } } }; integrazap.open("POST", "https://integrazap.com.br/gadget-v.2/load-integrazap.php", true); integrazap.setRequestHeader('Content-type','application/x-www-form-urlencoded'); integrazap.withCredentials = true; integrazap.send('y=' + JSON.stringify({site: btoa(integrazap_y), url_param: btoa(getParamUrl)}));