2020年– date –

1...456
document.addEventListener('DOMContentLoaded', function () { var buttons = [ { label: '駐車場は🚗', message: '駐車場はありますか?' }, { label: '予約📅', message: '予約方法を教えてください' }, { label: 'ぶどう膜炎とは👁', message: 'ぶどう膜炎とは何ですか?' }, { label: '近視の予防法って👀', message: '近視の予防法を教えてください' }, ]; function addButtons() { var chatBody = document.querySelector('.mwai-conversation'); if (!chatBody) return; if (document.querySelector('.takeru-quick-btns')) return; if (chatBody.querySelectorAll('.mwai-message').length > 1) return; var container = document.createElement('div'); container.className = 'takeru-quick-btns'; container.style.cssText = 'display:flex;flex-wrap:wrap;gap:8px;padding:8px 12px;justify-content:flex-end;'; buttons.forEach(function (b) { var btn = document.createElement('button'); btn.textContent = b.label; btn.style.cssText = 'border:1.5px solid #00A04C;color:#333;background:white;border-radius:20px;padding:6px 14px;font-size:13px;cursor:pointer;display:flex;align-items:center;gap:4px;'; btn.addEventListener('click', function () { var input = document.querySelector('.mwai-chat .mwai-input textarea, .mwai-chat input[type="text"]'); var sendBtn = document.querySelector('.mwai-chat .mwai-send-button'); if (input && sendBtn) { var nativeInputValueSetter = Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype, 'value').set; nativeInputValueSetter.call(input, b.message); input.dispatchEvent(new Event('input', { bubbles: true })); setTimeout(function() { sendBtn.click(); }, 100); container.remove(); } }); container.appendChild(btn); }); chatBody.prepend(container); } var observer = new MutationObserver(function () { if (document.querySelector('.mwai-chat.mwai-open, .mwai-chat')) { setTimeout(addButtons, 500); } }); observer.observe(document.body, { childList: true, subtree: true }); });