window.chatwootSettings = {"position":"left","type":"standard","launcherTitle":"Discutez avec nous"}; (function () { var script = document.currentScript; if (!script) return; var baseUrl = (script.dataset.baseUrl || '').replace(/\/$/, ''); var websiteToken = script.dataset.websiteToken || ''; var position = script.dataset.position || ''; var locale = script.dataset.locale || document.documentElement.lang || ''; if (locale) { window.chatwootSettings = window.chatwootSettings || {}; window.chatwootSettings.locale = locale; } if (!baseUrl || !websiteToken) return; var allowed = { left: true, right: true }; if (allowed[position]) { window.chatwootSettings = window.chatwootSettings || {}; window.chatwootSettings.position = position; } var loaded = false; function loadChatwoot() { if (loaded) return; loaded = true; var sdk = document.createElement('script'); sdk.src = baseUrl + '/packs/js/sdk.js'; sdk.async = true; sdk.onload = function () { if (window.chatwootSDK && typeof window.chatwootSDK.run === 'function') { var settings = { websiteToken: websiteToken, baseUrl: baseUrl }; window.chatwootSDK.run(settings); // Masquer la bulle préliminaire dès que le SDK est prêt if (window.__chatwootHideBubble) window.__chatwootHideBubble(); } }; var head = document.head || document.getElementsByTagName('head')[0] || document.documentElement; head.appendChild(sdk); } // Bulle statique : aucune ressource chatwoot.bilp.fr avant le clic. // Le script est dans
: attendre que body existe. function createBubble() { if (!document.body) return; var bubble = document.createElement('button'); bubble.type = 'button'; bubble.id = 'chatbot-chatwoot-bubble'; bubble.setAttribute('aria-label', 'Ouvrir le chat'); bubble.innerHTML = ''; document.body.appendChild(bubble); // Couleur de la bulle = couleur des liens du site ; icône toujours blanche var linkEl = document.querySelector('a'); var bubbleBg = linkEl ? getComputedStyle(linkEl).color : '#0b72d1'; var bubbleFg = '#fff'; var style = document.createElement('style'); style.textContent = '#chatbot-chatwoot-bubble{position:fixed;left:' + (position === 'right' ? 'auto' : '20px') + ';right:' + (position === 'right' ? '20px' : 'auto') + ';bottom:20px;width:56px;height:56px;border-radius:50%;border:0;' + 'background:' + bubbleBg + ';color:' + bubbleFg + ';box-shadow:0 2px 8px rgba(0,0,0,.3);' + 'cursor:pointer;z-index:999999;display:flex;align-items:center;justify-content:center;' + 'transition:opacity .2s,transform .2s}' + '#chatbot-chatwoot-bubble:hover{transform:scale(1.08)}' + '#chatbot-chatwoot-bubble.chatwoot-bubble-hidden{opacity:0;pointer-events:none}'; (document.head || document.documentElement).appendChild(style); // Masquer la bulle quand le widget réel apparaît (appelé par loadChatwoot) window.__chatwootHideBubble = function() { var b = document.getElementById('chatbot-chatwoot-bubble'); if (b) b.classList.add('chatwoot-bubble-hidden'); }; // Chargement du SDK au survol de la bulle (mouseover) bubble.addEventListener('mouseover', function () { loadChatwoot(); }); } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', createBubble); } else { createBubble(); } })();