(function() { var take = function() { //DDP const BASE_URL = "https://pr.aqur.com"; const fetchOptions = { method: "POST", headers: { "Content-Type": "application/json" } }; const chatform=localStorage.getItem("chatform"); const href = window.location.href; if(chatform && href.includes('/product-buy-form') && href.includes('/post')){ console.log("confirm page") var ConfirmExec=()=>{ var ConfirmBtnInterval = setInterval(function () { const ConfirmBtn = document.querySelector('input[name="keep_submit_x"]') if(ConfirmBtn){ clearInterval(ConfirmBtnInterval); ConfirmBtn.click() //ScrollFormtoSubmit('input[name="keep_submit_x"]') } }, 100); } ConfirmExec() } if(chatform && href.includes('/product-buy-form') && href.includes('/complete')){ var TrackingExec=()=>{ var CompleteTextInterval = setInterval(function () { const CompleteText = document.querySelector('input[name="keep_submit_x"]') async function track(trackingData) { await fetch(`${BASE_URL}/track`, { ...fetchOptions, body: trackingData }); localStorage.removeItem("chatform"); let chatformData = JSON.parse(chatform); const response2 = await fetch(`${BASE_URL}/pdi/${chatformData.uuId}`); const data2 = await response2.json(); data2.data.Completed = true; data2.data.status = "Completed"; await fetch(`${BASE_URL}/pdi/set`, { ...fetchOptions, body: JSON.stringify(data2.data) }); } track(chatform) if(CompleteText){ clearInterval(CompleteTextInterval); } }, 100); } TrackingExec() } } setTimeout(take, 0); }())