1function fill_hidden(default_campaign, redirect = '/obrigado'){ 2 3 var queryString = window.location.search; 4 5 // Check if the query string contains UTM variables 6 if (queryString.includes('utm_')) { 7 // Split the query string into an array of key-value pairs 8 var queryParams = queryString.substring(1).split('&'); 9 10 // Loop through the key-value pairs and set the UTM variables in sessionStorage 11 for (var i = 0; i < queryParams.length; i++) { 12 var keyValue = queryParams[i].split('='); 13 if (keyValue[0].startsWith('utm_')) { 14 sessionStorage.setItem('s_' + keyValue[0], keyValue[1]); 15 } 16 } 17 } 18 19 20 21 22 23 24 function parrudo(fazProspeccao = '', vendePara = '') { 25 if (default_campaign === "parceiros-site") { 26 qualidade = 'Parceiro'; 27 obrigado = redirect; 28 return [qualidade, obrigado]; 29 } else { 30 var qualidade = ''; 31 var obrigado = ''; 32 if (fazProspeccao === '0' && vendePara === '1') { 33 // faz prospecção e vende para b2b 34 qualidade = 'A'; 35 obrigado = '/submetido'; 36 } else if (fazProspeccao === '1' && vendePara === '1') { 37 // não faz prospecção e vende para b2b 38 qualidade = 'C'; 39 obrigado = '/concluido' 40 } else if (fazProspeccao === '2' && vendePara === '1') { 41 // não sabe o que é prospecção e vende para b2b 42 qualidade = 'C'; 43 obrigado = '/concluido' 44 } else if (fazProspeccao === '0' && vendePara === '2') { 45 // faz prospecção e vende para b2b e b2c 46 qualidade = 'B'; 47 obrigado = '/parabens' 48 } else if (fazProspeccao === '1' && vendePara === '2') { 49 // não faz prospecção e vende para b2b e b2c 50 qualidade = 'C'; 51 obrigado = '/concluido' 52 } else if (fazProspeccao === '2' && vendePara === '2') { 53 // não sabe o que é prospecção e vende para b2b e b2c 54 qualidade = 'C'; 55 obrigado = '/concluido' 56 } else if (fazProspeccao === '0' && vendePara === '0') { 57 // faz prospecção e vende b2c 58 qualidade = 'D'; 59 obrigado = '/obrigadoo' 60 } else if (fazProspeccao === '1' && vendePara === '0') { 61 // não faz prospecção e vende para b2c 62 qualidade = 'D'; 63 obrigado = '/obrigadoo' 64 } else if (fazProspeccao === '2' && vendePara === '0') { 65 // não sabe o que é prospecção e vende para b2c 66 qualidade = 'D'; 67 obrigado = '/obrigadoo' 68 } else { 69 obrigado = redirect; 70 } 71 return [qualidade, obrigado]; 72 } 73 } 74 75 var campaign = document.createElement("input"); 76 campaign.setAttribute("name", "campaign"); 77 campaign.setAttribute("class", "page_parameter"); 78 campaign.setAttribute("type", "hidden"); 79 campaign.setAttribute("value", ""); 80 81 var utm_source = document.createElement("input"); 82 utm_source.setAttribute("name", "utm_source"); 83 utm_source.setAttribute("class", "utm_parameter"); 84 utm_source.setAttribute("type", "hidden"); 85 utm_source.setAttribute("value", ""); 86 87 var utm_medium = document.createElement("input"); 88 utm_medium.setAttribute("name", "utm_medium"); 89 utm_medium.setAttribute("class", "utm_parameter"); 90 utm_medium.setAttribute("type", "hidden"); 91 utm_medium.setAttribute("value", ""); 92 93 var utm_campaign = document.createElement("input"); 94 utm_campaign.setAttribute("name", "utm_campaign"); 95 utm_campaign.setAttribute("class", "utm_parameter"); 96 utm_campaign.setAttribute("type", "hidden"); 97 utm_campaign.setAttribute("value", ""); 98 99 var utm_id = document.createElement("input"); 100 utm_id.setAttribute("name", "utm_id"); 101 utm_id.setAttribute("class", "utm_parameter"); 102 utm_id.setAttribute("type", "hidden"); 103 utm_id.setAttribute("value", ""); 104 105 var utm_term = document.createElement("input"); 106 utm_term.setAttribute("name", "utm_term"); 107 utm_term.setAttribute("class", "utm_parameter"); 108 utm_term.setAttribute("type", "hidden"); 109 utm_term.setAttribute("value", ""); 110 111 var utm_content = document.createElement("input");
112 utm_content.setAttribute("name", "utm_content"); 113 utm_content.setAttribute("class", "utm_parameter"); 114 utm_content.setAttribute("type", "hidden"); 115 utm_content.setAttribute("value", ""); 116 117 var link = document.createElement("input"); 118 link.setAttribute("name", "link"); 119 link.setAttribute("class", "utm_parameter"); 120 link.setAttribute("type", "hidden"); 121 link.setAttribute("value", ""); 122 123 var form_fill_hidden = document.getElementsByClassName("fill_hidden"); 124 for (let i = 0; i < form_fill_hidden.length; i = i + 1) { 125 //adding redirect and post to diferent places 126 form_fill_hidden[i].action = "batatinha.io" 127 128 //adding hidden inputs 129 form_fill_hidden[i].appendChild(campaign) 130 form_fill_hidden[i].appendChild(utm_source) 131 form_fill_hidden[i].appendChild(utm_medium) 132 form_fill_hidden[i].appendChild(utm_campaign) 133 form_fill_hidden[i].appendChild(utm_id) 134 form_fill_hidden[i].appendChild(utm_term) 135 form_fill_hidden[i].appendChild(utm_content) 136 form_fill_hidden[i].appendChild(link) 137 } 138 139 140 function getParameterByName(name) { 141 name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); 142 var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), 143 results = regex.exec(location.search); 144 return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); 145 } 146 147 var campaign_final = ''; 148 (function () { 149 'use strict'; 150 var campaign = getParameterByName('campaign'); 151 var fields = document.querySelectorAll('.page_parameter'); 152 153 if (campaign !== '') { 154 for (let i = 0; i < fields.length; i = i + 1) { 155 fields[i].value = campaign; 156 campaign_final = campaign; 157 } 158 } else { 159 for (let i = 0; i < fields.length; i = i + 1) { 160 fields[i].value = default_campaign; 161 campaign_final = default_campaign; 162 } 163 } 164 165 // var dict_utm = { 166 // utm_source: getParameterByName('utm_source'), 167 // utm_medium: getParameterByName('utm_medium'), 168 // utm_campaign: getParameterByName('utm_campaign'), 169 //utm_id: getParameterByName('utm_id'), 170 //utm_term: getParameterByName('utm_term'), 171 //utm_content: getParameterByName('utm_content'), 172 //link: document.URL 173 //}; 174 var dict_utm = { 175 utm_source: getParameterByName('utm_source') || sessionStorage.getItem('s_utm_source'), 176 utm_medium: getParameterByName('utm_medium') || sessionStorage.getItem('s_utm_medium'), 177 utm_campaign: getParameterByName('utm_campaign') || sessionStorage.getItem('s_utm_campaign'), 178 utm_id: getParameterByName('utm_id') || sessionStorage.getItem('s_utm_id'), 179 utm_term: getParameterByName('utm_term') || sessionStorage.getItem('s_utm_term'), 180 utm_content: getParameterByName('utm_content') || sessionStorage.getItem('s_utm_content'), 181 link: document.URL 182 }; 183 184 var fields = document.querySelectorAll('.utm_parameter'); 185 for (let i = 0; i < fields.length; i = i + 1) { 186 fields[i].value = dict_utm[fields[i].name]; 187 } 188 189 sessionStorage.setItem("s_campaign", campaign_final); 190 //sessionStorage.setItem("s_utm_source", dict_utm["utm_source"]); 191 //sessionStorage.setItem("s_utm_medium", dict_utm["utm_medium"]); 192 //sessionStorage.setItem("s_utm_campaign", dict_utm["utm_campaign"]); 193 //sessionStorage.setItem("s_utm_id", dict_utm["utm_id"]); 194 //sessionStorage.setItem("s_utm_term", dict_utm["utm_term"]); 195 //sessionStorage.setItem("s_utm_content", dict_utm["utm_content"]); 196 })(); 197 198 199 200 // var uri = window.location.toString(); 201 // if (uri.indexOf("?") > 0) { 202 // var clean_uri = uri.substring(0, uri.indexOf("?")); 203 // window.history.replaceState({}, document.title, clean_uri); 204 // } 205 206 //serialize json to form-urlencode to bypass no-cors-problem 207 function serialize(obj) { 208 var str = []; 209 for(var p in obj) 210 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p])); 211 return str.join("&"); 212 } 213 214 215 window.addEventListener('submit', function(event){ 216 217 event.preventDefault() 218 const telefone = document.getElementById('telefone'); 219 const valorAnterior = telefone.value; 220 221 var aa = telefone.value; 222 var formated_phone = aa.replace("(","").replaceAll(")","").replaceAll(" ","").replaceAll("+","").replaceAll("-",""); 223 formated_phone = formated_phone.length > 11 ? formated_phone.slice(2) : formated_phone; 224 225 telefone.value = formated_phone; 226 setTimeout(function() { 227 telefone.value = valorAnterior; 228 }, 0); 229 230 // console.log("N Formatado:" + formated_phone); 231 // console.log("Novo Telefone: " + novoTelefone); 232 // console.log("Enviando: " + telefone.value); 233 234 var fazProspeccao = document.getElementById('select-faz-prospecao'); 235 var vendePara = document.getElementById('vende-para'); 236 237 if (!document.getElementById('select-faz-prospecao')) { 238 fazProspeccao = ""; 239 vendePara = ""; 240 } 241 242 const jason_killer = {}; 243 for (let element of event.submitter.form.elements) { 244 if (element.value != "submit"){ 245 jason_killer[element.name] = element.value; 246 } 247 } 248 249 jason_killer['extra_fields[tipo-de-obrigado]'] = parrudo(fazProspeccao.value, vendePara.value)[0]; 250 jason_killer['extra_fields[pagina-de-captura]'] = campaign_final; 251 252 fetch('https://integracoes.speedio.com.br/webhook/efacc0c9-fe7d-41b2-830d-627338c60c91', { 253 // fetch('https://integracoes.speedio.com.br/webhook/fe61c3469ed6b25b34c671288245a', { 254 body: serialize(jason_killer), 255 mode: "no-cors", 256 headers: { 257 'Accept': 'application/json', 258 'content-type': 'application/x-www-form-urlencoded' 259 }, 260 method: "post", 261 }).then(function(){ 262 263 if (fazProspeccao === null) { 264 redirect 265 } else { 266 redirect = parrudo(fazProspeccao.value, vendePara.value)[1]; 267 } 268 window.location.href = redirect; 269 }).catch(error => {console.log(error)}); 270 271 }); 272 273}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.