document.addEventListener("DOMContentLoaded", function() { let whatsappList = `
`; document.body.insertAdjacentHTML("beforeend", whatsappList); let popup = document.getElementById("whatsapp-popup"); let toggleButton = document.getElementById("open-popup"); let overlay = document.getElementById("overlay"); // Toggle popup when clicking the main button toggleButton.addEventListener("click", function() { popup.style.display = popup.style.display === "none" || popup.style.display === "" ? "block" : "none"; overlay.style.display = overlay.style.display === "none" || overlay.style.display === "" ? "block" : "none"; }); // Close popup when clicking close button document.getElementById("close-popup").addEventListener("click", function() { popup.style.display = "none"; overlay.style.display = "none"; }); // Close popup when clicking any WhatsApp link const whatsappLinks = popup.querySelectorAll('a'); whatsappLinks.forEach(link => { link.addEventListener('click', function() { popup.style.display = 'none'; overlay.style.display = 'none'; }); }); // Close popup when clicking the overlay (background) overlay.addEventListener('click', function() { popup.style.display = 'none'; overlay.style.display = 'none'; }); }); (function () { /* ============ EMAIL ============ */ const emailPattern = /^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$/; const emailSelectors = 'input[name="options[1724951733]"], ' + 'input[name="options[1428504440]"], ' + 'input[name="options[880498916]"], ' + 'input[name="options[398740139]"], ' + 'input[name="options[768035371]"]'; function initEmailValidation() { document.querySelectorAll(emailSelectors).forEach((input) => { if (input.dataset.validated) return; addErrorBox(input, 'الرجاء إدخال بريد إلكتروني صالح'); applyAsciiOnly(input); setAttrs(input, 'email', emailPattern.source); addBlurValidation(input); input.dataset.validated = 'true'; }); } /* ============ PASSWORD ============ */ const passwordPattern = /^[A-Za-z0-9!@#\$%\^&\*\(\)_\+\-\=\[\]\{\};:"\\|,.<>\/\?]{6,}$/; const passwordSelectors = [ 'options[2142005556]', 'options[1755403422]', 'options[1873106002]', 'options[1637968308]', 'options[654466681]', ] .map((id) => `input[name="${id}"]`) .join(', '); function initPasswordValidation() { document.querySelectorAll(passwordSelectors).forEach((input) => { if (input.dataset.validated) return; // غلاف وزر 👁 wrapWithPasswordEye(input); addErrorBox(input, 'الرجاء تأكد من صحة كلمة المرور'); applyAsciiOnly(input); setAttrs(input, 'password', passwordPattern.source); addBlurValidation(input); input.dataset.validated = 'true'; }); } /* ============ EA CODE (8 digits) ============ */ const eaPattern = /^\d{8}$/; const eaSelectors = [ 'options[1193638897]', 'options[1518920782]', 'options[877986639]', 'options[1894743418]', 'options[1119198331]', 'options[479378244]', 'options[1350318749]', 'options[576280990]', 'options[1449454819]', 'options[884446292]', 'options[110932821]', 'options[1350160982]', ] .map((id) => `input[name="${id}"]`) .join(', '); function initEaValidation() { document.querySelectorAll(eaSelectors).forEach((input) => { if (input.dataset.validated) return; addErrorBox(input, 'كود EA غير صالح'); applyAsciiOnly(input); setAttrs(input, 'text', eaPattern.source); addBlurValidation(input); input.dataset.validated = 'true'; }); } /* ============ HELPERS ============ */ function setAttrs(el, type, pattern) { el.type = type; el.required = true; el.dir = 'rtl'; el.pattern = pattern; } function addErrorBox(el, msg) { const err = document.createElement('div'); err.className = 'input-error'; err.textContent = msg; err.style.display = 'none'; el.insertAdjacentElement('afterend', err); } function addBlurValidation(input) { const err = input.nextElementSibling; input.addEventListener('blur', () => { const bad = !input.checkValidity(); input.classList.toggle('invalid', bad); err.style.display = bad ? 'block' : 'none'; }); } function applyAsciiOnly(input) { input.addEventListener('keypress', (e) => { if (!/^[\x20-\x7E]$/.test(String.fromCharCode(e.which))) e.preventDefault(); }); input.addEventListener('input', (e) => { e.target.value = e.target.value.replace(/[^\x20-\x7E]/g, ''); }); } function wrapWithPasswordEye(input) { const wrapper = document.createElement('div'); wrapper.style.position = 'relative'; input.parentNode.insertBefore(wrapper, input); wrapper.appendChild(input); input.style.paddingLeft = '35px'; const eye = document.createElement('span'); eye.textContent = '👁'; eye.style.cssText = 'position:absolute;left:10px;top:50%;transform:translateY(-50%);cursor:pointer;'; wrapper.appendChild(eye); eye.addEventListener('click', () => { input.type = input.type === 'password' ? 'text' : 'password'; }); } /* ============ OBSERVER ============ */ const observer = new MutationObserver(() => { initEmailValidation(); initPasswordValidation(); initEaValidation(); }); observer.observe(document.body, { childList: true, subtree: true }); /* أول تشغيل */ initEmailValidation(); initPasswordValidation(); initEaValidation(); })(); /* إضافة لينك شرح استخراج أكواد EA + حذف الـ الأصلي */ (function () { /* 1) رابط الشرح */ const eaHelpLinkURL = 'https://arab-ut.com/ea-backup-codes-guide/page-699997932'; // ← غيّره /* 2) جميع حقول EA */ const eaSelectors = [ 'options[1193638897]','options[1518920782]','options[877986639]', 'options[1894743418]','options[1119198331]','options[479378244]', 'options[1350318749]','options[576280990]','options[1449454819]', 'options[884446292]','options[110932821]','options[1350160982]' ].map(id => `input[name="${id}"]`).join(', '); /* 3) أضف اللينك واحذف الـ القديم */ function addEaHelpLink() { const firstInput = document.querySelector(eaSelectors); if (!firstInput) return; const label = firstInput.closest('.s-product-options-option') ?.querySelector('label.s-product-options-option-label'); if (!label) return; /* لو اللينك موجود خلاص */ if (label.querySelector('.ea-help-link')) return; /* شيل أى قديم بالكامل */ label.querySelectorAll('small').forEach(el => el.remove()); /* أنشئ جديد باللينك */ const smallWrap = document.createElement('small'); const link = document.createElement('a'); link.href = eaHelpLinkURL; link.target = '_blank'; link.rel = 'noopener'; link.textContent = 'لمعرفة كيفية استخراج الأكواد'; link.className = 'ea-help-link'; /* ستايل أوضح */ link.style.color = '#0a58ca'; // أزرق لينكات link.style.textDecoration = 'underline'; link.style.fontSize = '0.85rem'; // أكبر سنّة link.style.marginRight = '0'; smallWrap.appendChild(link); /* إلصاق بعد */ const titleB = label.querySelector('b'); if (titleB) { titleB.insertAdjacentElement('afterend', smallWrap); } else { label.appendChild(smallWrap); } } /* 4) نفّذ أول مرة وراقب الـDOM */ addEaHelpLink(); new MutationObserver(addEaHelpLink) .observe(document.body, { childList: true, subtree: true }); })();