// رابط تحميل التطبيق const appDownloadLink = "https://Sahlayn.com/app"; // دالة إنشاء زر تحميل التطبيق function createDownloadLink() { const link = document.createElement("a"); link.href = appDownloadLink; link.textContent = "اضغط هنا"; link.target = "_blank"; link.style = ` display: inline-block; margin-right: 5px; padding: 4px 10px; background-color: #1dd0c6; color: #fff; border-radius: 6px; font-size: 12px; text-decoration: none; `; return link; } // دالة تعديل نص رسائل الكوبون function updateCouponMessage(el, message, isInputError = false) { const msg = message.trim(); if (msg.includes("الكوبون غير متاح")) { if (isInputError) { el.innerHTML = `كود الخصم حصري للاستخدام داخل التطبيق و لتحميل التطبيق `; el.appendChild(createDownloadLink()); } else { el.textContent = "كود الخصم حصري للاستخدام داخل التطبيق"; } } else if (msg.includes("لقد تعديت") || msg.includes("مرات الاستخدام")) { el.textContent = "تم استخدام هذا الكود مسبقاً"; } } // مراقبة رسالة الخطأ أسفل حقل الكوبون const errorObserver = new MutationObserver(() => { const errorEl = document.getElementById("coupon-error"); if (!errorEl) return; updateCouponMessage(errorEl, errorEl.textContent, true); }); errorObserver.observe(document.body, { childList: true, subtree: true }); // مراقبة SweetAlert const swalObserver = new MutationObserver(() => { const swalTitle = document.getElementById("swal2-title"); if (!swalTitle) return; updateCouponMessage(swalTitle, swalTitle.textContent, false); }); swalObserver.observe(document.body, { childList: true, subtree: true }); // إنشاء شريط التنبيه (انتقل للتطبيق) const downloadNotice = document.createElement("div"); downloadNotice.style = ` background: linear-gradient(to left, #1dd0c6, #40ffa7); color: white; padding: 12px; border-radius: 10px; font-size: 15px; font-weight: bold; display: flex; justify-content: space-between; align-items: center; margin: 15px 0px; flex-direction: column; `; downloadNotice.innerHTML = ` اشحن أسرع من تطبيقنا 🚀 انتقل للتطبيق `; // إدراج العنصر قبل .product__description const productDescription = document.querySelector('.product__description'); if (productDescription) { productDescription.parentNode.insertBefore(downloadNotice, productDescription); } document.addEventListener("DOMContentLoaded", function () { // إظهار العنصر الأول (تغيير display إلى block) document.querySelector( "body > div#app.container.container--margined:nth-child(4) > div > div#payment_process:nth-child(3) > main.sections-wrapper:nth-child(1) > div.section.section--payment > div.row.payment-step > div.col-md-12 > div#payment_step > div.mt-4:nth-child(2) > div:nth-child(1) > div:nth-child(2)" ).style.display = "block"; // إخفاء قائمة وسائل الدفع الافتراضية document.querySelector("ul#default_payment_method").style.display = "none"; });