(function() { var take = function() { window.AqurBaseURL = 'https://pr.aqur.com'; window.addEventListener("chatform_initialized", async (event) => { var path=window.location.pathname; const as = document.querySelectorAll('a.formlp-front-section--s0002-btn, a.formlp-front-section--s0002b1-btn'); as.forEach((a,i)=>{ a.removeAttribute("target"); console.log("reomove href!") a.classList.add("checkChk_" + i) a.setAttribute("data-link", a.href) a.removeAttribute("href"); }) createAqurBinding() const BASE_URL = "https://pr.aqur.com"; const fetchOptions = { method: "POST", headers: { "Content-Type": "application/json" } }; const chatform = localStorage.getItem("chatform"); const alertBox = document.getElementById('alert-box'); if (chatform && alertBox) { async function sendError(trackingData) { let chatformData = JSON.parse(chatform); const response2 = await fetch(`${BASE_URL}/pdi/${chatformData.uuId}`); const data2 = await response2.json(); data2.data.Completed = false; data2.data.status = "Fail"; data2.data.Message = alertBox.textContent.trim(); await fetch(`${BASE_URL}/pdi/set`, { ...fetchOptions, body: JSON.stringify(data2.data) }); } sendError(chatform); } }) function 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"); } } var chatform_initialized = false const pid = "ptg"; const target = "production"; const mode = "release"; const device = JSON.parse("false".toLowerCase()) ? "mobile" : "pc"; var 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', "a55ac2fc-fa8a-4bb6-8c30-16e1de6a1064"); 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', "18.219.47.115"); REF.searchParams.append('ref', REF.href); REF.searchParams.append('path', REF.pathname); //for UI REF.searchParams.append('CLIENT_ID', 'PR'); REF.searchParams.append('BASE_URL', 'https://pr.aqur.com'); REF.searchParams.append('HEADER_LABEL', ''); REF.searchParams.append('HEADER_BG_COLOR', '#fff'); REF.searchParams.append('HEADER_LABEL_COLOR', '#fff'); REF.searchParams.append('SHOW_TIMER', 'false'); REF.searchParams.append('ICON_PATH', 'https://res.cloudinary.com/dts6mbw86/image/upload/v1713319985/aqur/common/icon_azvikf.png'); const params = new URLSearchParams(REF.search.slice(1)); let search = REF.search.slice(1) //console.log(search) launch = params.get('launch'); 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() }) } document.addEventListener('click', (event) => { if (event.target && event.target.closest('.chatformBtn') || event.target.classList.contains("chatformBtn") || event.target.closest('.bot_open') || event.target.classList.contains("bot_open") || event.target.id == "chatform_widget_cancelbtn" ) { activateChatformWidget() } }); document.dispatchEvent(new CustomEvent("chatform_widget_creation_complete")); }; setTimeout(creationComplete, 250); window.addEventListener("message", async (event) => { 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("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")); } if (event.data.event == "amazonButton") { document.querySelector('#AmazonPayCv2Button').click() var setAmzaonSubmit = () => { document.querySelector('#AmazonPayCv2Button').click() } setTimeout(setAmzaonSubmit, 1000); activateChatformWidget() } if (event.data.event == "chatform_sent") { //console.log("chatform_sent") var project = event.data.project; var arr = project.data; var chatform = { pid: project.pid, sid: project.sid, uuId: project.uuId, customId:"conversion" } localStorage.setItem('chatform', JSON.stringify(chatform)); bindandSubmit(arr) } if(window.aqur){ window.aqur.bind(event) } }, false) } setTimeout(take, 0); function createAqurBinding() { console.log("AqurBindingCreated") //aqur bind start window.aqur = {} window.aqur.debug = false; // false -> to change, true for debug mode window.aqur.save = (key, value) => { window.aqur[key] = value; // You can access data anytime using window.aqur.XXX } window.aqur.bind = (event) => { // console.log("waq",event.data.event) if (event.data.event == "name") { window.aqur.setLastName(event.data.value.values[0].value) window.aqur.setFirstName(event.data.value.values[1].value) window.aqur.setLastNameKana(event.data.value.values[2].value) window.aqur.setFirstNameKana(event.data.value.values[3].value) window.aqur.save("LastName", event.data.value.values[0].value) window.aqur.save("FirstName", event.data.value.values[1].value) window.aqur.save("LastNameKana", event.data.value.values[2].value) window.aqur.save("FirstNameKana", event.data.value.values[3].value) } if (event.data.event == "gender") { var item = window.aqur.getCheckedOptionSA(event.data.value.options) if(item){ window.aqur.setGender(item.value) window.aqur.save("Gender", item.value) } } if (event.data.event == "birthday") { window.aqur.setBirthdayYear(Number(event.data.value.values[0].value)) window.aqur.setBirthdayMonth(Number(event.data.value.values[1].value)) window.aqur.setBirthdayDay(Number(event.data.value.values[2].value)) window.aqur.save("Year", event.data.value.values[0].value) window.aqur.save("Month", event.data.value.values[1].value) window.aqur.save("Day", event.data.value.values[2].value) } if (event.data.event == "address") { var fullZip = event.data.value.values[0].value.trim() if (fullZip.length === 7) { const formZip = document.querySelector('input#zip')?.value; if (fullZip !== formZip) { console.log("bind zip", fullZip) // alert("wroking") window.aqur.setPostalCode(event.data.value.values[0].value) window.aqur.save("PostalCode", event.data.value.values[0].value) function callLater() { window.aqur.setPref(event.data.value.values[1].value) window.aqur.setCity(event.data.value.values[2].value) window.aqur.save("Pref", event.data.value.values[1].value) window.aqur.save("City", event.data.value.values[2].value) } setTimeout(callLater, 1500); } } window.aqur.setStreet(event.data.value.values[3].value) window.aqur.setBuilding(event.data.value.values[4].value) window.aqur.save("Street", event.data.value.values[3].value.replace(/[−ー―‐-〜]/g, '-')) window.aqur.save("Building", event.data.value.values[4].value.replace(/[−ー―‐-〜]/g, '-')) } if (event.data.event == "tel") { window.aqur.setTel(event.data.value.values[0].value) window.aqur.save("Tel", event.data.value.values[0].value) } if (event.data.event == "email") { window.aqur.setEmail(event.data.value.values[0].value) window.aqur.save("Email", event.data.value.values[0].value) } if (event.data.event == "password") { window.aqur.setPassword(event.data.value.values[0].value) window.aqur.save("Password", event.data.value.values[0].value) if(window.aqur.City){ window.aqur.setCity(window.aqur.City) } } if (event.data.event == "payment") { var item = window.aqur.getCheckedOptionSA(event.data.value.options) if (item) { window.aqur.setPaymentMethodTypeKey(item.value) window.aqur.save("Payment", item.value) } } if (event.data.event == "cc") { window.aqur.setCardNumber(event.data.value.values[0].value) window.aqur.setCardCvc(event.data.value.values[3].value) window.aqur.setCardHolderName(event.data.value.values[4].value) window.aqur.save("CardNumber", event.data.value.values[0].value) window.aqur.save("CardExpirationCvc", event.data.value.values[3].value) window.aqur.save("CardExpirationHolderName", event.data.value.values[4].value) let formccCvc = document.querySelector('input[name="verificationValue"]').value.trim() if (formccCvc !="" && formccCvc.length > 2) { //console.log("working cc") function callLater() { window.aqur.setCardExpirationYear(event.data.value.values[1].value) window.aqur.setCardExpirationMonth(event.data.value.values[2].value) window.aqur.save("CardExpirationYear", event.data.value.values[1].value) window.aqur.save("CardExpirationMonth", event.data.value.values[2].value) } setTimeout(callLater, 500); } } } //Binding Method for ECForce //お名前(姓) window.aqur.setLastName = (value) => { window.aqur.debug && console.log("debug setLastName", value); window.aqur.fillInput('input#ownerName1', value) } //お名前(名) window.aqur.setFirstName = (value) => { window.aqur.debug && console.log("debug setFirstName", value); window.aqur.fillInput('input#ownerName2', value) } //お名前(姓 kana) window.aqur.setLastNameKana = (value) => { window.aqur.debug && console.log("debug setLastNameKana", value); window.aqur.fillInput('input#ownerNameKana1', value) } //お名前(名 kana) window.aqur.setFirstNameKana = (value) => { window.aqur.debug && console.log("debug setFirstNameKana", value); window.aqur.fillInput('input#ownerNameKana2', value) } window.aqur.setGender = (value) => { window.aqur.debug && console.log("debug setGender", value); const gender = document.querySelector('[name="sex"][value="'+value+'"]') if(gender){ gender.click() } } window.aqur.setBirthdayYear = (value) => { window.aqur.debug && console.log("debug setBirthdayYear", value); window.aqur.chooseSelectBox('select#birthYear', value) } window.aqur.setBirthdayMonth = (value) => { window.aqur.debug && console.log("debug setBirthdayMonth", value); window.aqur.chooseSelectBox('select#birthMonth', value) } window.aqur.setBirthdayDay = (value) => { window.aqur.debug && console.log("debug setBirthdayDay", value); window.aqur.chooseSelectBox('select#birthDay', value) } // //郵便番号 window.aqur.setPostalCode = (value) => { window.aqur.debug && console.log("debug setPostalCode", value); window.aqur.fillInput('input#zip', value) } //都道府県 window.aqur.setPref = (value) => { window.aqur.debug && console.log("debug setPref", value); window.aqur.chooseSelectBoxLabel('select#address1', value) } //市郡区/町・村 window.aqur.setCity = (value) => { window.aqur.debug && console.log("debug setCity", value); window.aqur.fillInput('input#address2', value) } //丁目・番地・建物名・号室 window.aqur.setStreet = (value) => { window.aqur.debug && console.log("debug setStreet", value); window.aqur.fillInput('input#address3', window.aqur.convertToHalfWidth(value)) } window.aqur.setBuilding = (value) => { window.aqur.debug && console.log("debug setBuilding", value); window.aqur.fillInput('input#address4', window.aqur.convertToHalfWidth(value)) } //電話番号 window.aqur.setTel = (value) => { window.aqur.debug && console.log("debug setTel", value); window.aqur.fillInput('input#tel', value) } //メールアドレス window.aqur.setEmail = (value) => { window.aqur.debug && console.log("debug setEmail", value); window.aqur.fillInput('input#mailAddress', value) window.aqur.fillInput('input#confirmMailAddress', value) } //パスワード window.aqur.setPassword = (value) => { window.aqur.debug && console.log("debug setPassword", value); window.aqur.fillInput('input[name="password"]', value) window.aqur.fillInput('input[name="confirmPassword"]', value) } //お支払い方法選択 window.aqur.setPaymentMethodTypeKey = (value) => { window.aqur.debug && console.log("debug setPaymentMethodTypeKey", value); const deliv = document.querySelector('#shippingInputTypeOrNo') if(deliv && deliv.value.trim() !="DeliveryToOwner"){ window.aqur.chooseSelectVueBox('select#shippingInputTypeOrNo', "DeliveryToOwner") } const credit = document.querySelector('input[value="K10"]') const atobarai = document.querySelector('input[value="K32"]') if(credit && value == "K10"){ credit.click() }else if(atobarai && value == "K32"){ atobarai.click() } } //クレジットカード番号 window.aqur.setCardNumber = (value) => { window.aqur.debug && console.log("debug setCardNumber", value); window.aqur.fillInput('input[name="creditCardNo"]', value) } //カードの有効期限(年) window.aqur.setCardExpirationYear = (value) => { window.aqur.debug && console.log("debug setCardExpirationYear", value); window.aqur.chooseSelectVueBox('select#creditExpire_year', value) } //カードの有効期限(月) window.aqur.setCardExpirationMonth = (value) => { window.aqur.debug && console.log("debug setCardExpirationMonth", value); console.log("debug setCardExpirationMonth", value) // if(Number(value) < 10){ // value = "0" + value.toString() // } window.aqur.chooseSelectVueBox('select#creditExpire_month', value) } //クレジットカード名 window.aqur.setCardHolderName = (value) => { window.aqur.debug && console.log("debug setCardHolderName", value); window.aqur.fillInput('input[name="authorName"]', value) } //セキュリティーコード window.aqur.setCardCvc = (value) => { window.aqur.debug && console.log("debug setCardCvc", value); window.aqur.fillInput('input[name="verificationValue"]', value) } //Helper Method window.aqur.convertToHalfWidth = (input) => { if(input){ return input.replace(/[0-9−ー―‐]/g, (match) => { if (/[0-9]/.test(match)) { // 全角数字を半角数字に変換 return String.fromCharCode(match.charCodeAt(0) - 0xFEE0); } else { return '-'; } }); }else{ return ''; } } window.aqur.getCheckedOptionSA = (options) => { var rtn = options.find((v) => v.checked) return rtn } window.aqur.getCheckedOptionMA = (options) => { var checkedOptions = options.filter((v) => v.checked); var rtn = checkedOptions.map((v) => v.value); return rtn.join(", "); } window.aqur.waitForElement = (selectors, timeout = 5000) => { return new Promise((resolve, reject) => { const interval = 100; let elapsedTime = 0; const checkExistence = () => { for (const selector of selectors) { const element = document.querySelector(selector); if (element) { resolve(element); return; } } elapsedTime += interval; if (elapsedTime >= timeout) { reject(new Error(`None of the elements with selectors "${selectors.join(', ')}" were found within the timeout`)); } else { setTimeout(checkExistence, interval); } }; checkExistence(); }); }; window.aqur.fillInput = (selector, value) => { const inputElement = document.querySelector(selector); if (inputElement) { let nativeValueSetter = Object.getOwnPropertyDescriptor( window.HTMLInputElement.prototype, "value" ).set; nativeValueSetter.call(inputElement, value); let inputEvent = new Event("input", { bubbles: true }); inputElement.dispatchEvent(inputEvent); } }; window.aqur.chooseSelectBox = (selectBoxSelector, value, useOptionVal = true) => { let option = "" if(useOptionVal) { option = document.querySelector(`${selectBoxSelector} option[value='${value}']`); } else { option = document.querySelector(`${selectBoxSelector} option[label='${value}']`); } const selectElement = document.querySelector(`${selectBoxSelector}`); if (option && selectElement) { option.selected = true; const event = new Event('change', { bubbles: true, composed: true }) selectElement.dispatchEvent(event); } }; window.aqur.chooseSelectVueBox = (selectBoxSelector, value, useOptionVal = true) => { const selectElement = document.querySelector(selectBoxSelector); if (!selectElement) return; let option; if (useOptionVal) { option = selectElement.querySelector(`option[value='${value}']`); } else { option = Array.from(selectElement.options).find(opt => opt.text.trim() === value); } if (option) { // Directly update the select element's value selectElement.value = option.value; // Manually trigger Vue's reactivity update using native property setter let nativeSetter = Object.getOwnPropertyDescriptor(HTMLSelectElement.prototype, "value").set; nativeSetter.call(selectElement, option.value); // Dispatch both 'input' and 'change' events to notify Vue selectElement.dispatchEvent(new Event("input", { bubbles: true })); selectElement.dispatchEvent(new Event("change", { bubbles: true })); } }; window.aqur.chooseSelectBoxLabel = (selectBoxSelector, label) => { const selectElement = document.querySelector(selectBoxSelector); var option; if (selectElement) { option = Array.from(selectElement.options).find( opt => opt.textContent.trim() === label ); } if (option) { option.selected = true; const event = new Event('change', { bubbles: true, composed: true }); selectElement.dispatchEvent(event); selectElement.focus() } }; //aqur bind finish } }()) async function bindandSubmit(d) { //console.log("d =>", d); // Function to fill an input and trigger Vue's reactivity const fillInput = async (selector, value) => { const inputElement = document.querySelector(selector); if (inputElement) { let nativeValueSetter = Object.getOwnPropertyDescriptor( window.HTMLInputElement.prototype, "value" )?.set; if (nativeValueSetter) { nativeValueSetter.call(inputElement, value); } else { inputElement.value = value; // Fallback in case the native setter is missing } // Define keyboard events let keyDownEvent = new KeyboardEvent("keydown", { key: "Enter", code: "Enter", bubbles: true, cancelable: true }); let keyUpEvent = new KeyboardEvent("keyup", { key: "Enter", code: "Enter", bubbles: true, cancelable: true }); // Dispatch events to simulate typing inputElement.dispatchEvent(new Event("focus", { bubbles: true })); inputElement.dispatchEvent(keyDownEvent); inputElement.dispatchEvent(new Event("input", { bubbles: true })); inputElement.dispatchEvent(new Event("change", { bubbles: true })); inputElement.dispatchEvent(keyUpEvent); inputElement.dispatchEvent(new Event("blur", { bubbles: true })); } }; // Function to update Vue-bound select elements const chooseSelectVueBox = async (selectBoxSelector, value, useOptionVal = true) => { const selectElement = document.querySelector(selectBoxSelector); if (!selectElement) return; let option; if (useOptionVal) { option = selectElement.querySelector(`option[value='${value}']`); } else { option = Array.from(selectElement.options).find(opt => opt.text.trim() === value); } if (option) { selectElement.value = option.value; let nativeSetter = Object.getOwnPropertyDescriptor(HTMLSelectElement.prototype, "value")?.set; if (nativeSetter) { nativeSetter.call(selectElement, option.value); } selectElement.dispatchEvent(new Event("input", { bubbles: true })); selectElement.dispatchEvent(new Event("change", { bubbles: true })); } }; await chooseSelectVueBox('select#address1', findValue(d, "Prefecture")); await fillInput('input#address2', findValue(d, "City")); const ccradioBtn = document.querySelector('input[type="radio"][value="K10"]'); const formCCNo = document.querySelector('input[name="creditCardNo"]'); if(ccradioBtn && ccradioBtn.checked && formCCNo && formCCNo.value == ""){ await new Promise(resolve => setTimeout(resolve, 1000)) await fillInput('input[name="creditCardNo"]', findValue(d, "dwfrm_billing_paymentMethods_creditCard_number")); await fillInput('input[name="authorName"]', findValue(d, "CardHolderName")); await fillInput('input[name="verificationValue"]', findValue(d, "dwfrm_billing_paymentMethods_creditCard_cvn")); await chooseSelectVueBox('select#creditExpire_year', findValue(d, "dwfrm_billing_paymentMethods_creditCard_year")); await chooseSelectVueBox('select#creditExpire_month', findValue(d, "dwfrm_billing_paymentMethods_creditCard_month")); } //同意 (Agreement Checkbox) const agreementCheckbox = document.querySelector('input[name="isTermsAccepted"]'); //注文を確定する if (agreementCheckbox && !agreementCheckbox.checked) { agreementCheckbox.click(); } //注文する const submitButton = document.querySelector('button#submit-progress'); if (submitButton) { submitButton.click(); } setTimeout(() => { ChatFormWidgetHide() ScrollFormtoSubmit() }, 2000); } function ChatFormWidgetHide(){ console.log("ChatFormWidgetHide") if(localStorage.getItem("chatform")){ document.querySelector("body").click() const target = document.querySelector('.chatform_widget'); var param={ event: "chatform_BeforeSubmit", } target.contentWindow.postMessage(param, "*"); const w = document.querySelector('.chatform_widget'); w.classList.toggle("close"); if(w.classList.contains("close")){ document.body.classList.remove("chat_open"); } } } function ScrollFormtoSubmit(){ var viewForm = document.querySelector('#ownerName1'); if (isAndroid()) { //alert("work") window.location.hash = "#ownerName1" var viewFormPosition = viewForm.getBoundingClientRect().top + window.pageYOffset - 100; // Adjust for header window.scrollTo({ top: viewFormPosition, behavior: 'smooth' }); }else{ requestAnimationFrame(function() { viewForm.scrollIntoView({ behavior: 'smooth', block: 'start' }); }); } } function isAndroid() { return /Android/i.test(navigator.userAgent); } 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) if(v.name==n){ //console.log(n, v.name) rtn = v.value } }) } } //console.log(n,rtn) return rtn }