/* Add custom Js styles below */
/* Add custom Js styles below */
document.addEventListener("DOMContentLoaded", function () {
let shown = false;
document.addEventListener("DOMContentLoaded", function () {
const CART_URL = "/cart";
const BRAND_COLOR = "#8B0000";
/* حذف أي سلة مضافة سابقًا من الأكواد القديمة */
document.querySelectorAll(".center-floating-cart, .smart-floating-cart, .always-cart-widget, .premium-cart-pill").forEach(function (el) {
el.remove();
});
let cartCount = Number(localStorage.getItem("centerFloatingCartCount") || 0);
const style = document.createElement("style");
style.innerHTML = `
.center-floating-cart {
position: fixed;
top: 50%;
left: 14px;
transform: translateY(-50%);
z-index: 999999;
direction: rtl;
font-family: inherit;
}
.center-floating-cart-btn {
width: 82px;
min-height: 96px;
border-radius: 26px;
background: #111;
color: #fff;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 6px;
text-decoration: none;
box-shadow: 0 16px 45px rgba(0,0,0,0.35);
position: relative;
border: 1px solid rgba(255,255,255,0.18);
cursor: pointer;
transition: all 0.3s ease;
}
.center-floating-cart-btn:hover {
transform: scale(1.05);
background: ${BRAND_COLOR};
}
.center-floating-cart-icon {
font-size: 30px;
line-height: 1;
}
.center-floating-cart-text {
font-size: 12px;
font-weight: 900;
text-align: center;
line-height: 1.35;
}
.center-floating-cart-count {
position: absolute;
top: -10px;
right: -10px;
min-width: 30px;
height: 30px;
padding: 0 7px;
background: ${BRAND_COLOR};
color: #fff;
border-radius: 999px;
display: flex;
align-items: center;
justify-content: center;
font-size: 14px;
font-weight: 900;
border: 2px solid #fff;
box-shadow: 0 6px 18px rgba(139,0,0,0.35);
}
.center-floating-cart-message {
position: absolute;
top: 50%;
left: 95px;
transform: translateY(-50%) translateX(-10px);
background: #fff;
color: #111;
min-width: 210px;
padding: 13px 15px;
border-radius: 18px;
box-shadow: 0 14px 40px rgba(0,0,0,0.22);
font-size: 13px;
font-weight: 800;
line-height: 1.7;
opacity: 0;
pointer-events: none;
transition: all 0.3s ease;
border: 1px solid rgba(0,0,0,0.08);
}
.center-floating-cart.show-message .center-floating-cart-message {
opacity: 1;
transform: translateY(-50%) translateX(0);
}
.center-floating-cart-message span {
color: ${BRAND_COLOR};
font-weight: 900;
}
.center-cart-bounce {
animation: centerCartBounce 0.55s ease;
}
@keyframes centerCartBounce {
0% { transform: translateY(-50%) scale(1); }
40% { transform: translateY(-50%) scale(1.13); }
100% { transform: translateY(-50%) scale(1); }
}
@media (max-width: 600px) {
.center-floating-cart {
left: 10px;
}
.center-floating-cart-btn {
width: 72px;
min-height: 86px;
border-radius: 22px;
}
.center-floating-cart-icon {
font-size: 26px;
}
.center-floating-cart-text {
font-size: 11px;
}
.center-floating-cart-message {
left: 82px;
min-width: 175px;
font-size: 12px;
}
}
`;
document.head.appendChild(style);
const cart = document.createElement("div");
cart.className = "center-floating-cart";
cart.innerHTML = `
${cartCount}
🛒
سلة
المشتريات
تم تحديث السلة
عدد المنتجات الآن: ${cartCount}
`;
document.body.appendChild(cart);
const countEl = document.getElementById("centerFloatingCartCount");
const messageCountEl = document.getElementById("centerFloatingCartMessageCount");
function readRealCartCount() {
const selectors = [
".s-cart-summary-count",
".s-cart-count",
".cart-count",
".header-cart-count",
".s-cart-widget-count",
"[data-cart-count]",
".badge"
];
for (const selector of selectors) {
const el = document.querySelector(selector);
if (!el) continue;
const number = parseInt((el.innerText || el.textContent || "").replace(/\D/g, ""));
if (!isNaN(number)) return number;
}
return null;
}
function updateCartCount(number) {
cartCount = Number(number) || 0;
countEl.innerText = cartCount;
messageCountEl.innerText = cartCount;
localStorage.setItem("centerFloatingCartCount", cartCount);
cart.classList.add("center-cart-bounce");
cart.classList.add("show-message");
setTimeout(function () {
cart.classList.remove("center-cart-bounce");
}, 600);
setTimeout(function () {
cart.classList.remove("show-message");
}, 2500);
}
const realCount = readRealCartCount();
if (realCount !== null) {
updateCartCount(realCount);
}
document.addEventListener("click", function (e) {
const btn = e.target.closest("button, a");
if (!btn) return;
const text = btn.innerText.trim();
const isAddToCart =
text.includes("أضف للسلة") ||
text.includes("اضف للسلة") ||
text.includes("أضف إلى السلة") ||
text.includes("إضافة للسلة") ||
text.includes("اشتري الآن") ||
text.includes("اشترِ الآن") ||
text.includes("Add to cart");
if (!isAddToCart) return;
setTimeout(function () {
const updatedCount = readRealCartCount();
if (updatedCount !== null) {
updateCartCount(updatedCount);
} else {
updateCartCount(cartCount + 1);
}
}, 700);
});
const observer = new MutationObserver(function () {
const updatedCount = readRealCartCount();
if (updatedCount !== null && updatedCount !== cartCount) {
updateCartCount(updatedCount);
}
});
observer.observe(document.body, {
childList: true,
subtree: true,
characterData: true
});
});
document.addEventListener("DOMContentLoaded", function () {
if (sessionStorage.getItem("smartQuizShown")) return;
setTimeout(function () {
const quiz = document.createElement("div");
quiz.innerHTML = `
نساعدك تختار؟
اختر نوع الطلب المناسب لك
`;
document.body.appendChild(quiz);
document.querySelectorAll(".quizChoice").forEach(function (btn) {
btn.style.display = "block";
btn.style.width = "100%";
btn.style.margin = "10px 0";
btn.style.padding = "13px";
btn.style.borderRadius = "14px";
btn.style.border = "none";
btn.style.background = "#8B0000";
btn.style.color = "#fff";
btn.style.fontSize = "15px";
btn.style.fontWeight = "bold";
btn.style.cursor = "pointer";
btn.addEventListener("click", function () {
sessionStorage.setItem("smartQuizShown", "true");
window.location.href = this.getAttribute("data-url");
});
});
document.getElementById("closeQuiz").onclick = function () {
document.getElementById("quizOverlay").remove();
sessionStorage.setItem("smartQuizShown", "true");
};
}, 2500);
});
document.addEventListener("DOMContentLoaded", function () {
let shown = false;
function showExitOffer() {
if (shown || localStorage.getItem("exitOfferShown")) return;
shown = true;
localStorage.setItem("exitOfferShown", "true");
const popup = document.createElement("div");
popup.innerHTML = `
`;
document.body.appendChild(popup);
document.getElementById("continueShopping").onclick = function () {
document.getElementById("exitPopup").remove();
};
document.getElementById("closeExitPopup").onclick = function () {
document.getElementById("exitPopup").remove();
};
}
document.addEventListener("mouseleave", function (e) {
if (e.clientY <= 0) {
showExitOffer();
}
});
setTimeout(function () {
if (window.innerWidth <= 768) {
showExitOffer();
}
}, 35000);
});
document.addEventListener("DOMContentLoaded", function () {
function findAddToCartButton() {
const buttons = Array.from(document.querySelectorAll("button, a"));
return buttons.find(function (btn) {
const text = btn.innerText.trim();
return text.includes("أضف للسلة") || text.includes("اضف للسلة") || text.includes("Add to cart");
});
}
const originalBtn = findAddToCartButton();
if (!originalBtn) return;
const stickyBtn = document.createElement("button");
stickyBtn.innerHTML = "أضف للسلة الآن";
stickyBtn.style.position = "fixed";
stickyBtn.style.bottom = "18px";
stickyBtn.style.right = "18px";
stickyBtn.style.left = "18px";
stickyBtn.style.background = "#8B0000";
stickyBtn.style.color = "#fff";
stickyBtn.style.border = "none";
stickyBtn.style.borderRadius = "16px";
stickyBtn.style.padding = "15px";
stickyBtn.style.fontSize = "17px";
stickyBtn.style.fontWeight = "bold";
stickyBtn.style.zIndex = "99999";
stickyBtn.style.display = "none";
stickyBtn.style.boxShadow = "0 8px 22px rgba(0,0,0,0.25)";
stickyBtn.style.cursor = "pointer";
document.body.appendChild(stickyBtn);
window.addEventListener("scroll", function () {
if (window.scrollY > 500) {
stickyBtn.style.display = "block";
} else {
stickyBtn.style.display = "none";
}
});
stickyBtn.addEventListener("click", function () {
originalBtn.click();
});
});
document.addEventListener("DOMContentLoaded", function () {
const buttons = Array.from(document.querySelectorAll("button, a"));
const addBtn = buttons.find(function (btn) {
const text = btn.innerText.trim();
return text.includes("أضف للسلة") || text.includes("اضف للسلة") || text.includes("Add to cart");
});
if (!addBtn) return;
const trustBox = document.createElement("div");
trustBox.innerHTML = `
✓ دفع آمن وموثوق
✓ تجهيز سريع للطلب
✓ خدمة عملاء متوفرة للمساعدة
`;
addBtn.parentElement.appendChild(trustBox);
});
document.addEventListener("DOMContentLoaded", function () {
const messages = [
"عميل يشاهد هذا المنتج الآن",
"تم طلب منتج مشابه قبل قليل",
"هذا المنتج من الخيارات المفضلة للعملاء",
"لا تفوّت المنتجات الأكثر طلباً"
];
function showSmartNotice() {
const notice = document.createElement("div");
notice.innerHTML = messages[Math.floor(Math.random() * messages.length)];
notice.style.position = "fixed";
notice.style.bottom = "80px";
notice.style.right = "18px";
notice.style.background = "#fff";
notice.style.color = "#222";
notice.style.padding = "12px 16px";
notice.style.borderRadius = "14px";
notice.style.boxShadow = "0 6px 20px rgba(0,0,0,0.18)";
notice.style.zIndex = "99999";
notice.style.fontSize = "14px";
notice.style.fontWeight = "bold";
notice.style.maxWidth = "280px";
document.body.appendChild(notice);
setTimeout(function () {
notice.remove();
}, 4500);
}
setTimeout(showSmartNotice, 5000);
setInterval(showSmartNotice, 25000);
});
document.addEventListener("DOMContentLoaded", function () {
const style = document.createElement("style");
style.innerHTML = `
.cart-toast {
position: fixed;
bottom: 25px;
right: 20px;
background: #111;
color: #fff;
padding: 14px 18px;
border-radius: 14px;
font-size: 15px;
font-weight: bold;
z-index: 999999;
box-shadow: 0 8px 25px rgba(0,0,0,0.25);
opacity: 0;
transform: translateY(20px);
transition: all 0.3s ease;
direction: rtl;
}
.cart-toast.show {
opacity: 1;
transform: translateY(0);
}
`;
document.head.appendChild(style);
function showCartToast() {
const oldToast = document.querySelector(".cart-toast");
if (oldToast) oldToast.remove();
const toast = document.createElement("div");
toast.className = "cart-toast";
toast.innerHTML = "✓ تمت إضافة المنتج إلى السلة";
document.body.appendChild(toast);
setTimeout(function () {
toast.classList.add("show");
}, 100);
setTimeout(function () {
toast.classList.remove("show");
setTimeout(function () {
toast.remove();
}, 300);
}, 2500);
}
document.addEventListener("click", function (e) {
const btn = e.target.closest("button, a");
if (!btn) return;
const text = btn.innerText.trim();
const isAddToCart =
text.includes("أضف للسلة") ||
text.includes("اضف للسلة") ||
text.includes("أضف إلى السلة") ||
text.includes("اضف إلى السلة") ||
text.includes("Add to cart");
if (!isAddToCart) return;
const originalText = btn.innerHTML;
setTimeout(function () {
showCartToast();
btn.innerHTML = "✓ تمت الإضافة";
btn.style.opacity = "0.9";
setTimeout(function () {
btn.innerHTML = originalText;
btn.style.opacity = "1";
}, 2000);
}, 300);
});
});
document.addEventListener("DOMContentLoaded", function () {
const CART_URL = "/cart";
const BRAND_COLOR = "#8B0000";
let cartCount = Number(localStorage.getItem("premiumCartCount") || 0);
const style = document.createElement("style");
style.innerHTML = `
.premium-cart-overlay {
position: fixed;
inset: 0;
background: rgba(0,0,0,0.45);
backdrop-filter: blur(7px);
z-index: 999998;
display: flex;
align-items: center;
justify-content: center;
padding: 18px;
opacity: 0;
pointer-events: none;
transition: all .35s ease;
direction: rtl;
}
.premium-cart-overlay.show {
opacity: 1;
pointer-events: auto;
}
.premium-cart-box {
width: 100%;
max-width: 390px;
background: linear-gradient(145deg, #ffffff, #f7f7f7);
border-radius: 28px;
padding: 24px;
text-align: center;
box-shadow: 0 25px 70px rgba(0,0,0,0.35);
transform: scale(.88) translateY(30px);
transition: all .35s ease;
font-family: inherit;
position: relative;
overflow: hidden;
}
.premium-cart-overlay.show .premium-cart-box {
transform: scale(1) translateY(0);
}
.premium-cart-box:before {
content: "";
position: absolute;
top: -80px;
right: -80px;
width: 180px;
height: 180px;
background: ${BRAND_COLOR};
opacity: .12;
border-radius: 50%;
}
.premium-check {
width: 72px;
height: 72px;
margin: 0 auto 14px;
border-radius: 50%;
background: ${BRAND_COLOR};
color: #fff;
display: flex;
align-items: center;
justify-content: center;
font-size: 38px;
box-shadow: 0 12px 28px rgba(139,0,0,.35);
animation: premiumPop .5s ease;
}
@keyframes premiumPop {
0% { transform: scale(.4); opacity: 0; }
70% { transform: scale(1.15); opacity: 1; }
100% { transform: scale(1); }
}
.premium-cart-title {
font-size: 22px;
font-weight: 800;
color: #111;
margin-bottom: 8px;
}
.premium-cart-product {
color: #555;
font-size: 15px;
line-height: 1.7;
margin-bottom: 18px;
}
.premium-cart-actions {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 10px;
margin-top: 16px;
}
.premium-cart-actions a,
.premium-cart-actions button {
border: none;
padding: 13px 10px;
border-radius: 16px;
font-size: 14px;
font-weight: 800;
cursor: pointer;
text-decoration: none;
font-family: inherit;
}
.premium-cart-main {
background: ${BRAND_COLOR};
color: #fff;
box-shadow: 0 8px 20px rgba(139,0,0,.25);
}
.premium-cart-secondary {
background: #eeeeee;
color: #222;
}
.premium-cart-pill {
position: fixed;
bottom: 22px;
left: 22px;
background: #111;
color: #fff;
z-index: 999997;
padding: 12px 16px;
border-radius: 999px;
display: flex;
align-items: center;
gap: 8px;
font-weight: 800;
box-shadow: 0 10px 30px rgba(0,0,0,.25);
cursor: pointer;
text-decoration: none;
direction: rtl;
font-family: inherit;
}
.premium-cart-pill span {
background: ${BRAND_COLOR};
min-width: 24px;
height: 24px;
border-radius: 50%;
display: inline-flex;
align-items: center;
justify-content: center;
font-size: 13px;
}
.premium-confetti {
position: fixed;
width: 8px;
height: 8px;
border-radius: 50%;
z-index: 1000000;
pointer-events: none;
animation: premiumConfetti .9s ease forwards;
}
@keyframes premiumConfetti {
0% {
transform: translate(0, 0) scale(1);
opacity: 1;
}
100% {
transform: translate(var(--x), var(--y)) scale(.2);
opacity: 0;
}
}
@media (max-width: 600px) {
.premium-cart-box {
border-radius: 24px;
padding: 22px;
}
.premium-cart-actions {
grid-template-columns: 1fr;
}
.premium-cart-pill {
bottom: 18px;
left: 18px;
}
}
`;
document.head.appendChild(style);
const cartPill = document.createElement("a");
cartPill.className = "premium-cart-pill";
cartPill.href = CART_URL;
cartPill.innerHTML = `السلة ${cartCount}`;
document.body.appendChild(cartPill);
function updateCartPill() {
cartPill.innerHTML = `السلة ${cartCount}`;
localStorage.setItem("premiumCartCount", cartCount);
}
function getProductName(button) {
const productArea = button.closest("section, article, .product, .product-item, .product-card, .s-product-card-entry, .container") || document.body;
const title =
productArea.querySelector("h1") ||
productArea.querySelector("h2") ||
productArea.querySelector("h3") ||
document.querySelector("h1");
return title ? title.innerText.trim() : "المنتج";
}
function launchConfetti() {
const colors = ["#8B0000", "#111111", "#D4AF37", "#ffffff"];
for (let i = 0; i < 26; i++) {
const piece = document.createElement("div");
piece.className = "premium-confetti";
piece.style.background = colors[Math.floor(Math.random() * colors.length)];
piece.style.left = "50%";
piece.style.top = "50%";
piece.style.setProperty("--x", (Math.random() * 280 - 140) + "px");
piece.style.setProperty("--y", (Math.random() * 260 - 180) + "px");
document.body.appendChild(piece);
setTimeout(function () {
piece.remove();
}, 1000);
}
}
function showPremiumCart(productName) {
const oldPopup = document.querySelector(".premium-cart-overlay");
if (oldPopup) oldPopup.remove();
const overlay = document.createElement("div");
overlay.className = "premium-cart-overlay";
overlay.innerHTML = `
✓
تمت الإضافة بنجاح
تم إضافة ${productName} إلى سلة التسوق.
تقدر تكمل التسوق أو تنتقل للسلة لإتمام الطلب.
`;
document.body.appendChild(overlay);
setTimeout(function () {
overlay.classList.add("show");
}, 50);
document.getElementById("continueShoppingPremium").onclick = function () {
overlay.classList.remove("show");
setTimeout(function () {
overlay.remove();
}, 300);
};
overlay.addEventListener("click", function (e) {
if (e.target === overlay) {
overlay.classList.remove("show");
setTimeout(function () {
overlay.remove();
}, 300);
}
});
setTimeout(function () {
if (document.body.contains(overlay)) {
overlay.classList.remove("show");
setTimeout(function () {
overlay.remove();
}, 300);
}
}, 5000);
}
document.addEventListener("click", function (e) {
const btn = e.target.closest("button, a");
if (!btn) return;
const text = btn.innerText.trim();
const isAddToCart =
text.includes("أضف للسلة") ||
text.includes("اضف للسلة") ||
text.includes("أضف إلى السلة") ||
text.includes("اضف إلى السلة") ||
text.includes("إضافة للسلة") ||
text.includes("Add to cart") ||
text.includes("Add To Cart");
if (!isAddToCart) return;
const productName = getProductName(btn);
const originalText = btn.innerHTML;
btn.innerHTML = "جاري الإضافة...";
btn.style.pointerEvents = "none";
btn.style.opacity = ".8";
setTimeout(function () {
cartCount++;
updateCartPill();
btn.innerHTML = "✓ تمت الإضافة";
btn.style.pointerEvents = "auto";
btn.style.opacity = "1";
if (navigator.vibrate) {
navigator.vibrate(60);
}
launchConfetti();
showPremiumCart(productName);
setTimeout(function () {
btn.innerHTML = originalText;
}, 1800);
}, 600);
});
});
document.addEventListener("DOMContentLoaded", function () {
const style = document.createElement("style");
style.innerHTML = `
/* تحسين جودة ووضوح صور المنتجات */
.s-product-card-image img,
.s-product-card-entry img,
salla-product-card img,
.product-card img,
.product-item img,
img[src*="products"],
img[alt*="منتج"] {
width: 100% !important;
height: auto !important;
object-fit: cover !important;
object-position: center !important;
image-rendering: auto !important;
filter: contrast(1.06) brightness(1.03) saturate(1.05) !important;
transform: translateZ(0) scale(1.01) !important;
backface-visibility: hidden !important;
-webkit-font-smoothing: antialiased !important;
transition: transform 0.35s ease, filter 0.35s ease !important;
}
/* إطار الصورة بشكل فاخر وواضح */
.s-product-card-image,
.product-card .image,
.product-item .image {
background: #f7f7f7 !important;
overflow: hidden !important;
border-radius: 18px !important;
}
/* عند المرور على المنتج */
.s-product-card-entry:hover img,
.product-card:hover img,
.product-item:hover img,
salla-product-card:hover img {
transform: translateZ(0) scale(1.04) !important;
filter: contrast(1.08) brightness(1.04) saturate(1.07) !important;
}
/* منع ظهور الصورة مشوشة أثناء التحميل */
img {
image-rendering: auto !important;
}
`;
document.head.appendChild(style);
function getBestFromSrcset(srcset) {
if (!srcset) return null;
const sources = srcset.split(",").map(function (item) {
const parts = item.trim().split(" ");
const url = parts[0];
const size = parts[1] ? parseInt(parts[1].replace("w", "")) : 0;
return { url: url, size: size };
});
sources.sort(function (a, b) {
return b.size - a.size;
});
return sources[0] ? sources[0].url : null;
}
function enhanceProductImages() {
const images = document.querySelectorAll(`
.s-product-card-image img,
.s-product-card-entry img,
salla-product-card img,
.product-card img,
.product-item img
`);
images.forEach(function (img, index) {
const bestSrc =
getBestFromSrcset(img.getAttribute("srcset")) ||
getBestFromSrcset(img.getAttribute("data-srcset")) ||
img.getAttribute("data-src") ||
img.getAttribute("data-lazy") ||
img.getAttribute("src");
if (bestSrc && img.src !== bestSrc) {
img.src = bestSrc;
}
img.setAttribute("loading", index < 6 ? "eager" : "lazy");
img.setAttribute("decoding", "async");
if (index < 6) {
img.setAttribute("fetchpriority", "high");
}
img.style.opacity = "1";
img.style.filter = "contrast(1.06) brightness(1.03) saturate(1.05)";
});
}
enhanceProductImages();
const observer = new MutationObserver(function () {
enhanceProductImages();
});
observer.observe(document.body, {
childList: true,
subtree: true
});
});
document.addEventListener("DOMContentLoaded", function () {
const BRAND_COLOR = "#8B0000";
const BOOSTER_MESSAGES = [
"هذا المنتج من الخيارات المفضلة للعملاء",
"تصميم أنيق مناسب للمناسبات الخاصة",
"تفاصيل فاخرة تضيف لمسة مميزة لإطلالتك",
"اختيار مثالي لمن تبحث عن حضور راقٍ ومختلف"
];
const TRUST_POINTS = [
"دفع آمن وموثوق",
"تجهيز سريع للطلب",
"خدمة عملاء للمساعدة",
"منتجات مختارة بعناية"
];
const style = document.createElement("style");
style.innerHTML = `
.luxury-buy-box {
margin: 18px 0;
padding: 18px;
border-radius: 22px;
background: linear-gradient(135deg, #fff, #fff7f7);
border: 1px solid rgba(139,0,0,0.14);
box-shadow: 0 10px 30px rgba(0,0,0,0.08);
direction: rtl;
font-family: inherit;
text-align: right;
}
.luxury-buy-title {
font-size: 17px;
font-weight: 900;
color: #111;
margin-bottom: 10px;
}
.luxury-buy-message {
color: ${BRAND_COLOR};
font-size: 15px;
font-weight: 800;
line-height: 1.8;
min-height: 28px;
margin-bottom: 14px;
}
.luxury-trust-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
}
.luxury-trust-item {
background: #fff;
border-radius: 14px;
padding: 10px;
font-size: 13px;
font-weight: 700;
color: #333;
box-shadow: 0 4px 14px rgba(0,0,0,0.05);
display: flex;
align-items: center;
gap: 6px;
}
.luxury-trust-item::before {
content: "✓";
background: ${BRAND_COLOR};
color: #fff;
width: 18px;
height: 18px;
border-radius: 50%;
display: inline-flex;
align-items: center;
justify-content: center;
font-size: 11px;
flex-shrink: 0;
}
.luxury-sticky-buy {
position: fixed;
left: 14px;
right: 14px;
bottom: 18px;
z-index: 999999;
background: #111;
color: #fff;
border-radius: 22px;
padding: 13px 14px;
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
direction: rtl;
font-family: inherit;
box-shadow: 0 14px 38px rgba(0,0,0,0.28);
transform: translateY(120px);
opacity: 0;
transition: all 0.35s ease;
}
.luxury-sticky-buy.show {
transform: translateY(0);
opacity: 1;
}
.luxury-sticky-text {
font-size: 14px;
font-weight: 800;
line-height: 1.5;
}
.luxury-sticky-btn {
border: none;
background: ${BRAND_COLOR};
color: #fff;
padding: 11px 16px;
border-radius: 16px;
font-weight: 900;
font-size: 14px;
cursor: pointer;
white-space: nowrap;
font-family: inherit;
box-shadow: 0 8px 20px rgba(139,0,0,0.35);
animation: luxuryPulse 1.8s infinite;
}
@keyframes luxuryPulse {
0% { transform: scale(1); }
50% { transform: scale(1.04); }
100% { transform: scale(1); }
}
.luxury-mini-popup {
position: fixed;
bottom: 95px;
right: 18px;
max-width: 320px;
background: #fff;
color: #111;
z-index: 999999;
border-radius: 18px;
padding: 14px 16px;
box-shadow: 0 12px 35px rgba(0,0,0,0.20);
direction: rtl;
font-family: inherit;
font-size: 14px;
font-weight: 800;
line-height: 1.7;
border: 1px solid rgba(139,0,0,0.12);
opacity: 0;
transform: translateY(20px);
transition: all 0.35s ease;
}
.luxury-mini-popup.show {
opacity: 1;
transform: translateY(0);
}
.luxury-mini-popup span {
color: ${BRAND_COLOR};
}
@media (max-width: 600px) {
.luxury-trust-grid {
grid-template-columns: 1fr;
}
.luxury-sticky-buy {
bottom: 14px;
border-radius: 18px;
}
.luxury-sticky-text {
font-size: 13px;
}
.luxury-sticky-btn {
font-size: 13px;
padding: 10px 13px;
}
}
`;
document.head.appendChild(style);
function findBuyButton() {
const buttons = Array.from(document.querySelectorAll("button, a"));
return buttons.find(function (btn) {
const text = btn.innerText.trim();
return (
text.includes("أضف للسلة") ||
text.includes("اضف للسلة") ||
text.includes("أضف إلى السلة") ||
text.includes("اشتري الآن") ||
text.includes("اشترِ الآن") ||
text.includes("Add to cart")
);
});
}
function createBuyBooster() {
const buyBtn = findBuyButton();
if (!buyBtn) return;
if (document.querySelector(".luxury-buy-box")) return;
const box = document.createElement("div");
box.className = "luxury-buy-box";
box.innerHTML = `
لماذا هذا المنتج اختيار مناسب؟
${BOOSTER_MESSAGES[0]}
${TRUST_POINTS.map(item => `
${item}
`).join("")}
`;
buyBtn.parentElement.appendChild(box);
let index = 0;
setInterval(function () {
index = (index + 1) % BOOSTER_MESSAGES.length;
const msg = document.getElementById("luxuryBuyMessage");
if (msg) msg.innerText = BOOSTER_MESSAGES[index];
}, 3000);
}
function createStickyBuy() {
const buyBtn = findBuyButton();
if (!buyBtn) return;
if (document.querySelector(".luxury-sticky-buy")) return;
const sticky = document.createElement("div");
sticky.className = "luxury-sticky-buy";
sticky.innerHTML = `
أعجبك المنتج؟ لا تخليه يفوتك
`;
document.body.appendChild(sticky);
const stickyBtn = sticky.querySelector(".luxury-sticky-btn");
stickyBtn.addEventListener("click", function () {
buyBtn.scrollIntoView({ behavior: "smooth", block: "center" });
setTimeout(function () {
buyBtn.click();
}, 500);
});
window.addEventListener("scroll", function () {
if (window.scrollY > 450) {
sticky.classList.add("show");
} else {
sticky.classList.remove("show");
}
});
}
function showMotivationPopup() {
if (sessionStorage.getItem("luxuryPopupShown")) return;
const popup = document.createElement("div");
popup.className = "luxury-mini-popup";
popup.innerHTML = `
اختيار ذكي — هذا المنتج يعطيك إطلالة فاخرة وتفاصيل مميزة تستحق التجربة.
`;
document.body.appendChild(popup);
setTimeout(function () {
popup.classList.add("show");
}, 300);
setTimeout(function () {
popup.classList.remove("show");
setTimeout(function () {
popup.remove();
}, 400);
}, 5500);
sessionStorage.setItem("luxuryPopupShown", "true");
}
createBuyBooster();
createStickyBuy();
setTimeout(showMotivationPopup, 9000);
const observer = new MutationObserver(function () {
createBuyBooster();
createStickyBuy();
});
observer.observe(document.body, {
childList: true,
subtree: true
});
});
const BOOSTER_MESSAGES = [
"هذا المنتج من الخيارات المفضلة للعملاء",
"تصميم أنيق مناسب للمناسبات الخاصة",
"تفاصيل فاخرة تضيف لمسة مميزة لإطلالتك",
"اختيار مثالي لمن تبحث عن حضور راقٍ ومختلف"
];
document.addEventListener("DOMContentLoaded", function () {
const CART_URL = "/cart";
const BRAND_COLOR = "#8B0000";
const style = document.createElement("style");
style.innerHTML = `
.lux-cart-confirm-overlay {
position: fixed;
inset: 0;
background: rgba(0,0,0,0.45);
backdrop-filter: blur(7px);
z-index: 999998;
display: flex;
align-items: center;
justify-content: center;
padding: 18px;
opacity: 0;
pointer-events: none;
transition: all 0.35s ease;
direction: rtl;
}
.lux-cart-confirm-overlay.show {
opacity: 1;
pointer-events: auto;
}
.lux-cart-confirm-box {
width: 100%;
max-width: 390px;
background: #fff;
border-radius: 28px;
padding: 24px;
text-align: center;
box-shadow: 0 25px 70px rgba(0,0,0,0.35);
transform: scale(.88) translateY(30px);
transition: all 0.35s ease;
font-family: inherit;
}
.lux-cart-confirm-overlay.show .lux-cart-confirm-box {
transform: scale(1) translateY(0);
}
.lux-check {
width: 72px;
height: 72px;
margin: 0 auto 14px;
border-radius: 50%;
background: ${BRAND_COLOR};
color: #fff;
display: flex;
align-items: center;
justify-content: center;
font-size: 38px;
box-shadow: 0 12px 28px rgba(139,0,0,.35);
}
.lux-cart-title {
font-size: 22px;
font-weight: 900;
color: #111;
margin-bottom: 8px;
}
.lux-cart-text {
color: #555;
font-size: 15px;
line-height: 1.8;
margin-bottom: 18px;
}
.lux-cart-actions {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 10px;
}
.lux-cart-actions a,
.lux-cart-actions button {
border: none;
padding: 13px 10px;
border-radius: 16px;
font-size: 14px;
font-weight: 900;
cursor: pointer;
text-decoration: none;
font-family: inherit;
}
.lux-cart-main {
background: ${BRAND_COLOR};
color: #fff;
}
.lux-cart-secondary {
background: #eeeeee;
color: #222;
}
@media (max-width: 600px) {
.lux-cart-actions {
grid-template-columns: 1fr;
}
}
`;
document.head.appendChild(style);
function showConfirm() {
const old = document.querySelector(".lux-cart-confirm-overlay");
if (old) old.remove();
const overlay = document.createElement("div");
overlay.className = "lux-cart-confirm-overlay";
overlay.innerHTML = `
✓
تمت الإضافة بنجاح
المنتج صار في سلة مشترياتك.
تقدر تكمل التسوق أو تنتقل للسلة لإتمام الطلب.
`;
document.body.appendChild(overlay);
setTimeout(function () {
overlay.classList.add("show");
}, 50);
document.getElementById("luxContinueShopping").onclick = function () {
overlay.classList.remove("show");
setTimeout(function () {
overlay.remove();
}, 300);
};
overlay.addEventListener("click", function (e) {
if (e.target === overlay) {
overlay.classList.remove("show");
setTimeout(function () {
overlay.remove();
}, 300);
}
});
}
document.addEventListener("click", function (e) {
const btn = e.target.closest("button, a");
if (!btn) return;
const text = btn.innerText.trim();
const isAddToCart =
text.includes("أضف للسلة") ||
text.includes("اضف للسلة") ||
text.includes("أضف إلى السلة") ||
text.includes("إضافة للسلة") ||
text.includes("Add to cart");
if (!isAddToCart) return;
setTimeout(showConfirm, 700);
});
});
document.addEventListener("DOMContentLoaded", function () {
const BRAND_COLOR = "#8B0000";
const STORAGE_KEY = "recentlyViewedProducts";
const style = document.createElement("style");
style.innerHTML = `
.recent-viewed-widget {
position: fixed;
bottom: 18px;
right: 18px;
z-index: 999998;
direction: rtl;
font-family: inherit;
}
.recent-viewed-btn {
background: #111;
color: #fff;
border: none;
border-radius: 999px;
padding: 12px 16px;
font-size: 13px;
font-weight: 900;
cursor: pointer;
box-shadow: 0 12px 32px rgba(0,0,0,0.25);
}
.recent-viewed-panel {
position: absolute;
bottom: 58px;
right: 0;
width: 290px;
background: #fff;
border-radius: 22px;
padding: 14px;
box-shadow: 0 18px 55px rgba(0,0,0,0.24);
border: 1px solid rgba(0,0,0,0.08);
opacity: 0;
pointer-events: none;
transform: translateY(15px);
transition: all 0.3s ease;
}
.recent-viewed-widget.open .recent-viewed-panel {
opacity: 1;
pointer-events: auto;
transform: translateY(0);
}
.recent-viewed-title {
font-size: 15px;
font-weight: 900;
color: #111;
margin-bottom: 10px;
}
.recent-viewed-item {
display: flex;
align-items: center;
gap: 9px;
text-decoration: none;
color: #111;
padding: 8px;
border-radius: 14px;
transition: background 0.25s ease;
}
.recent-viewed-item:hover {
background: #f7f7f7;
}
.recent-viewed-item img {
width: 52px;
height: 68px;
object-fit: cover;
border-radius: 10px;
background: #eee;
}
.recent-viewed-name {
font-size: 13px;
font-weight: 800;
line-height: 1.5;
}
.recent-viewed-empty {
font-size: 13px;
color: #777;
line-height: 1.7;
}
@media (max-width: 600px) {
.recent-viewed-widget {
right: 12px;
bottom: 12px;
}
.recent-viewed-panel {
width: 270px;
}
}
`;
document.head.appendChild(style);
function getProductInfo() {
const titleEl = document.querySelector("h1, .product-title, .s-product-title");
const imageEl = document.querySelector(".s-product-image img, .product-single img, .product img, img");
const title = titleEl ? titleEl.innerText.trim() : "";
const image = imageEl ? imageEl.src : "";
if (!title || title.length < 3) return null;
return {
title: title,
image: image,
url: window.location.href
};
}
function saveCurrentProduct() {
const product = getProductInfo();
if (!product) return;
let products = JSON.parse(localStorage.getItem(STORAGE_KEY) || "[]");
products = products.filter(function (item) {
return item.url !== product.url;
});
products.unshift(product);
products = products.slice(0, 4);
localStorage.setItem(STORAGE_KEY, JSON.stringify(products));
}
function createWidget() {
let products = JSON.parse(localStorage.getItem(STORAGE_KEY) || "[]");
const widget = document.createElement("div");
widget.className = "recent-viewed-widget";
const itemsHtml = products.length
? products.map(function (item) {
return `
${item.title}
`;
}).join("")
: `ما فيه منتجات شوهدت مؤخرًا حتى الآن.
`;
widget.innerHTML = `
`;
document.body.appendChild(widget);
widget.querySelector(".recent-viewed-btn").addEventListener("click", function () {
widget.classList.toggle("open");
});
}
saveCurrentProduct();
createWidget();
});