(function() { var take = function() { var vframe; window.addEventListener("chatform_initialized", (event) => { const wvLoading = document.querySelector('.wvLoading'); if(wvLoading){ wvLoading.style.display="none"; } const botLoadingV2 = document.querySelector('.botLoadingV2'); if(botLoadingV2){ botLoadingV2.style.display="none"; } //window.location.href.includes("_qlv") if ( window.location.href.includes("_sqlv")) { console.log("auto launch") const normalElement = document.querySelector('.aqur_normal'); const upsellElement = document.querySelector('.aqur_upsell'); // 見つかった要素に基づいて btnClass を更新 if (normalElement) { btnClass = 'aqur_normal'; } else if (upsellElement) { btnClass = 'aqur_upsell'; } //console.log(btnClass) const target = document.querySelector('.chatform_widget'); var param={ type: "chatform_shareParams", btnClass:btnClass } target.contentWindow.postMessage(param, "*"); //console.log(param) //activateChatformWidget() activateChatformWidget() } // var launchBtn = document.createElement("img"); // launchBtn.src="https://res.cloudinary.com/dts6mbw86/image/upload/v1706838938/aqur/st/bs/btn_course_bpzuqq.png"; // launchBtn.classList.add("launchBtn"); // document.body.appendChild(launchBtn); const order_name01 = document.querySelector('#order_name01'); var isLogin = !order_name01 if(isLogin){ console.log("login") const iframe = document.querySelector('.chatform_widget'); iframe.remove(); const lpshoppingcolumn = document.querySelector('#lpshoppingcolumn, #smp-lpshoppingcolumn'); lpshoppingcolumn.style.display= "block"; lpshoppingcolumn.scrollIntoView({ behavior: "smooth", block: "start", inline: "nearest" }); localStorage.removeItem("chatform"); const launchBtn = document.querySelector('.launchBtn'); launchBtn.style.display= "none"; } }) window.addEventListener("createVframe", (event) => { console.log("createVframe") var url = new URL(window.location.href); let userChatbot = url.searchParams.get('usechatbot') if(userChatbot){ return } vframe = document.createElement("iframe"); vframe.id="vframe"; vframe.sandbox.add('allow-storage-access-by-user-activation'); vframe.sandbox.add('allow-forms'); vframe.sandbox.add('allow-top-navigation'); vframe.sandbox.add('allow-scripts'); vframe.sandbox.add('allow-same-origin'); vframe.width="1px"; vframe.height="1px"; var REF = new URL(window.location.href); REF.searchParams.append('usechatbot', "no"); vframe.src = REF; document.body.appendChild(vframe); function checkVframeLocation() { try { //do nothing const currentUrl = vframe.contentWindow.location.href; } catch (e) { console.error('Error accessing iframe content:', e); //var origin = window.location.origin; //window.location.href = origin + "/shopping/confirm.php" } } setInterval(checkVframeLocation, 1000); vframe.addEventListener("load", (e) => { //console.log(e.target.src) var insertDDP =()=>{ var script = vframe.contentWindow.document.createElement('script'); if (window.location.hostname === 'localhost') { script.src = "http://localhost:8080/client/ddp"; } else { script.src = "https://st.aqur.com/client/ddp"; } console.log("ddp inserted") vframe.contentWindow.document.head.appendChild(script); } var url = new URL(vframe.contentWindow.location.href) console.log(url.href) const target = document.querySelector('.chatform_widget'); if(target){ var param={ event: "chatform_vframeLoaded", url:url.href } target.contentWindow.postMessage(param, "*"); } switch (url.origin) { default: insertDDP() } }) let vfmode = url.searchParams.get('vfmode') if(vfmode=="debug"){ const lpshoppingcolumn = document.querySelector('#lpshoppingcolumn, #smp-lpshoppingcolumn'); if(lpshoppingcolumn){ lpshoppingcolumn.style.display= "block"; } vframe.width="100%"; vframe.height="150px" vframe.style.display= "block"; vframe.style.zIndex= 1000000; vframe.style.position= "fixed"; vframe.style.backgroundColor= "white"; vframe.style.top=0; vframe.style.boxSizing="border-box"; vframe.style.border="2px solid red"; vframe.scrollIntoView({ behavior: "smooth", block: "start", inline: "nearest" }); var param={ event: "chatform_vframe_debug" } vframe.contentWindow.postMessage(param, "*"); } }) function selectProduct(d){ const ProductList = d.find((v) => v.type === "ProductList"); let selectedItem = ProductList.options.find((v) => v.checked == true); if(selectedItem){ const ProductListInput = document.querySelector("option[value='"+selectedItem.value+"']"); ProductListInput.selected=true; ProductListInput.dispatchEvent(new Event('change')); } } window.addEventListener("chatform_initialized", (event) => { console.log("Aqur Initialized") }) //Default function render(template, data){ //console.log("render",template,data) return template.replace(/{{(.*?)}}/g, (match) => { return data[match.split(/{{|}}/).filter(Boolean)[0].trim()] }) } var savedScrollPosition; function activateChatformWidget(){ if(!chatform_initialized){ console.log("Aqur is not ready") return } const w = document.querySelector('.chatform_widget'); w.classList.toggle("close"); w.classList.toggle("normal"); if(w.classList.contains("close")){ document.body.classList.remove("chat_open"); var scroll = function() { window.scrollTo(0, parseInt(savedScrollPosition)); console.log(savedScrollPosition) } setTimeout(scroll, 0); }else{ savedScrollPosition = window.scrollY; document.body.classList.add("chat_open"); } } var chatform_initialized = false const pid = "bs_517"; const target = "production"; const mode = "release"; const device = JSON.parse("false".toLowerCase())?"mobile":"pc"; const launch = "click"; const client = "https://form.aqur.com/"; let REF = new URL(window.location); let userChatbot = REF.searchParams.get('usechatbot') if(userChatbot=="no"){ console.log("no chatbot") return } REF.searchParams.append('pid', pid); REF.searchParams.append('mode', mode); REF.searchParams.append('target', target); REF.searchParams.append('hash', "5d541307-9570-409f-8b75-5d96fccac649"); REF.searchParams.append('browser', "undefined"); REF.searchParams.append('device', device); REF.searchParams.append('os', "undefined"); REF.searchParams.append('ua', "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)"); REF.searchParams.append('ip', "3.144.23.143"); REF.searchParams.append('ref', REF.href); REF.searchParams.append('path', REF.pathname); //for UI REF.searchParams.append('CLIENT_ID', 'ST'); REF.searchParams.append('BASE_URL', 'https://socialtech-server-d095bfc2f756.herokuapp.com'); REF.searchParams.append('HEADER_LABEL', 'ご購入はこちら!'); REF.searchParams.append('HEADER_BG_COLOR', '#06c755'); REF.searchParams.append('HEADER_LABEL_COLOR', '#FDF150'); REF.searchParams.append('SHOW_TIMER', 'false'); REF.searchParams.append('ICON_PATH', 'https://res.cloudinary.com/dts6mbw86/image/upload/v1713319985/aqur/common/icon_azvikf.png'); REF.searchParams.append('useOutlineAnimation', "yes"); //pと特別シナリオのマッピング var pmaps = [ { p: "losup001_mt_cpn_lt_aqr_nb_sqlv", pid: "cu_733", sid: "2c3743a4-b39b-4ed0-92ce-eca1d681ef09" }, { p: "losup002_mt_cpn_aqr_qlv", pid: "cu_733", sid: "2fb0c1ed-d27a-47d4-80c8-ecc110652033" }, { p: "losup002_mt_cpn_aqr_sqlv", pid: "cu_733", sid: "2fb0c1ed-d27a-47d4-80c8-ecc110652033" }, { p: "losup002_mt_cpn_aqr_nb_sqlv", pid: "cu_733", sid: "2fb0c1ed-d27a-47d4-80c8-ecc110652033" }, { p: "losup002_mt_cpn_lt_aqr_nb_sqlv", pid: "cu_733", sid: "1edf5814-3da7-4dae-98b2-60a2795b9af4" }, { p: "losup002_mt_cpn_np0_lt_aqr_nb_sqlv", pid: "cu_836", sid: "70d8e565-47c8-4952-9cca-be4da16f2cd8" }, { p: "losup002_mt_cpn_mpr_aqr_nb_sqlv", pid: "cu_756", sid: "cdcf64f3-3dd7-49d5-be34-5f2f43589485" }, { p: "breclear005_980_bg_nb_aqr_sqlv", pid: "bs_211", sid: "54dca1d8-0caa-42fc-ad02-dcae4226c84d" }, { p: "breclear005_980_nh_nb_sqlv", pid: "bs_211", sid: "957a8ed4-4b6e-4529-8c0f-211e2e8e545e" }, { p: "brewash001_kwmb_cpn_nh_nb_sqlv", pid: "bs", sid: "bb76cd9b-b597-4d36-847e-5d77d7ba51f3" }, { p: "brewash001_kwmb_cpn_gbn_sqlv", pid: "bs", sid: "31501580-ab6d-405e-a7a7-689fbcd74ae6" }, { p: "breclear005_980_lt_nb_sqlv", pid: "bs", sid: "853db88e-bdcc-4ed6-80f1-15f48dd46d22" }, { p: "brewash001_kwmb_dga_cpn_v01_nb_qlv", pid: "bs", sid: "0bdd20c7-0852-425b-a95a-a55e02e2af94" }, { p: "brewash001_kwmb_dga_cpn_v02_nb_qlv", pid: "bs", sid: "b37d55ec-79c6-4d21-a4ef-7170fb01bf83" }, { p: "brewash001_kwmb_dga_cpn_v03_nb_qlv", pid: "bs", sid: "64d56c94-3d91-45f7-8ac3-1a634189a20a" }, { p: "brewash001_kwmb_dga_cpn_v04_nb_qlv", pid: "bs", sid: "88bf5ece-800c-40b8-8884-05d10d41d8b9" }, { p: "brewash001_kwmb_dga_cpn_v05_nb_qlv", pid: "bs", sid: "b9ce3cfc-a832-44d0-a076-2a21c7d71fdd" }, { p: "brewash001_kwmb_dga_cpn_v06_nb_qlv", pid: "bs", sid: "3ccf9c56-3bf3-48f5-8542-9fed842207a5" }, { p: "brewash001_kwmb_dga_cpn_nkmc_nb_qlv", pid: "bs", sid: "ee6141b0-bb7a-491e-b2a3-4b05e1c8a5cc" }, { p: "losup002_mt_cpn_y_aqr_qlv", pid: "cu", sid: "2fb0c1ed-d27a-47d4-80c8-ecc110652033" }, { p: "brewash001_kwmb_cpn_knk_nb_sqlv", pid: "bs", sid: "8e8a4860-9698-4e53-923e-4d36696ca596" }, { p: "lotion006_mt_mpr_bg_aqr_nb_sqlv", pid: "cu_906", sid: "344248ab-978b-476f-bf5e-eb2dad87f4e2" }, { p: "brewash001_kwmb_cpn_bg_nb_sqlv", pid: "bs", sid: "00adf7f4-5f54-43aa-af4d-e47f20ba8aa5" }, { p: "breclear005_mtb_bg_nb_sqlv", pid: "bs_517", sid: "643cda80-4156-4940-b4ca-034948ae101c" }, ]; let p = REF.searchParams.get('p'); if (p) { let pmap = pmaps.find(v => v.p === p); if (pmap?.sid) { //console.log('sid', pmap.sid); REF.searchParams.append('sid', pmap.sid); } } let search = REF.search.slice(1) //console.log(search) let widget = render( ''+ '', { device : device, client : client, search : (search)?"&"+search:"", } ); const body = document.body; if(body){ localStorage.removeItem("chatform"); localStorage.removeItem("chatformAmazonPay"); var filterid; const chatbotProgressBar = "
" body.insertAdjacentHTML('beforeend', chatbotProgressBar); body.classList.add(device) body.insertAdjacentHTML('beforeend', widget); const target = document.querySelector('.chatform_widget'); const observer = new MutationObserver((mutations) => { mutations.forEach((mutation) => { if(!target.classList.contains("close")){ var contentWindow = target.contentWindow; if(contentWindow){ contentWindow.postMessage("chat_open", "*"); contentWindow.postMessage( { type:"filterIdChanged", data:filterid }, "*"); } } }); }); const config = { characterData: true, attributes:true, subtree: true }; observer.observe(target, config); } let creationComplete = function(){ if(device=="pc"){ var resize=()=>{ let zoom_level = window.devicePixelRatio || window.screen.availWidth / document.documentElement.clientWidth * 100; const targets = document.querySelectorAll('body,.chatform_widget'); if(zoom_level>=3){ targets[0].classList.add("mobile") targets[0].classList.remove("pc") targets[1].classList.add("mobile") targets[1].classList.remove("pc") }else{ targets[0].classList.add("pc") targets[0].classList.remove("mobile") targets[1].classList.add("pc") targets[1].classList.remove("mobile") } } resize() window.addEventListener("resize", () => { resize() }) } document.addEventListener('click', (event) => { if (event.target && event.target.closest('.aqur_normal') || event.target.classList.contains("aqur_normal") || event.target.closest('.aqur_upsell') || event.target.classList.contains("aqur_upsell") || event.target.id == "chatform_widget_cancelbtn" ) { var btnClass="aqur_normal"; if( event.target.closest('.aqur_normal') || event.target.classList.contains("aqur_normal") ){ btnClass = "aqur_normal" } if(event.target.closest('.aqur_upsell') || event.target.classList.contains("aqur_upsell") ){ btnClass = "aqur_upsell" } if(event.target.hasAttribute('data-filterid')){ filterid = event.target.getAttribute('data-filterid') //console.log("filterid",filterid) }else{ filterid = event.target.closest("."+btnClass).getAttribute('data-filterid') //console.log("no filterid",filterid) } activateChatformWidget() const target = document.querySelector('.chatform_widget'); var param={ type: "chatform_shareParams", btnClass:btnClass } target.contentWindow.postMessage(param, "*"); } }); document.dispatchEvent(new CustomEvent("chatform_widget_creation_complete")); }; setTimeout(creationComplete, 0); window.addEventListener("message", (event) => { /* Default Actions*/ if(event.data.event == "chatform_start"){ console.log(event.data.uuId) } if(event.data.event == "chatform_close"){ activateChatformWidget(); } if(event.data.event == "chatform_evalScript"){ window.eval(event.data.script) } if(event.data.event == "chatform_insertTag"){ body.insertAdjacentHTML( "beforeend", event.data.tag ); event.data.scripts.forEach((item)=>{ eval(item.textContent)}) } if(event.data.event == "chatform_initialized"){ //console.log("1.chatform_initialized") document.getElementById("chatbotProgressBar").style.width = "100%"; var opacity = function(){ document.getElementById("chatbotProgressBar").style.opacity = "0"; }; setTimeout(opacity, 1000); chatform_initialized = true; let REF = new URL(window.location); let launch_ = REF.searchParams.get('launch') if(launch=="auto"||launch_=="auto"){ activateChatformWidget(); } window.dispatchEvent(new CustomEvent("chatform_initialized")); } if(event.data.event == "chatform_getProductList"){ //console.log("chatform_shareProduct") //getProductList() } if(event.data.event == "chatform_selectProduct"){ //console.log("chatform_selectProduct") var t = event.data.data.data; var arr = t.data; selectProduct(arr) } if(event.data.event == "chatform_vframe_bind"){ //console.log("chatform_vframe_bind",event.data) var data = event.data.project; var param={ event: "chatform_bindForm", project:data } vframe.contentWindow.postMessage(param, "*"); } if(event.data.event == "chatform_vframe_submit"){ //console.log("chatform_vframe_submit") localStorage.removeItem('chatformAmazonPay'); var data = event.data.project; var param={ event: "chatform_bindFormSubmit" } vframe.contentWindow.postMessage(param, "*"); } if(event.data.event == "chatform_bindFormConversion"){ //console.log("chatform_bindFormConversion") const target = document.querySelector('.chatform_widget'); var param={ event: "chatform_bindFormConversion", order_id:event.data.order_id, transaction_id:event.data.transaction_id } target.contentWindow.postMessage(param, "*"); } if(event.data.event == "chatform_bindFormErrorFound"){ //console.log("chatform_bindFormErrorFound") const target = document.querySelector('.chatform_widget'); var param={ event: "chatform_bindFormErrorFound", text:event.data.text } target.contentWindow.postMessage(param, "*"); } if(event.data.event == "chatform_bindFormUpcellComplete"){ //console.log("chatform_bindFormUpcellComplete",event.data) window.location.href=event.data.targetURL; } if(event.data.event == "chatform_bindClick"){ //console.log("chatform_bindClick",event.data) document.getElementById(event.data.elementId).click(); } if(event.data.event == "chatform_bindCheck"){ //console.log("chatform_bindCheck",event.data) document.getElementById(event.data.elementId).click(); } if(event.data.event == "chatform_bindSetAmazonPay"){ console.log("chatform_bindSetAmazonPay") var project = event.data.project; var arr = project.data; const id = arr.find((v)=>v.customId=="AmazonPayCV").id var chatformAmazonPay = { pid:project.pid, sid:project.sid, uuId:project.uuId, id:id } localStorage.setItem('chatformAmazonPay', JSON.stringify(chatformAmazonPay)); } if(event.data.event == "amazonButton"){ console.log("amazonButton click"); var pid = event.data.pid; if (pid=='bs') { const ProductElem = document.getElementById('product_id'); const ProductValue = '374' document.querySelector("#product_id option[value='"+ ProductValue +"']").selected = true; ProductElem.value = ProductValue; console.log(ProductValue) var setAmazonSubmit = () => { var amazonPayButton = document.getElementById('AmazonPayButtonV2_Recurring'); amazonPayButton.click(); }; setTimeout(setAmazonSubmit, 1000); activateChatformWidget(); } } if(event.data.event == "chatform_reloadPage"){ //console.log("chatform_vframe_submit") window.location.reload() } if(event.data.event == "chatform_page_transition"){ //console.log("chatform_page_transition") const target = document.querySelector('.chatform_widget'); var param={ event: "page_transition", message:event.data.message, totalProcess: event.data.totalProcess, pageIndex:event.data.pageIndex } target.contentWindow.postMessage(param, "*"); } if(event.data.event == "chatform_btn_activated"){ //console.log("chatform_btn_activated") var param={ event: "chatform_btn_activated" } const target = document.querySelector('.chatform_widget'); target.contentWindow.postMessage(param, "*"); } if(event.data.event == "chatform_redirect_url"){ console.log("chatform_redirect_url") window.location.href=event.data.redirect_url; } if(event.data.event == "chatform_rerender"){ const w = document.querySelector('.chatform_widget'); const originalWidth = getComputedStyle(w).width; function flashWidth() { w.style.width = `calc(${originalWidth} - 0.1px)`; setTimeout(() => { w.style.width = originalWidth; }, 500); } if (navigator.userAgent.indexOf('Windows') !== -1) { flashWidth(); } } //document.getElementById("amazon_v2_agree").checked="checked"; //document.getElementById("AmazonPayButtonV2_Recurring").click(); },false) } setTimeout(take, 0); }())