/* Add custom Js styles below */
/*
=======================================
0) Instagram Feed Injection + Custom Header
=======================================
- Injects Elfsight feed after .itsak-compare inside a wrapper
- Loads platform.js once
- Removes default Elfsight header and adds a custom CTA button
- Safe selectors (no invalid querySelector), lightweight observers
*/
/* ---------- 0) تحديث محتوى الفوتر ---------- */
(function () {
// تحقق من لغة الصفحة - تنفيذ الكود فقط عندما تكون اللغة الإنجليزية
if (document.documentElement.lang === "en") {
console.log("[itsak-ig] Skipping injection: page language is not English");
return; // الخروج من الدالة إذا لم تكن اللغة الإنجليزية
}
function updateFooter() {
const footerInner = document.querySelector(".store-footer__inner");
if (!footerInner) return;
const footerContent = `
اكتشف منتجات هاي سمايل الأصلية من الوكيل الحصري في الشرق الأوسط ✨
منتجات تبييض أسنان، شرائط PAP+ المبتكرة، ومنتجات العناية اليومية بالفم. جميعها آمنة على مينا الأسنان وتمنحك ابتسامة أكثر بياضًا وصحة
`;
const css = `
.gfa-content__button-container.${BTN_CLASS}{
width:auto;display:flex;justify-content:center;align-items:center;
margin:20px 0;
}
.gfa-content__button.${BTN_CLASS}{
display:flex;flex-flow:row nowrap;justify-content:center;align-items:center;
text-decoration:none !important;text-align:center;cursor:pointer;
transition:color .2s ease, background-color .2s ease, border-color .2s ease, opacity .2s ease;
font-size:17px;font-weight:600;color:#eb0a8b !important;box-sizing:border-box;
padding:18px 36px;margin:12px 0 0;background-color:transparent;border:1px solid rgba(235,10,139,.35);
width:auto;text-transform:uppercase;letter-spacing:0;border-radius:12px;
font-family:"Cairo", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji";
}
.gfa-content__button.${BTN_CLASS}:hover{
background-color: rgba(235,10,139,.08);
color:#eb0a8b !important;
border-color: rgba(235,10,139,.55);
text-decoration:none !important;
opacity:1;
}
@media (max-width:768px){
.gfa-content__button.${BTN_CLASS}{font-size:13px;letter-spacing:0;padding:14px 28px;margin:8px 0 0}
}`;
function ensureStyle() {
if (!document.getElementById(STYLE_ID)) {
const s = document.createElement("style");
s.id = STYLE_ID;
s.textContent = css;
document.head.appendChild(s);
}
}
function replaceHeader(appRoot) {
const header = appRoot.querySelector(HEADER_SELECTOR);
if (!header) return;
// لا تكرر الزر
if (appRoot.querySelector(`.${BTN_CLASS}.gfa-content__button`)) return;
header.remove();
const wrapper = document.createElement("div");
wrapper.innerHTML = btnHTML;
const node = wrapper.firstElementChild;
// ضع الزر أعلى الفيد
if (appRoot.firstElementChild) {
appRoot.insertBefore(node, appRoot.firstElementChild);
} else {
appRoot.appendChild(node);
}
}
function init() {
ensureStyle();
const tryReplace = () => {
const root = document.querySelector(APP_SELECTOR);
if (root) replaceHeader(root);
};
// محاولة أولى
tryReplace();
// راقب إعادة رسم Elfsight (خفيف)
const obs = new MutationObserver(() => {
// throttle بسيط
requestAnimationFrame(tryReplace);
});
obs.observe(document.body, { childList: true, subtree: true });
}
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", init);
} else {
init();
}
})();
/*
=======================================
1) itsak-qa (CSS tweaks for FAQ section)
=======================================
*/
(function () {
const css = `
/* Put title and FAQ list on the same row */
.itsak-qa .container{
display:grid !important;
grid-template-columns:minmax(0,1fr) minmax(0,1fr) !important; /* title | list */
gap:1.5rem !important;
align-items:center!important;
}
/* Mobile: stack as usual */
@media (max-width: 768px){
.itsak-qa .container{ display:block !important; }
}
/* Title: align to start (RTL-aware) and remove centering widths/margins */
.itsak-qa .home-block-title{ margin-inline:0 !important; }
.itsak-qa .home-block-title .text-center{ text-align:center!important; }
.itsak-qa .home-block-title .max-w-2xl{ max-width:100% !important; margin-inline:0 !important; }
.itsak-qa .home-block-title .home-block-line{ margin-inline:0 !important; }
/* FAQ list: single column only */
.itsak-qa .grid.items-start{ grid-template-columns:1fr !important; }
.itsak-qa .grid.items-start > .single-faq{ width:100% !important; }
`;
const s = document.createElement("style");
s.textContent = css;
document.head.appendChild(s);
})();
/*
=======================================
2) Salla slider videos (replace images with videos)
=======================================
*/
/* Salla: swap rectangular-links images with videos + smaller height */
/* Minimal: swap slider images to videos (Salla) */
/* Minimal: swap slider images to videos (Salla) */
/* Force videos to be muted + play (Salla slider fix) */ /* Salla slider: hide images + inject videos (super simple + robust) */
/* Replace each rectangular-links image wrapper with a video (muted/auto) */
/* Replace each rectangular-links image wrapper with a video (muted/auto) */
(function () {
const SECTION = ".itsak-videos";
const SOURCES = [
"https://itsak.tech/hismaile-client-1.mp4",
"https://itsak.tech/hismaile-client-2.mp4",
"https://itsak.tech/hismaile-client-3.mp4",
"https://itsak.tech/hismaile-client-4.mp4",
"https://itsak.tech/hismaile-client-5.mp4",
"https://itsak.tech/hismaile-client-6.mp4",
];
// Hide any leftover just in case
const style = document.createElement("style");
style.textContent = `
${SECTION} .swiper-slide img,
${SECTION} .swiper-slide picture { display: none !important; }
${SECTION} .swiper-slide video {
width: auto !important;
display: block;
margin: 0 auto;
object-fit: contain;
border-radius: .375rem;
}
@media (min-width: 768px){ ${SECTION} .swiper-slide video { } }
`;
document.head.appendChild(style);
function swap() {
const slides = document.querySelectorAll(`${SECTION} .swiper-slide`);
if (!slides.length) return;
slides.forEach((slide, i) => {
if (slide.dataset.vdone === "1") return;
const img = slide.querySelector("img");
if (!img) return;
// find the inner wrapper that currently holds the image
const box =
slide.querySelector(".overflow-hidden.rounded-md.w-fit.mx-auto") ||
img.parentElement ||
slide;
// build the video
const v = document.createElement("video");
v.src = SOURCES[i % SOURCES.length];
v.poster =
img.currentSrc || img.src || img.getAttribute("data-src") || "";
v.muted = true;
v.defaultMuted = true;
v.setAttribute("muted", "");
v.autoplay = true;
v.loop = true;
v.playsInline = true;
v.setAttribute("playsinline", "");
v.setAttribute("webkit-playsinline", "");
v.preload = "metadata";
v.className =
(img.className || "").replace("lazy", "").trim() ||
"mx-auto object-contain rounded-md";
// hard replace the image wrapper contents so video is the ONLY child
box.innerHTML = "";
box.appendChild(v);
// force playback
v.load();
const p = v.play();
if (p && p.catch)
p.catch(() => {
/* ignore autoplay promise errors */
});
slide.dataset.vdone = "1";
});
}
function boot() {
// run now and a few retries for hydration
let n = 0;
const t = setInterval(() => {
swap();
if (++n > 20) clearInterval(t);
}, 400);
swap();
// if Salla re-renders the slider, re-run
const sec = document.querySelector(SECTION);
if (sec) {
new MutationObserver(swap).observe(sec, {
childList: true,
subtree: true,
});
}
// any user interaction helps iOS to start playback
document.addEventListener("click", swap, { passive: true });
}
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", boot);
} else {
boot();
}
})();
/* ============================
Inject Full-Width Animated Wave Above Footer (Continuous Motion)
============================ */
/* ============================
Inject Full-Width Wavy Animation Above Footer (Smooth Back & Forth)
============================ */
(function () {
const FOOTER = document.querySelector(".store-footer");
if (!FOOTER) return;
// CSS
const css = `
.footer-waves {
position: absolute;
top: -100px;
left: 0;
width: 100%;
height: 100px;
overflow: hidden;
line-height: 0;
z-index: 1;
}
.store-footer { position: relative; z-index: 2; }
.footer-waves svg {
display: block;
position: absolute;
top: 0;
left: 0;
width: 200%;
height: 100%;
fill: #eb0a8b;
}
/* حركة متناسقة ذهاب وإياب */
.footer-waves .wave-1 {
animation: wave-bounce 10s ease-in-out infinite;
opacity: 0.9;
}
.footer-waves .wave-2 {
animation: wave-bounce 14s ease-in-out infinite reverse;
opacity: 0.5;
}
@keyframes wave-bounce {
0% { transform: translateX(0); }
50% { transform: translateX(-25%); }
100% { transform: translateX(0); }
}
`;
if (!document.getElementById("footer-waves-style")) {
const style = document.createElement("style");
style.id = "footer-waves-style";
style.textContent = css;
document.head.appendChild(style);
}
// HTML for waves
const waves = document.createElement("div");
waves.className = "footer-waves";
waves.setAttribute("aria-hidden", "true");
waves.innerHTML = `
`;
FOOTER.prepend(waves);
})();
// change the link of the product
/* itsak.tech – Edit product-card buttons text/background */
/* itsak.tech – Edit product-card buttons text/background + title-based override */
(function () {
const BLUE = "#027bff";
// بطاقات خاصة: يبقى نصها الافتراضي "اختار نكهتك"
const SPECIAL_IDS = new Set([
"product-1342743225",
"product-1722992968",
"product-1922692717",
"product-1021806212",
"product-1160025951",
"product-1765727560",
"product-1400236606", // NEW: أضفناها لقائمة الخاصّة
"product-658415472",
]);
// NEW: تسميات مخصّصة لكل بطاقة (إن وُجدت تتقدم على أي منطق آخر)
const CUSTOM_LABELS = {
"product-1400236606": "اختر لونك", // المطلوب
"product-1821947049": "اختر لونك", // المطلوب
"product-1021806212": "اختر لونك", // المطلوب
"product-1722992968": "اختر لونك", // المطلوب
};
const LABEL_SPECIAL = "اختر نكهتك";
const LABEL_OPTIONS = "حدد اختيارك";
const LABEL_DESIGN = "صمم مجموعتك";
// localization helper: return English labels when page lang starts with 'en'
function localizeLabel(arLabel) {
try {
const lang = (document.documentElement.lang || "").toLowerCase();
if (lang.startsWith("en")) {
switch (arLabel) {
case LABEL_SPECIAL:
return "Choose flavor";
case LABEL_OPTIONS:
return "Select option";
case LABEL_DESIGN:
return "Design set";
case "اختر لونك":
return "Choose color";
default:
return arLabel;
}
}
} catch (e) {
/* ignore */
}
return arLabel;
}
const TITLE_OVERRIDES = [
"مجموعة الفرشاة والتذوق",
"مجموعة التبييض والتفتيح الفوري",
"عرض سيروم تصحيح اللون V34",
"مجموعة المعاجين ( ٤ معاجين)",
];
const normalize = (s) =>
(s || "")
.replace(/\s+/g, " ")
.replace(/\u200f|\u200e/g, "")
.trim();
const normalizedTitles = TITLE_OVERRIDES.map(normalize);
const onReady = (fn) =>
document.readyState === "loading"
? document.addEventListener("DOMContentLoaded", fn)
: fn();
function setButtonLabel(btn, label) {
const textSpan = btn.querySelector(".s-button-text");
const enhancedLabel = btn.querySelector(".enhanced-label");
if (enhancedLabel) {
enhancedLabel.textContent = " " + label + " ";
return;
}
if (textSpan) {
const icons = Array.from(textSpan.querySelectorAll("i"));
textSpan.textContent = " " + label;
if (icons.length) {
icons.reverse().forEach((ic) => {
textSpan.prepend(ic);
textSpan.prepend(" ");
});
}
return;
}
btn.textContent = label;
}
function paintButton(btn, color) {
btn.style.setProperty("background-color", color, "important");
btn.style.setProperty("color", "#fff", "important");
btn.style.setProperty("border-color", color, "important");
const host = btn.closest(".s-button-element") || btn.parentElement;
if (host) {
host.style.setProperty("--primary", color, "important");
host.style.setProperty("--salla-primary", color, "important");
host.style.setProperty("background-color", color, "important");
host.style.setProperty("color", "#fff", "important");
host.style.setProperty("border-color", color, "important");
}
}
function cardHasOptions(card) {
return !!card.querySelector(".s-product-options-option-container");
}
function hideOptions(card) {
const options = card.querySelector(".product-options");
if (options) {
options.style.display = "none";
options.style.visibility = "hidden";
options.style.opacity = "0";
options.style.height = "0";
options.style.margin = "0";
options.style.padding = "0";
}
}
function titleMatchesOverride(card) {
const titleEl =
card.querySelector(".product-card__title a") ||
card.querySelector(".product-card__title");
if (!titleEl) return false;
const current = normalize(titleEl.textContent);
if (!current) return false;
return normalizedTitles.some((t) => current === t || current.includes(t));
}
function updateCard(card) {
const cardId = card.id || "";
const isSpecial = SPECIAL_IDS.has(cardId);
const hasOptions = cardHasOptions(card);
const isTitleOverride = titleMatchesOverride(card);
// لو ليس خاصًا ولا فيه خيارات ولا يطابق العناوين — لا نلمسه
if (!isSpecial && !hasOptions && !isTitleOverride) return;
// إخفِ الخيارات إن وُجدت
if (hasOptions) hideOptions(card);
// تحديد نص الزر حسب الأولوية:
// 0) NEW: وسم مخصّص بالـ ID
// 1) عنوان ضمن القائمة -> "صمم مجموعتك"
// 2) بطاقة خاصة -> "اختار نكهتك"
// 3) أي بطاقة فيها خيارات -> "حدد اختيارك"
let targetLabel = LABEL_OPTIONS;
if (CUSTOM_LABELS[cardId]) {
targetLabel = CUSTOM_LABELS[cardId]; // NEW: يتقدم على الباقي
} else if (isTitleOverride) {
targetLabel = LABEL_DESIGN;
} else if (isSpecial) {
targetLabel = LABEL_SPECIAL;
}
// apply localization
targetLabel = localizeLabel(targetLabel);
const buttons = card.querySelectorAll(
".product-card__normal-cart button, \
.product-card__enhanced-mini-cart button, \
.addToCart button, \
salla-add-product-button button"
);
buttons.forEach((btn) => {
setButtonLabel(btn, targetLabel);
paintButton(btn, BLUE);
});
}
function updateAll() {
document
.querySelectorAll("custom-salla-product-card.product-card")
.forEach(updateCard);
}
onReady(() => {
updateAll();
const obs = new MutationObserver((muts) => {
for (const m of muts) {
m.addedNodes.forEach((node) => {
if (!(node instanceof Element)) return;
if (node.matches?.("custom-salla-product-card.product-card"))
updateCard(node);
node
.querySelectorAll?.("custom-salla-product-card.product-card")
.forEach(updateCard);
});
}
});
obs.observe(document.body, { childList: true, subtree: true });
let retries = 0;
const tick = () => {
updateAll();
if (++retries < 12) setTimeout(tick, 500);
};
tick();
});
})();
//change the link of the product
(function () {
"use strict";
/* عدّل IDs هنا */
const TARGET_IDS = [
1160025951, 1400236606, 1765727560, 1342743225, 1722992968, 1922692717,
1021806212, 658415472, 1821947049,
]; // أضف: 1400236606, 1765727560, ...
// مساعد: يجلب كارد المنتج من أي عنصر داخله
function getCard(el) {
return el.closest(
"custom-salla-product-card, .product-card, [id^='product-']"
);
}
// مساعد: يستخرج product-id من الكارد
function getPid(card) {
if (!card) return null;
const idAttr = card.getAttribute("id") || "";
const m = idAttr.match(/product-(\d+)/);
if (m && m[1]) return m[1];
const inner = card.querySelector("[product-id]");
return inner ? inner.getAttribute("product-id") : null;
}
// مساعد: رابط المنتج من الصورة أو العنوان
function getProductUrl(card) {
const a1 = card.querySelector(".product-card__image a[href]");
const a2 = card.querySelector(".product-card__title a[href]");
return (a1 && a1.href) || (a2 && a2.href) || null;
}
// هل الكارد ضمن IDs المطلوبة؟
function isTarget(card) {
const pid = getPid(card);
return (
pid &&
(TARGET_IDS.includes(Number(pid)) || TARGET_IDS.includes(String(pid)))
);
}
// التفويض: أي ضغطة على زر الإضافة في الكارد المستهدف → ننتقل للرابط
const ADD_BTN_SELECTOR = [
"salla-add-product-button button",
".addToCart__btn button",
".product-card__normal-cart__btn button",
".product-card__enhanced-mini-cart button",
".addToCart button",
'button[aria-label="Add to cart button"]',
].join(",");
document.addEventListener(
"click",
function (e) {
const btn = e.target.closest?.(ADD_BTN_SELECTOR);
if (!btn) return;
const card = getCard(btn);
if (!card || !isTarget(card)) return;
// لا نلمس المفضلة/العرض السريع
if (e.target.closest(".wishlist, .quickview-btn")) return;
const url = getProductUrl(card);
if (!url) return;
// فتح بنفس النافذة أو تبويب جديد عند Ctrl/⌘ أو mid-click
e.preventDefault();
e.stopPropagation();
if (e.metaKey || e.ctrlKey || e.button === 1) {
window.open(url, "_blank");
} else {
window.location.href = url;
}
},
{ capture: true }
);
// دعم عناصر تُحمّل لاحقًا (اختياري لكن مفيد)
const obs = new MutationObserver(() => {
/* لا حاجة لأي شيء هنا لأننا نستخدم التفويض */
});
obs.observe(document.documentElement, { childList: true, subtree: true });
})();
(function () {
const MARK = "iconWithTextInjected";
// localization helper
function getLocalizedText() {
try {
const lang = (document.documentElement.lang || "").toLowerCase();
if (lang.startsWith("en")) {
return {
secure: "Secure Payment",
customers: "150K+ Satisfied Customers",
};
}
} catch (e) {
/* ignore */
}
return {
secure: "دفع آمن",
customers: "150K+ عميل راضٍ",
};
}
function getHTML() {
const texts = getLocalizedText();
return `
${texts.secure}
${texts.customers}
`;
}
const onReady = (fn) =>
document.readyState === "loading"
? document.addEventListener("DOMContentLoaded", fn)
: fn();
function inject() {
// ابحث عن عمود معلومات المنتج
const info = document.querySelector(".product-single__info");
if (!info) return;
// لا نكرر الإدراج
if (info.dataset[MARK]) return;
// ابحث عن عنوان المنتج
const h1 = info.querySelector("h1");
if (!h1) return;
// أنشئ العنصر وأدرجه قبل العنوان مباشرة
const wrapper = document.createElement("div");
wrapper.className = "hi-icons-wrapper";
wrapper.innerHTML = getHTML();
h1.parentNode.insertBefore(wrapper, h1);
// علّم أننا حقناّ القسم
info.dataset[MARK] = "1";
}
onReady(() => {
inject();
// في حال سلة تعمل Hydration متأخر، راقب DOM لأي تغييرات وأعد المحاولة عند الحاجة
const mo = new MutationObserver(() => inject());
mo.observe(document.body, { childList: true, subtree: true });
// ريترايز خفيفة بعد التحميل
let tries = 0;
(function tick() {
inject();
if (++tries < 10) setTimeout(tick, 400);
})();
});
})();
(function () {
// localization helper for review text
function getReviewText() {
try {
const lang = (document.documentElement.lang || "").toLowerCase();
if (lang.startsWith("en")) {
return "4.7 out of 5 based on over 1,766 reviews.";
}
} catch (e) {
/* ignore */
}
return "٤٫٧ من ٥ بناءً على أكثر من ١٧٦٦ تقييمًا.";
}
function getReviewHTML() {
const reviewText = getReviewText();
return `
${reviewText}
`;
}
document.addEventListener("DOMContentLoaded", () => {
const iconsSection = document.querySelector(".icon-with-text");
if (iconsSection) {
iconsSection.insertAdjacentHTML("afterend", getReviewHTML());
}
});
})();
/* itsak.tech – Force blue button + per-title labels */
/* itsak.tech – Force blue button + per-title labels */
(function () {
const BLUE = "#027bff";
// النص الافتراضي
const LABEL_DEFAULT = "حدد اختيارك";
// localization helper for second block
function localizeLabel(arLabel) {
try {
const lang = (document.documentElement.lang || "").toLowerCase();
if (lang.startsWith("en")) {
switch (arLabel) {
case "اختر نكهتك":
return "Choose your flavor";
case "اختر لونك":
return "Choose your color";
case "حدد اختيارك":
return "Select your option";
default:
return arLabel;
}
}
} catch (e) {
/* ignore */
}
return arLabel;
}
// جدول المطابقة بحسب العنوان (تطابق تام بعد التطبيع)
const TITLE_LABEL_MAP = new Map([
["معجون أسنان", "اختر نكهتك"],
["مرطب الشفاه", "اختر نكهتك"],
["مجموعة العناية اليومية", "اختر نكهتك"],
["مجموعة المعاجين", "اختر نكهتك"],
["فرشاة الأسنان الكهربائية", "اختر لونك"],
["رؤوس بديلة لفرشاة الأسنان", "اختر لونك"],
["مجموعة فرّش و تذوق", "اختر لونك"],
]);
// عناوين تظل بالأزرق لكن تستخدم النص الافتراضي
const TITLES_BLUE_WITH_DEFAULT = new Set(["رؤوس بديلة لفرشاة الأسنان"]);
const normalize = (s) =>
(s || "")
.replace(/\s+/g, " ")
.replace(/\u200f|\u200e/g, "")
.trim();
function setButtonLabel(btn, label) {
const textSpan = btn.querySelector(".s-button-text");
const enhancedLabel = btn.querySelector(".enhanced-label");
if (enhancedLabel) {
enhancedLabel.textContent = " " + label + " ";
return;
}
if (textSpan) {
const icons = Array.from(textSpan.querySelectorAll("i"));
textSpan.textContent = " " + label;
if (icons.length) {
icons.reverse().forEach((ic) => {
textSpan.prepend(ic);
textSpan.prepend(" ");
});
}
return;
}
btn.textContent = label;
}
function paintButton(btn, color) {
btn.style.setProperty("background-color", color, "important");
btn.style.setProperty("color", "#fff", "important");
btn.style.setProperty("border-color", color, "important");
const host = btn.closest(".s-button-element") || btn.parentElement;
if (host) {
host.style.setProperty("--primary", color, "important");
host.style.setProperty("--salla-primary", color, "important");
host.style.setProperty("background-color", color, "important");
host.style.setProperty("color", "#fff", "important");
host.style.setProperty("border-color", color, "important");
}
}
function applyOnButtons(scope, label) {
// localize label based on page lang
label = localizeLabel(label);
const buttons = scope.querySelectorAll(
".product-card__normal-cart button, \
.product-card__enhanced-mini-cart button, \
.addToCart button, \
salla-add-product-button button, \
.sticky-product-bar button.s-button-element"
);
buttons.forEach((btn) => {
setButtonLabel(btn, label);
paintButton(btn, BLUE);
});
}
function tweakCard(card) {
const titleEl =
card.querySelector(".product-card__title a") ||
card.querySelector(".product-card__title");
if (!titleEl) return;
const title = normalize(titleEl.textContent);
let matched = false;
// لو العنوان موجود بالخريطة
for (const [k, v] of TITLE_LABEL_MAP.entries()) {
if (title === normalize(k)) {
applyOnButtons(card, v);
matched = true;
break;
}
}
// لو ما تطابق ومع ذلك ضمن قائمة الافتراضي
if (!matched) {
for (const k of TITLES_BLUE_WITH_DEFAULT) {
if (title === normalize(k)) {
applyOnButtons(card, LABEL_DEFAULT);
matched = true;
break;
}
}
}
}
function tweakPDP() {
const h1 =
document.querySelector(".product-single__info h1") ||
document.querySelector("h1.product-title") ||
document.querySelector(".product-single__info h1.text-xl");
if (!h1) return;
const title = normalize(h1.textContent);
let label = null;
for (const [k, v] of TITLE_LABEL_MAP.entries()) {
if (title === normalize(k)) {
label = v;
break;
}
}
if (!label) {
for (const k of TITLES_BLUE_WITH_DEFAULT) {
if (title === normalize(k)) {
label = LABEL_DEFAULT;
break;
}
}
}
if (!label) return;
applyOnButtons(document, label);
}
function runAll() {
document
.querySelectorAll("custom-salla-product-card.product-card")
.forEach(tweakCard);
tweakPDP();
}
const onReady = (fn) =>
document.readyState === "loading"
? document.addEventListener("DOMContentLoaded", fn)
: fn();
onReady(() => {
runAll();
const obs = new MutationObserver((muts) => {
for (const m of muts) {
m.addedNodes.forEach((node) => {
if (!(node instanceof Element)) return;
if (node.matches?.("custom-salla-product-card.product-card")) {
tweakCard(node);
}
node
.querySelectorAll?.("custom-salla-product-card.product-card")
.forEach(tweakCard);
if (
node.matches?.(
".product-single__info, form.product-form, .sticky-product-bar"
) ||
node.querySelector?.(
".product-single__info, form.product-form, .sticky-product-bar"
)
) {
tweakPDP();
}
});
}
});
obs.observe(document.body, { childList: true, subtree: true });
let tries = 0;
const iv = setInterval(() => {
runAll();
if (++tries >= 40) clearInterval(iv);
}, 500);
document.addEventListener("visibilitychange", () => {
if (!document.hidden) runAll();
});
});
})();
/////////////////////
//header nav
(function () {
"use strict";
// لا تُظهر عنصر "اعرف المزيد" على الديسكتوب إذا كانت اللغة إنجليزية
try {
const lang = (document.documentElement.lang || "").toLowerCase();
if (lang.startsWith("en")) return;
} catch (e) {
/* ignore */
}
const STYLE_ID = "nav-know-more-style";
const NEW_ID = "nav-know-more";
const SHOP_ID = "410510705"; // id عنصر "تسوق"
const SAVE_ID = "295466722"; // id عنصر "اجمع ووفر"
const CSS = `
@media (min-width:1024px){
#${NEW_ID}.has-children{ position:relative; }
#${NEW_ID} > a{ display:inline-flex; align-items:center; gap:.35rem; }
#${NEW_ID} .sub-menu{ display:none; position:absolute; inset-inline-start:0; top:100%; z-index:60; margin-top:-8px; }
#${NEW_ID}:hover .sub-menu{ display:block; }
#${NEW_ID} .sub-menu .mega{
background:#fff; border-radius:12px; box-shadow:0 10px 30px rgba(0,0,0,.08);
padding:16px; width:min(1001px, calc(100vw - 40px)); max-height:85vh; overflow:auto;
}
#${NEW_ID} .mega a{ font-size:14px; color:#666; font-weight:400; text-decoration:none; display:flex; flex-direction:column; align-items:flex-start; }
#${NEW_ID} .mega a:hover{ color:#eb0a8b; }
#${NEW_ID} .mega img{ border-radius:12px; margin-bottom:6px; display:block; width:100%; height:auto; }
#${NEW_ID} .mega .caption{ display:block; text-align:center; font-size:14px; color:#666; font-weight:400; margin-top:2px; }
}
@media (max-width:1023px){
#${NEW_ID}{ display:none !important; }
}
`.trim();
function ensureStyle() {
if (document.getElementById(STYLE_ID)) return;
const s = document.createElement("style");
s.id = STYLE_ID;
s.textContent = CSS;
document.head.appendChild(s);
}
function buildMoreLi(siblingForClasses) {
const li = document.createElement("li");
li.id = NEW_ID;
const baseClasses = siblingForClasses
? siblingForClasses.className
: "!hidden lg:!block root-level lg:!inline-block";
li.className = (baseClasses + " has-children").trim();
const a = document.createElement("a");
a.target = "_self";
a.href = "/#";
a.setAttribute("aria-label", "اعرف المزيد");
const span = document.createElement("span");
span.textContent = "اعرف المزيد";
span.setAttribute("translate", "no");
a.appendChild(span);
li.appendChild(a);
const sub = document.createElement("div");
sub.className = "sub-menu";
const mega = document.createElement("div");
mega.className = "mega";
mega.innerHTML = `