// 🎁 منبثق خصم أنيق بخط Tajawal يظهر مرة واحدة فقط لكل زائر – إعداد GPT
document.addEventListener("DOMContentLoaded", function() {
// ✅ لا تكرر المنبثق إن تم عرضه سابقاً
if (localStorage.getItem("discountPopupShown")) return;
// ⏱️ تأخير الظهور 10 ثوانٍ
setTimeout(() => {
// تحميل خط Tajawal من Google Fonts
const tajawalFont = document.createElement("link");
tajawalFont.href = "https://fonts.googleapis.com/css2?family=Tajawal:wght@400;700;900&display=swap";
tajawalFont.rel = "stylesheet";
document.head.appendChild(tajawalFont);
// إنشاء المنبثق
const popup = document.createElement("div");
popup.innerHTML = `
`;
document.body.appendChild(popup);
const popupElement = document.querySelector(".discount-popup");
const copyBtn = document.getElementById("copyBtn");
const discountCode = document.getElementById("discountCode");
const closePopup = document.getElementById("closePopup");
// 🧠 عند نسخ الكود
copyBtn.addEventListener("click", function() {
navigator.clipboard.writeText(discountCode.textContent);
copyBtn.textContent = "✅ تم النسخ!";
setTimeout(() => (copyBtn.textContent = "نسخ الكود"), 2000);
});
// 🔒 عند إغلاق المنبثق – احفظ أنه ظهر
const closeAction = () => {
popupElement.remove();
localStorage.setItem("discountPopupShown", "true");
};
closePopup.addEventListener("click", closeAction);
popupElement.addEventListener("click", e => {
if (e.target === popupElement) closeAction();
});
}, 10000); // يظهر بعد 10 ثوانٍ
});
// 🛍️ إشعارات مبيعات وهمية بخط Tajawal + 🎉 – إصدار سريع كل 15 ثانية
document.addEventListener("DOMContentLoaded", function() {
// تحميل الخط
const tajawalFont = document.createElement("link");
tajawalFont.href = "https://fonts.googleapis.com/css2?family=Tajawal:wght@500;700&display=swap";
tajawalFont.rel = "stylesheet";
document.head.appendChild(tajawalFont);
// إنشاء الحاوية
const container = document.createElement("div");
container.className = "sales-popup-container";
document.body.appendChild(container);
// بيانات عشوائية
const names = ["نواف", "فهد", "علي", "سارة", "ريم", "نورة", "عبدالله", "فيصل", "منصور", "رهف", "مشعل", "تركي", "محمد", "بندر", "هند"];
const cities = ["الرياض", "جدة", "الدمام", "الظهران", "الخبر", "مكة", "المدينة", "ينبع", "حائل", "الطائف", "تبوك", "بريدة", "القصيم", "خميس مشيط", "أبها", "نجران", "الجبيل", "عرعر", "بيشة", "المجمعة", "القنفذة", "الدوادمي"];
const products = [
"متابعين تيك توك",
"بكج الاكسبلور الفضي",
"بكج الاكسبلور الذهبي",
"بكج الاكسبلور البرونزي",
"لايكات تيك توك",
"مشاهدات تيك توك"
];
const times = [
"قبل لحظات",
"قبل دقيقة",
"قبل دقيقتين",
"قبل 3 دقائق",
"قبل 5 دقائق",
"قبل 8 دقائق",
"قبل 12 دقيقة",
"قبل 17 دقيقة"
];
// إنشاء إشعار جديد
function showPopup() {
const name = names[Math.floor(Math.random() * names.length)];
const city = cities[Math.floor(Math.random() * cities.length)];
const product = products[Math.floor(Math.random() * products.length)];
const time = times[Math.floor(Math.random() * times.length)];
const popup = document.createElement("div");
popup.className = "sales-popup";
popup.innerHTML = `
`;
container.appendChild(popup);
setTimeout(() => popup.classList.add("visible"), 100);
setTimeout(() => {
popup.classList.remove("visible");
setTimeout(() => popup.remove(), 500);
}, 7000);
}
// تشغيل الإشعارات كل 15 ثانية
function startPopups() {
showPopup();
setInterval(showPopup, 15000); // ⏱️ إشعار جديد كل 15 ثانية
}
// CSS
const style = document.createElement("style");
style.innerHTML = `
.sales-popup-container {
position: fixed;
bottom: 20px;
left: 20px;
z-index: 999999;
display: flex;
flex-direction: column;
gap: 10px;
font-family: "Tajawal", sans-serif;
}
.sales-popup {
background: #ffffff;
color: #333;
border-radius: 14px;
box-shadow: 0 6px 18px rgba(0,0,0,0.1);
padding: 0.8rem 1rem;
min-width: 240px;
max-width: 280px;
opacity: 0;
transform: translateY(20px);
transition: all 0.4s ease;
direction: rtl;
}
.sales-popup.visible {
opacity: 1;
transform: translateY(0);
}
.popup-content {
display: flex;
align-items: flex-start;
gap: 0.6rem;
}
.popup-icon {
font-size: 1.5rem;
line-height: 1;
}
.popup-text {
font-size: 0.95rem;
line-height: 1.4;
}
.popup-text strong {
color: #7774a5;
font-weight: 700;
}
.popup-time {
color: #666;
font-size: 0.85rem;
}
@media (max-width: 600px) {
.sales-popup-container {
left: 10px;
bottom: 10px;
}
.sales-popup {
min-width: 200px;
font-size: 0.9rem;
}
}
`;
document.head.appendChild(style);
// أول إشعار بعد 3 ثوانٍ
setTimeout(startPopups, 3000);
});