// `;
// // ============ المتغيرات العامة ============
// let popup = null;
// let popupShown = false;
// let allowLeave = false;
// let pendingNavigationUrl = null;
// let observer = null;
// // ============ دوال مساعدة ============
// function getPopup() {
// return document.getElementById('exit-popup');
// }
// function ensurePopupExists() {
// popup = getPopup();
// if (!popup) {
// const tempDiv = document.createElement('div');
// tempDiv.innerHTML = popupHTML;
// const popupElement = tempDiv.firstElementChild;
// document.body.appendChild(popupElement);
// popup = popupElement;
// bindPopupEvents();
// }
// }
// function bindPopupEvents() {
// if (!popup) return;
// const continueBtn = popup.querySelector('#continueBtn');
// if (continueBtn && !continueBtn.hasAttribute('listener')) {
// continueBtn.setAttribute('listener', 'true');
// continueBtn.addEventListener('click', closePopup);
// }
// const leaveBtn = popup.querySelector('#leaveBtn');
// if (leaveBtn && !leaveBtn.hasAttribute('listener')) {
// leaveBtn.setAttribute('listener', 'true');
// leaveBtn.addEventListener('click', forceLeave);
// }
// popup.querySelectorAll('.options-list a').forEach(link => {
// if (!link.hasAttribute('listener')) {
// link.setAttribute('listener', 'true');
// link.addEventListener('click', function() {
// allowLeave = true;
// popupShown = true;
// markShownToday();
// window.removeEventListener('beforeunload', beforeUnloadHandler);
// });
// }
// });
// }
// // ============ دوال العرض والإغلاق ============
// function showPopup() {
// if (!canShowPopup()) return;
// if (hasShownToday()) return;
// ensurePopupExists();
// if (popup && !popupShown && !allowLeave) {
// popup.style.display = 'flex';
// popupShown = true;
// markShownToday();
// window.addEventListener('beforeunload', beforeUnloadHandler);
// if (window.history && window.history.pushState) {
// history.pushState(null, null, location.href);
// }
// }
// }
// function closePopup() {
// if (popup) popup.style.display = 'none';
// popupShown = false;
// pendingNavigationUrl = null;
// markShownToday();
// window.removeEventListener('beforeunload', beforeUnloadHandler);
// }
// function forceLeave() {
// allowLeave = true;
// markShownToday();
// window.removeEventListener('beforeunload', beforeUnloadHandler);
// if (popup) popup.style.display = 'none';
// if (pendingNavigationUrl) {
// window.location.href = pendingNavigationUrl;
// } else {
// window.close();
// }
// }
// function beforeUnloadHandler(e) {
// if (allowLeave) return;
// e.preventDefault();
// e.returnValue = '';
// }
// // ============ اعتراض الروابط الخارجية (كما في الأصل) ============
// function handleDocumentClick(e) {
// if (e.target.closest('#exit-popup')) return;
// const link = e.target.closest('a');
// if (!link) return;
// if (link.classList.contains('no-intercept')) return;
// const href = link.getAttribute('href');
// if (!href || href.startsWith('mailto:') || href.startsWith('tel:') || href.startsWith('javascript:')) return;
// const linkUrl = new URL(link.href, window.location.href);
// if (linkUrl.hostname === window.location.hostname) return;
// userHasInteracted = true;
// if (!canShowPopup()) return;
// e.preventDefault();
// pendingNavigationUrl = link.href;
// showPopup();
// }
// // ============ أحداث الخروج بالماوس — من الأعلى فقط ============
// function handleMouseOut(e) {
// if (!userHasInteracted) return;
// if (!e.relatedTarget && !e.toElement) {
// // ✅ من الأعلى فقط (شريط التبويبات/العنوان)
// if (e.clientY <= -10) {
// showPopup();
// }
// }
// }
// function handleMouseLeave(e) {
// if (!userHasInteracted) return;
// // ✅ من الأعلى فقط
// if (e.clientY <= -10) {
// showPopup();
// }
// }
// // ============ التعامل مع زر الرجوع (كما في الأصل) ============
// function handlePopState() {
// if (!userHasInteracted) return;
// if (hasShownToday()) return;
// if (!popupShown && !allowLeave) {
// showPopup();
// if (window.history && window.history.pushState) {
// history.pushState(null, null, location.href);
// }
// } else {
// if (!allowLeave && window.history && window.history.pushState) {
// history.pushState(null, null, location.href);
// }
// }
// }
// // ============ التهيئة ============
// function init() {
// ensurePopupExists();
// if (!window.__exitPopupInitialized) {
// window.__exitPopupInitialized = true;
// ['mousemove', 'scroll', 'touchstart', 'keydown', 'click'].forEach(function(evt) {
// document.addEventListener(evt, function() {
// userHasInteracted = true;
// }, { once: true, passive: true });
// });
// if (interceptExternalLinks) {
// document.addEventListener('click', handleDocumentClick);
// }
// document.addEventListener('mouseout', handleMouseOut);
// document.addEventListener('mouseleave', handleMouseLeave);
// window.addEventListener('popstate', handlePopState);
// observer = new MutationObserver(function() {
// if (!getPopup()) {
// ensurePopupExists();
// }
// });
// observer.observe(document.body, { childList: true, subtree: true });
// }
// if (window.history && window.history.pushState) {
// history.pushState(null, null, location.href);
// }
// }
// // ============ بدء التشغيل ============
// if (document.readyState === 'loading') {
// document.addEventListener('DOMContentLoaded', init);
// } else {
// init();
// }
// if (!document.body) {
// const bodyCheckInterval = setInterval(() => {
// if (document.body) {
// clearInterval(bodyCheckInterval);
// init();
// }
// }, 100);
// }
// })();
(function () {
function addCertificate() {
const footer = document.querySelector('footer[data-testid="store-footer"]');
if (!footer) return false;
// البحث عن الحاوية التي تحتوي على السجل التجاري
const container = footer.querySelector('.flex.gap-4');
if (!container) return false;
// التأكد من عدم إضافة الكود أكثر من مرة
if (container.querySelector('.f_certificates')) return true;
// إنشاء حاوية التوثيق
const certWrapper = document.createElement('div');
certWrapper.className = 'f_certificates';
// محتوى التوثيق (تمت إزالة التنسيقات الداخلية واعتمادها على CSS)
certWrapper.innerHTML = `
موثقين لدى منصة الأعمال
`;
// إضافة التوثيق بجانب السجل التجاري
container.appendChild(certWrapper);
return true;
}
// تنفيذ الكود ومحاولة تطبيقه بشكل مستمر حتى يتم تحميل الفوتر
if (!addCertificate()) {
const interval = setInterval(() => {
if (addCertificate()) clearInterval(interval);
}, 300);
setTimeout(() => clearInterval(interval), 10000);
}
})();