document.addEventListener("DOMContentLoaded", () => {
const hero = document.querySelector("section.s-block--hero-slider");
if (!hero || document.querySelector(".cfbar")) return;
const lang = document.documentElement.lang || "ar";
const isArabic = lang.toLowerCase().startsWith("ar");
const items = [
{
ar: "توصيل سريع وآمن خلال 48 ساعة",
en: "Fast Delivery",
i: "https://cdn.files.salla.network/homepage/504871843/f655cc88-2337-4790-9275-7925e58467f6.webp"
},
{
ar: "جودة أوروبية ومكونات طبيعية",
en: "EU Quality",
i: "https://static.vecteezy.com/system/resources/previews/038/339/183/non_2x/high-quality-line-icon-vector.jpg"
},
{
ar: "ضمان ذهبي واسترجاع سهل",
en: "Easy Returns",
i: "https://cdn.files.salla.network/homepage/504871843/ebdc57c8-8f3a-4439-9579-d88e4560f503.webp"
}
];
var gt = document.createElement("script");
gt.src = "//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit";
document.body.appendChild(gt);
function googleTranslateElementInit() {
new google.translate.TranslateElement({
pageLanguage: 'ar',
includedLanguages: 'en',
autoDisplay: true
}, document.body);
}
const style = document.createElement("style");
style.textContent = `
.cfbar{
display:flex;
gap:12px;
max-width:1100px;
margin:-35px auto 20px;
padding:0 12px;
position:relative;
z-index:60;
direction:${isArabic ? "rtl" : "ltr"};
}
.cfbar a{
flex:1;
background:#fff;
border-radius:4px;
padding:18px 10px;
text-align:center;
text-decoration:none;
color:#111;
box-shadow:0 2px 8px rgba(0,0,0,.08);
font-size:12px;
font-weight:600;
display:flex;
flex-direction:column;
align-items:center;
justify-content:center;
}
.cfbar img{
width:32px;
height:32px;
object-fit:contain;
margin-bottom:8px;
display:block;
}
@media (min-width: 992px){
.cfbar a div{
white-space: nowrap;
}
}
`;
document.head.appendChild(style);
const bar = document.createElement("div");
bar.className = "cfbar";
bar.innerHTML = items.map(x =>
`
${isArabic ? x.ar : x.en}
`
).join("");
hero.insertAdjacentElement("afterend", bar);
});
document.addEventListener("DOMContentLoaded", () => {
// ✅ هنا التعديل المهم
const faqSection = document.querySelector("section.s-block--faq.s-block-16");
if (!faqSection) return;
const branches = [
{ name: "القصر مول", map: "https://www.google.com/maps?q=Sir%20Francis%20Qasr%20Mall&output=embed" },
{ name: "النخيل مول", map: "https://www.google.com/maps?q=Sir%20Francis%20Nakheel%20Mall&output=embed" },
{ name: "واجهة روشن", map: "https://www.google.com/maps?q=Sir%20Francis%20Riyadh%20Front&output=embed" }
];
const section = document.createElement("section");
section.style.marginTop = "60px";
section.innerHTML = `
زورنا في أقرب فرع
اختر الفرع الأقرب لك واستمتع بتجربة سير فرانسيس
`;
const tabs = section.querySelector(".tabs");
const iframe = section.querySelector("iframe");
branches.forEach((b, i) => {
const btn = document.createElement("button");
btn.type = "button";
btn.textContent = b.name;
btn.style.cssText = `
padding:11px 26px;
border-radius:999px;
border:1px solid #ddd;
background:${i === 0 ? "#000" : "#fff"};
color:${i === 0 ? "#fff" : "#000"};
cursor:pointer;
font-weight:700;
transition:.3s;
`;
btn.onclick = () => {
tabs.querySelectorAll("button").forEach(el => {
el.style.background = "#fff";
el.style.color = "#000";
});
btn.style.background = "#000";
btn.style.color = "#fff";
iframe.src = b.map;
};
tabs.appendChild(btn);
if (i === 0) iframe.src = b.map;
});
// ✅ الآن سيتم إدراجه تحت FAQ رقم 22 مباشرة
faqSection.insertAdjacentElement("afterend", section);
});
document.addEventListener("DOMContentLoaded", () => {
if (!window.location.pathname.includes("/cart")) return;
const section = document.createElement("div");
section.id = "checkout-products-section";
section.innerHTML = `
اختيارات رائعة قبل اتمام طلبك
`;
const placeSection = () => {
const target = window.innerWidth <= 768
? document.querySelector("#free-shipping")
: document.querySelector("footer.store-footer");
if (target && !document.getElementById("checkout-products-section")) {
target.parentNode.insertBefore(section, target);
}
};
placeSection();
window.addEventListener("resize", placeSection);
section.addEventListener("click", e => {
const btn = e.target.closest("salla-add-product-button");
if (btn) setTimeout(() => location.reload(), 800);
});
});
document.querySelectorAll(".s-block__title h2").forEach(h2 => {
if (h2.textContent.trim() === "-" || h2.textContent.trim() === "") {
h2.closest(".s-block__title").style.display = "none";
}
});
(() => {
if (innerWidth > 768) return;
if (document.querySelector(".mf")) return;
const desc = document.querySelector(".product__description");
if (!desc) return;
desc.insertAdjacentHTML(
"afterbegin",
`
ضمان ذهبي
إسترجاع خلال 7 أيام
توصيل اكسبريس
التوصيل السريع لمدينة الرياض
طرق دفع متعددة
مدى، فيزا، دفع عند الاستلام
`
);
})();
(() => {
const STYLE_ID = "lv-installment-style";
const getPrice = () => {
const p =
document.querySelector("salla-installment[price]")?.getAttribute("price") ||
document.querySelector("salla-add-product-button[amount]")?.getAttribute("amount") ||
document.querySelector(".flex.whitespace-nowrap h2, .flex.whitespace-nowrap h4")?.textContent ||
document.querySelector("h2.total-price, .price-wrapper .total-price, h4.text-black.font-black")?.textContent ||
"";
return Number(String(p).match(/[\d.]+/g)?.join("") || 0) || 0;
};
const run = () => {
if (document.querySelector(".installment-box")) return;
const mf = document.querySelector(".mf");
const price = getPrice();
if (!mf || !price) return;
mf.insertAdjacentHTML(
"afterend",
`
قسمها إلى 4 دفعات متساوية بقيمة
${(price / 4).toFixed(2)} ر.س مع
أو
`
);
if (!document.getElementById(STYLE_ID)) {
document.head.insertAdjacentHTML(
"beforeend",
``
);
}
};
window.addEventListener("load", run, { once: true });
setTimeout(run, 500);
})();
// ====== إضافة ستايل تلقائي ======
const style = document.createElement("style");
style.innerHTML = `
.faq-content{
background:#f8f8f8;
padding:20px;
margin-top:12px;
border-radius:10px;
line-height:2;
}
.faq-row{
display:flex;
gap:14px;
margin-bottom:22px;
align-items:flex-start;
}
.faq-icon{
width:28px;
height:28px;
stroke:#000;
stroke-width:2;
fill:none;
flex-shrink:0;
margin-top:4px;
}
.faq-row b{
display:block;
font-size:16px;
margin-bottom:4px;
}
.faq-row p{
margin:0;
font-size:14px;
color:#555;
}
`;
document.head.appendChild(style);
// ====== أيقونات SVG ======
function iconAward(){
return ``;
}
function iconLeaf(){
return ``;
}
function iconClock(){
return ``;
}
function iconRefresh(){
return ``;
}
function iconTruck(){
return ``;
}
// ====== تشغيل FAQ ======
document.querySelectorAll(".pp-feature__item").forEach(item => {
item.addEventListener("click", () => {
const next = item.nextElementSibling;
// لو المحتوى موجود نحذفه (toggle)
if (next && next.classList.contains("faq-content")) {
next.remove();
return;
}
const content = document.createElement("div");
content.className = "faq-content";
content.innerHTML = `
1. جودة أوروبية بسعر مثالي
منتجاتنا بتصميم أوروبي ومعايير تصنيع عالمية.
2. ما هي المكونات المستخدمة؟
من أجود الزيوت الطبيعية بعناية فائقة.
3. ثبات يدوم ولمسة فاخرة
مصممة لتدوم طويلًا طوال اليوم.
4. ضمان تجربة 7 أيام
تقدر تجرب وإذا ما ناسبك الاسترجاع متاح.
5. الشحن والتوصيل
السعودية (الرياض – جدة – الدمام): خلال 48 ساعة
باقي المدن: 2 إلى 5 أيام عمل
دول الخليج: 2 - 4 أيام
`;
item.after(content);
});
});
document.querySelectorAll(".pp-feature__item").forEach(item => { if (item.innerText.includes("الأسئلة الشائعة")) item.classList.add("faq-arrow"); });
// ====== إضافة سهم لقسم الأسئلة ======
document.querySelectorAll(".pp-feature__item").forEach(item => {
if (item.innerText.includes("الأسئلة الشائعة")){
item.style.cursor = "pointer";
}
});
document.addEventListener("DOMContentLoaded", () => {
// للجوال فقط
if (window.innerWidth > 768) return;
const videos = {
"/onXOAgQ": "https://i.top4top.io/m_3596sn81e1.mp4",
"/EXqQBqQ": "https://b.top4top.io/m_3596gduwo1.mp4",
"/RAnbeGV": "https://e.top4top.io/m_3596smodu1.mp4",
"/nEXxVOb": "https://b.top4top.io/m_3596xry4g1.mp4",
"/vAXVOny": "https://j.top4top.io/m_3596032k31.mp4",
"/wWrqVen": "https://k.top4top.io/m_359617xqp1.mp4"
};
// يحدد الفيديو حسب الرابط
let chosenSrc = null;
for (const [path, src] of Object.entries(videos)) {
if (location.href.includes(path)) {
chosenSrc = src;
break;
}
}
if (!chosenSrc) return;
const videoHTML = (src) => `
`;
const tryInsert = () => {
const container = document.querySelector("article#more-content"); // أو "#more-content"
if (!container) return false;
// منع التكرار
if (container.querySelector(".mobile-product-video")) return true;
container.insertAdjacentHTML("afterbegin", videoHTML(chosenSrc));
return true;
};
// محاولة مباشرة
if (tryInsert()) return;
// لو المحتوى يتأخر بالتحميل
const obs = new MutationObserver(() => {
if (tryInsert()) obs.disconnect();
});
obs.observe(document.documentElement, { childList: true, subtree: true });
});
document.addEventListener("DOMContentLoaded", function () {
var free = document.getElementById("free-shipping");
var target = document.querySelector(".pt-5.flex.flex-col.items-start.lg\\:flex-row.pb-6.lg\\:pb-20");
var msg = document.getElementById("free-shipping-msg");
if (free) {
free.style.display = "block";
free.style.visibility = "visible";
free.classList.remove("hidden", "lg:hidden", "md:hidden");
}
if (free && target) {
target.before(free);
}
if (msg) {
msg.innerHTML = 'احصل على شحن مجاني عند إضافة 350 للسلة';
}
});
document.getElementById('cart-button').onclick = () => location.assign('/ar/cart');