(function() { // console.log("aqur 停止!"); // return; var take = function() { window.AqurBaseURL = 'https://ff.aqur.com'; var item_id; window.addEventListener("chatform_initialized", (event) => { autoLaunch() if(window.location.pathname.includes("/campaign/lp/supplement/dt/hizatect/dt-5080")){ console.log("aqur off! run anchor"); const links = document.querySelectorAll('.chatformBtn'); const targetId = "#formLPSection"; const targetEl = document.querySelector(targetId); if (links.length > 0 && targetEl) { links.forEach((link) => { link.removeAttribute("target"); link.addEventListener("click", (e) => { e.preventDefault(); targetEl.scrollIntoView({ behavior: "smooth", block: "start" }); }); }); } } }) function render(template, data){ //console.log("render",template,data) return template.replace(/{{(.*?)}}/g, (match) => { return data[match.split(/{{|}}/).filter(Boolean)[0].trim()] }) } function activateChatformWidget(){ if(!chatform_initialized){ console.log("Aqur is not ready") return } const w = document.querySelector('.chatform_widget'); w.classList.toggle("close"); if(w.classList.contains("close")){ document.body.classList.remove("chat_open"); }else{ document.body.classList.add("chat_open"); } } const url = window.location.href; var projectId; switch (true) { case url.includes("/metapre/"): projectId="meta" break; case url.includes("/meta/"): projectId="nmeta" break; case url.includes("/ws/"): projectId="ws" break; case url.includes("/hizatect/"): projectId="ht" break; case url.includes("/cp/"): projectId="cp" break; case url.includes("/collagen/"): projectId="cld" break; default: projectId = "meta"; break; } console.log("projectId",projectId) var chatform_initialized = false //const pid = "kakunin"; const pid = projectId; const target = "production"; const mode = "release"; const device = JSON.parse("false".toLowerCase())?"mobile":"pc"; const launch = "click"; const client = "https://form.aqur.com/"; //hizatect pcは非表示 ボタンクリックでフォームへ if(projectId=="ht"&&device=="pc"){ console.log("hizatect pcは非表示 ボタンクリックでフォームへ") if(/dt-5065/.test(window.location.pathname) || /dt-5074/.test(window.location.pathname) || /dt-5080/.test(window.location.pathname) || /dt-5089/.test(window.location.pathname) || /dt-5096/.test(window.location.pathname) || /dt-5105/.test(window.location.pathname)){ var cv_btn = document.querySelectorAll(".chatformBtn") var formLPSection = document.querySelector("#formLPSection") cv_btn.forEach((item)=>{ item.addEventListener("click",()=>{ formLPSection.scrollIntoView({ behavior: "smooth", block: "start", inline: "nearest" }); }) }) return } } //cp 非表示 ボタンクリックでフォームへ if(projectId=="cp"){ if(/dt-5097/.test(window.location.pathname)){ console.log("cp 非表示 ボタンクリックでフォームへ") var cv_btn = document.querySelectorAll(".chatformBtn") var formLPSection = document.querySelector("#formLPSection") cv_btn.forEach((item)=>{ item.addEventListener("click",()=>{ formLPSection.scrollIntoView({ behavior: "smooth", block: "start", inline: "nearest" }); }) }) return } } 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', "89655a20-12be-4fbd-bcf4-94a43aeabcd9"); 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', "216.73.216.31"); REF.searchParams.append('ref', REF.href); REF.searchParams.append('path', REF.pathname); console.log("device",device) //for UI REF.searchParams.append('CLIENT_ID', 'FF'); REF.searchParams.append('BASE_URL', 'https://ff.aqur.com'); REF.searchParams.append('HEADER_LABEL', '簡単ご注文手続き'); REF.searchParams.append('HEADER_BG_COLOR', '#ed5757'); REF.searchParams.append('HEADER_LABEL_COLOR', '#fff'); REF.searchParams.append('SHOW_TIMER', 'false'); REF.searchParams.append('ICON_PATH', 'icon.png'); 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){ 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() }) } var path=window.location.pathname; //cld if(/dt-5083.html/.test(path)||/dt-5084.html/.test(path)){ var cv_btn = document.querySelectorAll(".chatformBtn") cv_btn.forEach((item)=>{ item_id = "505251681100"; item.dataset.filterid=item_id; }) } //ht if(/dt-5080.html/.test(path)){ var cv_btn = document.querySelectorAll(".chatformBtn") cv_btn.forEach((item)=>{ item_id = "505352511214"; item.dataset.filterid=item_id; }) } //cp オプト if(/op-5008.html/.test(path)){ var cv_btn = document.querySelectorAll(".chatformBtn") cv_btn.forEach((item)=>{ item_id = "505352511206"; item.dataset.filterid=item_id; }) } //meta オプト if(/op-5004.html/.test(path)){ var bc = document.querySelectorAll(".btn_h.chatformBtn") bc.forEach((item)=>{ if(item){ item_id = "505050721201"; item.dataset.filterid=item_id; } }) } if(/op-5021.html/.test(path)){ var bc = document.querySelectorAll(".chatformBtn") bc.forEach((item)=>{ if(item){ item_id = "505091574009"; item.dataset.filterid=item_id; } }) } if(/op-/.test(path)==false){ const as = document.querySelectorAll('*[href="#formLPSection"]'); as.forEach((a)=>{ a.removeAttribute("href") }) } //ht if(/dt-5065/.test(path)){ var btn1 = document.querySelectorAll(".chatformBtn") btn1.forEach((el)=>{ item_id = "505391514000"; el.dataset.filterid=item_id; }) } //定期 if(/dt-5068/.test(path)){ var btn1 = document.querySelectorAll(".chatformBtn") btn1.forEach((el)=>{ item_id = "505391524000"; el.dataset.filterid=item_id }) } //ws if(/dt-5030/.test(path)|| /dt-5046/.test(path)){ var btn1 = document.querySelectorAll(".chatformBtn") btn1.forEach((el)=>{ item_id = "505251564001"; el.dataset.filterid=item_id; }) } //nmeta if(/dt-5063/.test(path)|| /st-5255/.test(path)){ var btn1 = document.querySelectorAll(".chatformBtn") btn1.forEach((el)=>{ item_id = "505091574009"; el.dataset.filterid=item_id }) } //meta if(/st-5246.html/.test(path)|| /st-5200.html/.test(path)|| /st-5209.html/.test(path)|| /st-5231.html/.test(path)|| /st-5247.html/.test(path)|| /st-5107.html/.test(path)){ var btn1 = document.querySelectorAll(".btn1,.btn2") var btn3 = document.querySelectorAll(".btn3,.btn4") btn1.forEach((el)=>{ el.dataset.filterid="505050721201" }) btn3.forEach((el)=>{ el.dataset.filterid="505050721200" }) var order_btn = document.querySelectorAll(".order_btn") order_btn.forEach((el)=>{ el.dataset.filterid="505091574006" }) } if(/st-5249.html/.test(path)){ var btn1 = document.querySelectorAll(".btn1,.btn2,.chatformBtn") btn1.forEach((el)=>{ item_id = "505050521200"; el.dataset.filterid=item_id }) } autoLaunch() document.addEventListener('click', (event) => { if (event.target && event.target.closest('.chatformBtn ') || event.target.classList.contains("chatformBtn") || event.target.id == "chatform_widget_cancelbtn" ) { activateChatformWidget() filterid = event.target.closest(".chatformBtn").dataset.filterid console.log(event.target.closest(".chatformBtn").dataset.filterid) } }); document.dispatchEvent(new CustomEvent("chatform_widget_creation_complete")); }; setTimeout(creationComplete, 250); function autoLaunch(){ //item_idがqueryに入っている場合は自動起動 metaのような1LP複数商材には未対応 let REF = new URL(window.location); let item_id_param = REF.searchParams.get('item_id') console.log("item_id",item_id_param,item_id) if(item_id_param && item_id_param==item_id){ filterid = item_id; activateChatformWidget(); } } window.addEventListener("message", (event) => { if(event.data.event == "chatform_gotoCart"){ //console.log("chatform_gotoCart") var clickOnAddToCartContentAsset = document.querySelector("#formLPSection .clickOnAddToCartContentAsset"); activateChatformWidget(); clickOnAddToCartContentAsset.click() } if (event.data.event == "loginButton") { var setSubmit = () => { document.querySelector('.clickOnAddToCartContentAsset.gotocart.btnCustom05').click() } setTimeout(setSubmit, 500); activateChatformWidget() } 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_sent"){ activateChatformWidget(); var params = event.data.params; var arr = params.project.data; var chatform = { pid:params.project.pid, sid:params.project.sid, uuId:params.project.uuId, id:arr[arr.length-1].id } localStorage.setItem('chatform', JSON.stringify(chatform)); bindForm(arr, params.project.pid) } 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_start"){ console.log(event.data.uuId) } if(event.data.event == "chatform_initialized"){ console.log("Aqur Initialized") document.getElementById("chatbotProgressBar").style.width = "100%"; var opacity = function(){ document.getElementById("chatbotProgressBar").style.opacity = "0"; }; setTimeout(opacity, 1000); chatform_initialized = true; if(launch=="auto"){ activateChatformWidget(); } window.dispatchEvent(new CustomEvent("chatform_initialized")); const iframe = document.querySelector('.chatform_widget'); var contentWindow = iframe.contentWindow; if(contentWindow){ var path=window.location.pathname; if(/dt-5068/.test(path)){ var param={ type: "chatform_shareParams", btnClass:"showTeiki" } const target = document.querySelector('.chatform_widget'); target.contentWindow.postMessage(param, "*"); } if(/op-5016/.test(path)){ var param={ type: "chatform_shareParams", btnClass:"op-5016" } const target = document.querySelector('.chatform_widget'); target.contentWindow.postMessage(param, "*"); } if(/op-5015/.test(path)){ var param={ type: "chatform_shareParams", btnClass:"op-5015" } const target = document.querySelector('.chatform_widget'); target.contentWindow.postMessage(param, "*"); } if(/op-5000/.test(path)){ var param={ type: "chatform_shareParams", btnClass:"op-5000" } const target = document.querySelector('.chatform_widget'); target.contentWindow.postMessage(param, "*"); } if(/op-5012/.test(path)){ var param={ type: "chatform_shareParams", btnClass:"op-5012" } const target = document.querySelector('.chatform_widget'); target.contentWindow.postMessage(param, "*"); } if(/st-5256/.test(path)){ var param={ type: "chatform_shareParams", btnClass:"st-5256" } const target = document.querySelector('.chatform_widget'); target.contentWindow.postMessage(param, "*"); } var shareProductList = [] var mobileCheck = document.querySelector("body").classList.contains("mobile"); if(mobileCheck){ var li = document.querySelectorAll(".orderInformation"); li.forEach((item)=>{ var value = item.querySelector("[name=orderSelect]").value var rows = item.querySelectorAll(".osb-row") var name = rows[0].querySelector("div:last-child").textContent.trim(); var imgContainer = rows[0].querySelector("div:first-child"); var src = imgContainer.querySelector("img").getAttribute('src'); var price = rows[1].querySelector("div:last-child").textContent.trim(); var quantity = rows[2].querySelector("div:last-child").textContent.trim(); var subTotal = rows[4].querySelector("div:last-child").textContent.trim(); var obj ={ value:value, label:name, price:price, quantity:quantity, subTotal:subTotal, checked:false, src:window.location.origin+src, name:"orderSelect", supplement:"", } shareProductList.push(obj) }) }else{ var li = document.querySelectorAll(".formLPCartTable >ul>li"); li.forEach((item)=>{ var orderSelect = item.querySelector("input"); var name = item.querySelector(".itemInfo .text .name"); var label = item.querySelectorAll(".itemInfo .text .label li"); var img = item.querySelector(".itemInfo figure img"); var supplement = [] label.forEach((labelItem)=>{ supplement.push(labelItem.textContent) }) var price = item.querySelector(".price dd"); var quantity = item.querySelector(".quantity dd"); var subTotal = item.querySelector(".subTotal dd"); var obj ={ value:orderSelect.value, label:name.textContent, supplement:supplement, price:price.textContent.trim(), quantity:quantity.textContent.trim(), subTotal:subTotal.textContent.trim(), checked:false, src:window.location.origin+img.getAttribute('src'), name:"orderSelect" } shareProductList.push(obj) }) } contentWindow.postMessage( { type:"shareProductList", data:shareProductList }, "*"); } } },false) } setTimeout(take, 0); function selectProduct(d){ const ProductList = d.find((v) => v.type === "ProductList"); let selectedItem = ProductList.options.find((v) => v.checked == true); if(selectedItem){ var valueId = selectedItem.value; //var valueId = "505050721200" var value = "[value='"+valueId+"']" const ProductListInput = document.querySelector('input[name="orderSelect"]'+value); ProductListInput.checked=true; ProductListInput.dispatchEvent(new Event('change')); } } function bindForm(d, projectId){ //console.log(d) selectProduct(d) bindText(d, "#dwfrm_formlp_profile_customer_lastname", "dwfrm_formlp_profile_customer_lastname") bindText(d, "#dwfrm_formlp_profile_customer_firstname", "dwfrm_formlp_profile_customer_firstname") bindText(d, "#dwfrm_formlp_profile_custom_txLastNameKana", "dwfrm_formlp_profile_custom_txLastNameKana") bindText(d, "#dwfrm_formlp_profile_custom_txFirstNameKana", "dwfrm_formlp_profile_custom_txFirstNameKana") bindText(d, "#dwfrm_formlp_profile_customer_phone", "dwfrm_formlp_profile_customer_phone") bindText(d, "#dwfrm_formlp_profile_address_postal", "dwfrm_formlp_profile_address_postal") bindSelect(d, '#dwfrm_formlp_profile_address_states_state', "dwfrm_formlp_profile_address_states_state") bindText(d, "#dwfrm_formlp_profile_address_city", "dwfrm_formlp_profile_address_city") bindText(d, "#dwfrm_formlp_profile_address_address1", "dwfrm_formlp_profile_address_address1") bindText(d, "#dwfrm_formlp_profile_address_address2", "dwfrm_formlp_profile_address_address2") bindText(d, "#dwfrm_formlp_profile_customer_email", "dwfrm_formlp_profile_customer_email") bindText(d, "#dwfrm_formlp_profile_customer_emailconfirm", "dwfrm_formlp_profile_customer_email") bindText(d, "[id^='dwfrm_formlp_profile_login_password_']", "dwfrm_formlp_profile_login_password") bindText(d, "[id^='dwfrm_formlp_profile_login_passwordconfirm_']", "dwfrm_formlp_profile_login_password") bindSelect(d, 'select[name="dwfrm_formlp_profile_customer_bml_year"]', "dwfrm_formlp_profile_customer_bml_year") bindSelect(d, 'select[name="dwfrm_formlp_profile_customer_bml_month"]', "dwfrm_formlp_profile_customer_bml_month") bindSelect(d, 'select[name="dwfrm_formlp_profile_customer_bml_day"]', "dwfrm_formlp_profile_customer_bml_day") bindRadio(d, 'input[name="dwfrm_formlp_profile_customer_gender"]', "dwfrm_formlp_profile_customer_gender") bindRadio(d, 'input[name="dwfrm_billing_paymentMethods_selectedPaymentMethodID"]', "dwfrm_billing_paymentMethods_selectedPaymentMethodID") const ccElm1 = document.querySelector("input#veritrans4gCardNumber"); const ccElm2 = document.querySelector("#veritrans-4g-card-number"); if(ccElm1){ bindText(d, "input#veritrans4gCardNumber", "dwfrm_billing_paymentMethods_creditCard_number"); }else if(ccElm2){ bindText(d, "input#veritrans-4g-card-number", "dwfrm_billing_paymentMethods_creditCard_number"); } bindSelect(d, 'select[name="dwfrm_billing_paymentMethods_creditCard_year"]', "dwfrm_billing_paymentMethods_creditCard_year") bindSelect(d, 'select[name="dwfrm_billing_paymentMethods_creditCard_month"]', "dwfrm_billing_paymentMethods_creditCard_month") bindText(d, '#dwfrm_billing_paymentMethods_creditCard_owner', "CardHolderName") bindText(d, "#veritrans-4g-security-code", "dwfrm_billing_paymentMethods_creditCard_cvn") // if(projectId == "cp") { // bindText(d, "#veritrans-4g-card-number", "dwfrm_billing_paymentMethods_creditCard_number") // bindSelect(d, 'select[name="dwfrm_billing_paymentMethods_creditCard_year"]', "dwfrm_billing_paymentMethods_creditCard_year") // bindSelect(d, 'select[name="dwfrm_billing_paymentMethods_creditCard_month"]', "dwfrm_billing_paymentMethods_creditCard_month") // bindText(d, '#dwfrm_billing_paymentMethods_creditCard_owner', "CardHolderName") // bindText(d, "#veritrans-4g-security-code", "dwfrm_billing_paymentMethods_creditCard_cvn") // } else { // bindText(d, "#dwfrm_billing_paymentMethods_creditCard_number", "dwfrm_billing_paymentMethods_creditCard_number") // bindSelect(d, 'select[name="dwfrm_billing_paymentMethods_creditCard_year"]', "dwfrm_billing_paymentMethods_creditCard_year") // bindSelect(d, 'select[name="dwfrm_billing_paymentMethods_creditCard_month"]', "dwfrm_billing_paymentMethods_creditCard_month") // bindText(d, "#dwfrm_billing_paymentMethods_creditCard_cvn", "dwfrm_billing_paymentMethods_creditCard_cvn") // } /*const emailPermission = d.find((v) => v.itemName === "txEmailContactPermission2"); let per = emailPermission.options.find((v) => v.checked == true); const permissionInput = document.querySelector('input[name="txEmailContactPermission2"]'); if(per.value==0){ permissionInput.checked = false }else{ permissionInput.checked = true }*/ const permissionInput = document.querySelector('input[name="txEmailContactPermission2"]'); permissionInput.checked = true var agreement = 'input[name="dwfrm_formlp_checkembershipagreement"]'; const agreementEl = document.querySelector(agreement); agreementEl.checked=true; agreementEl.dispatchEvent(new Event('change')); var policy = 'input[name="dwfrm_formlp_ckeckprivacypolicy"]'; const policyEl = document.querySelector(policy); policyEl.checked=true; policyEl.dispatchEvent(new Event('change')); var submit = 'button[name="dwfrm_formlp_confirmation"]'; const submitEl = document.querySelector(submit); let count=0 function myCallback(a, b) { submitEl.click() count++ if(count>=3){ clearInterval(intervalID); } } const intervalID = setInterval(myCallback, 800); document.body.classList.remove("chat_open"); } function bindText(d,t,n){ //console.log(t) const el = document.querySelector(t); if(el){ el.value = findValue(d,n); el.dispatchEvent(new Event('change')); } } function bindText2(d, selector, keyName) { const inputElement = document.querySelector(selector); if (!inputElement) return; const value = findValue(d, keyName); if (typeof value !== 'string') return; const nativeSetter = Object.getOwnPropertyDescriptor(inputElement.__proto__, 'value')?.set; if (nativeSetter) { nativeSetter.call(inputElement, value); } else { inputElement.value = value; } // Dispatch events inputElement.dispatchEvent(new Event('input', { bubbles: true, composed: true })); inputElement.dispatchEvent(new Event('change', { bubbles: true, composed: true })); inputElement.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', code: 'Enter', bubbles: true, cancelable: true })); inputElement.dispatchEvent(new KeyboardEvent('keyup', { key: 'Enter', code: 'Enter', bubbles: true, cancelable: true })); inputElement.dispatchEvent(new FocusEvent('blur', { bubbles: true, composed: true })); } function bindSelect(d,t,n){ //console.log(t) bindText(d,t,n) } function bindRadio(d,t,n){ //console.log(t) var value = findOption(d,n); var str = t +"[value='"+value+"']" const el = document.querySelector(str); if(el){ el.click() } } function bindCheckbox(d,t,n){ //console.log(t) var values = findOptions(d,n); values.forEach(function(v) { var str = t +"[value='"+v+"']" const el = document.querySelector(str); if(el){ el.checked=true el.dispatchEvent(new Event('change')); } }) } //radio return single value function findValue(d,n){ //console.log(d,n) let value="Undefind"; rtn = value; for(var i=0; i < d.length; i++){ var item = d[i]; if(item.values){ item.values.forEach(function(v) { //console.log(v.name, n) var reg = new RegExp(n) if(reg.test(v.name)){ //console.log(n, v.name, reg.test(v.name)) rtn = v.value } }) } } //console.log(n,rtn) return rtn } //radio return single value function findOption(d,n){ let value="Undefind"; rtn = value; for(var i=0; i < d.length; i++){ var item = d[i]; if(item.options){ item.options.forEach(function(v) { var reg = new RegExp(n) if(reg.test(v.name) && v.checked){ rtn = v.value } }) } } return rtn } //checkbox return array function findOptions(d,n){ rtn = []; for(var i=0; i < d.length; i++){ var item = d[i]; if(item.options){ item.options.forEach(function(v) { var reg = new RegExp(n) if(reg.test(v.name) && v.checked){ rtn.push(v.value) } }) } } return rtn } }())