/* Add custom JS code below */
// Save as karzoun.js and include it on every page:
//
(function () {
var ROBOT_ICON_URL = 'https://b.top4top.io/p_3980txbga0.png';
var ITEMS = [
{ text: 'إسأل 👋', size: '16px' },
{ text: 'سريع 🚀', size: '16px' }
];
window.karzounSettings = {
apiUrl: 'https://gloverstore.api.karzoun.chat/clientportal',
integrationId: 'kqQJwNVHpW-wiTczic9u3'
};
function forceOpenKarzoun() {
var container = document.getElementById('kz-messenger-container');
if (container) {
container.style.setProperty('display', 'block', 'important');
container.style.setProperty('visibility', 'visible', 'important');
container.style.setProperty('opacity', '1', 'important');
container.style.setProperty('pointer-events', 'auto', 'important');
container.style.setProperty('z-index', '2147483647', 'important');
var frames = container.querySelectorAll('iframe');
for (var i = 0; i < frames.length; i++) {
frames[i].style.setProperty('display', 'block', 'important');
frames[i].style.setProperty('visibility', 'visible', 'important');
frames[i].style.setProperty('opacity', '1', 'important');
frames[i].style.setProperty('pointer-events', 'auto', 'important');
try {
frames[i].contentWindow.postMessage({ type: 'OPEN_MESSENGER' }, '*');
frames[i].contentWindow.postMessage({ action: 'open' }, '*');
} catch (err) {}
}
}
if (window.Karzoun && window.Karzoun.messenger) {
try {
window.Karzoun.messenger.open();
} catch (e) {}
}
}
function createCustomLauncher() {
if (!document.body || document.getElementById('glover-saree-btn')) return;
var btn = document.createElement('button');
btn.id = 'glover-saree-btn';
btn.type = 'button';
btn.setAttribute('aria-label', 'إسأل سريع');
btn.style.cssText = [
'position: fixed',
'bottom: 135px',
'right: 16px',
'z-index: 999990',
'display: inline-flex',
'align-items: center',
'justify-content: center',
'gap: 4px',
'background: #0B1E38',
'color: #FFFFFF',
'border: 2px solid #2AB3E6',
'border-radius: 50px',
'padding: 6px 12px 6px 10px',
'width: 132px',
'height: 52px',
'font-family: inherit',
'font-weight: 800',
'cursor: pointer',
'box-shadow: 0 6px 18px rgba(11, 30, 56, 0.4)',
'white-space: nowrap',
'line-height: 1.2',
'overflow: visible',
'box-sizing: border-box'
].join(' !important; ') + ' !important;';
btn.innerHTML =
'' +
'
' +
'' +
'' +
'' + ITEMS[0].text + '';
var currentIndex = 0;
setInterval(function () {
var textEl = document.getElementById('glover-saree-text');
if (!textEl) return;
textEl.style.opacity = '0';
textEl.style.transform = 'translateY(4px)';
setTimeout(function () {
currentIndex = (currentIndex + 1) % ITEMS.length;
textEl.style.fontSize = ITEMS[currentIndex].size;
textEl.textContent = ITEMS[currentIndex].text;
textEl.style.opacity = '1';
textEl.style.transform = 'translateY(0)';
}, 350);
}, 2200);
btn.onclick = function (e) {
e.preventDefault();
e.stopPropagation();
if (window.Karzoun && window.Karzoun.messenger) {
try {
if (typeof window.Karzoun.messenger.close === 'function') {
window.Karzoun.messenger.close();
}
} catch (err) {}
}
forceOpenKarzoun();
setTimeout(forceOpenKarzoun, 60);
setTimeout(forceOpenKarzoun, 180);
};
document.body.appendChild(btn);
}
function loadKarzoun() {
createCustomLauncher();
if (document.getElementById('karzoun-pixel')) return;
var script = document.createElement('script');
script.id = 'karzoun-pixel';
script.src = 'https://karzoun-pixel.pages.dev/p.js';
script.async = true;
script.crossOrigin = 'anonymous';
document.body.appendChild(script);
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', loadKarzoun);
} else {
loadKarzoun();
}
})();