(function() { window.AqurBaseURL = 'https://pr.aqur.com'; var take = function() { window.addEventListener("chatform_initialized", (event) => { if(/hangover/.test(window.location.href) || /pf_ss_tto_fatigue_af/.test(window.location.href) || /pf_ss_ttoimp_fatigue_af/.test(window.location.href)){ var param={ type: "chatform_shareParams", btnClass:"aqurBtn1" } const target = document.querySelector('.chatform_widget'); target.contentWindow.postMessage(param, "*"); } else if(/waist/.test(window.location.href)){ var param={ type: "chatform_shareParams", btnClass:"aqurBtn2" } const target = document.querySelector('.chatform_widget'); target.contentWindow.postMessage(param, "*"); } else if(/fatigue980/.test(window.location.href)){ var param={ type: "chatform_shareParams", btnClass:"aqurBtn3" } const target = document.querySelector('.chatform_widget'); target.contentWindow.postMessage(param, "*"); } else if(/fatigue/.test(window.location.href)){ var param={ type: "chatform_shareParams", btnClass:"aqurBtn4" } const target = document.querySelector('.chatform_widget'); target.contentWindow.postMessage(param, "*"); } var path = window.location.pathname; if ( !path.includes('/lp/confirm') && !path.includes('/lp/complete') && !path.includes('/lp/cv_upsell') ) { var launchBtn = document.createElement("img"); var btnUrl = "https://res.cloudinary.com/dts6mbw86/image/upload/v1744907308/aqur/phyfl/floating_banner_ye_dvzoow.png" launchBtn.src = btnUrl; launchBtn.classList.add("launchBtn"); launchBtn.classList.add("chatformBtn"); document.body.appendChild(launchBtn); // Style the button launchBtn.style.position = "fixed"; launchBtn.style.bottom = "61px"; launchBtn.style.zIndex = "100000"; } let href = window.location.href; if(href.includes("youjyousenyaku.jp/lp") && href.includes("_sc_") && !href.includes("lp/cv_upsel") && !href.includes("lp/complete") ){ //console.log("auto start") activateChatformWidget() } 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 isChrome() { const userAgent = navigator.userAgent; const isChrome = /Chrome/.test(userAgent) && /Google Inc/.test(navigator.vendor); return isChrome; } 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 = "pysfl"; 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', "8fad7e30-28ea-46db-82ca-73190ce2b913"); 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.77"); 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", (event) => { if (event.data.action == 'CHECK_PATHNAME') { //console.log('CHECK_PATHNAME') const href = window.location.href; const target = document.querySelector('.chatform_widget'); var param={ action: "PATHNAME_RESPONSE", href: href } target.contentWindow.postMessage(param, "*"); } 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)); var mailAgreement = false mailAgreement = event.data.mailAgreement // activateChatformWidget(); chatformSubmit(mailAgreement) } 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")); } }, false) } setTimeout(take, 0); // import ecforce bind form const importAqurBinding =(target)=>{ var script = document.createElement('script'); script.src = `${window.AqurBaseURL}/bindings/`+target; document.head.appendChild(script); script.onload = function() { console.log("bindings script loaded"); window.aqur.debug = false; }; } importAqurBinding("ecforce") // Submit const chatformSubmit = (mailAgreement) =>{ console.log("chatformSubmit") // 同意 const Agreement = document.querySelector('input#agree').checked; if (!Agreement) { document.querySelector('input#agree').click() } if(mailAgreement){ const receive = document.querySelector('input#optin').checked; if (!receive) { document.querySelector('input#optin').click() } }else{ const receive = document.querySelector('input#optin').checked; if (receive) { document.querySelector('input#optin').click() } } // 申し込み確認ボタン const setSubmit = () => { document.getElementById('submit').click(); activateChatformWidget(); } setTimeout(setSubmit, 500) } }())