/* 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+ المبتكرة، ومنتجات العناية اليومية بالفم. جميعها آمنة على مينا الأسنان وتمنحك ابتسامة أكثر بياضًا وصحة

الرقم الضريبي : 310384069800003

`; footerInner.innerHTML = footerContent; try { const rootFooter = document.querySelector(".store-footer"); if (rootFooter) rootFooter.classList.add("footer-themed"); } catch (e) { /* ignore */ } } // تنفيذ الكود عند اكتمال تحميل الصفحة if (document.readyState === "loading") { document.addEventListener("DOMContentLoaded", updateFooter); } else { updateFooter(); } // مراقبة التغييرات في DOM لتطبيق التحديث عند الحاجة const observer = new MutationObserver((mutations) => { for (const mutation of mutations) { if (mutation.type === "childList") { const footerInner = document.querySelector(".store-footer__inner"); if (footerInner && footerInner.children.length === 0) { updateFooter(); break; } } } }); observer.observe(document.body, { childList: true, subtree: true }); })(); /* ======================================= 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 */ /* ---------- 1) Inject feed wrapper + elfsight app ---------- */ (function () { const TARGET_SELECTOR = ".itsak-compare"; const APP_CLASS = "elfsight-app-430b7c1b-c801-4fff-9983-023f63b76ac3"; const WRAPPER_CLASS = "itsak-ig-container container"; // يمكنك تعديل الكلاسات بحرية const WRAPPER_FLAG = "data-itsak-ig"; // علامة فريدة لتجنب التكرار const PLATFORM_SRC = "https://elfsightcdn.com/platform.js"; function ensurePlatformLoaded(onReady) { if (document.querySelector(`script[src*="${PLATFORM_SRC}"]`)) { onReady && onReady(); return; } const s = document.createElement("script"); s.src = PLATFORM_SRC; s.async = true; s.onload = () => onReady && onReady(); document.head.appendChild(s); } function injectWidget() { const target = document.querySelector(TARGET_SELECTOR); if (!target) return; // لا تستخدم querySelector بالكلاسات المزدوجة؛ استخدم علامة فريدة if (document.querySelector(`[${WRAPPER_FLAG}="1"]`)) return; // اصنع الكونتينر const wrapper = document.createElement("div"); wrapper.setAttribute(WRAPPER_FLAG, "1"); wrapper.className = WRAPPER_CLASS; // ضع تطبيق Elfsight داخله const app = document.createElement("div"); app.className = APP_CLASS; app.setAttribute("data-elfsight-app-lazy", ""); wrapper.appendChild(app); // أدخله بعد الهدف target.insertAdjacentElement("afterend", wrapper); } function init() { try { injectWidget(); ensurePlatformLoaded(); } catch (e) { console.error("[itsak-ig] inject error:", e); } } if (document.readyState === "loading") { document.addEventListener("DOMContentLoaded", init); } else { init(); } // راقب ظهور الهدف لاحقاً (خفيف) const obs = new MutationObserver(() => { if ( document.querySelector(TARGET_SELECTOR) && !document.querySelector(`[${WRAPPER_FLAG}="1"]`) ) { injectWidget(); } }); obs.observe(document.body, { childList: true, subtree: true }); })(); /* ---------- 2) Remove Elfsight header + add custom button ---------- */ (function () { const APP_SELECTOR = ".elfsight-app-430b7c1b-c801-4fff-9983-023f63b76ac3"; const HEADER_SELECTOR = ".eapps-instagram-feed-header.es-header"; const BTN_CLASS = "button-WRCvgobuReWM"; const STYLE_ID = "ig-custom-btn-style"; const btnHTML = `
تابعونا على الانستغرام
`; 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 ` `; } 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 = ` `; sub.appendChild(mega); li.appendChild(sub); return li; } function findMainUL() { return document.querySelector("nav#mobile-menu > ul.main-menu"); } function insertMore() { const ul = findMainUL(); if (!ul) return false; if (ul.querySelector("#" + NEW_ID)) return true; const shopEl = document.getElementById(SHOP_ID); const desktopShop = shopEl && ul.contains(shopEl) ? shopEl : null; const liMore = buildMoreLi(desktopShop || ul.querySelector("li")); if (desktopShop) { desktopShop.insertAdjacentElement("afterend", liMore); } else { const saveEl = document.getElementById(SAVE_ID); if (saveEl && ul.contains(saveEl)) { saveEl.insertAdjacentElement("beforebegin", liMore); } else { ul.appendChild(liMore); } } return true; } function boot() { ensureStyle(); let tries = 0; const iv = setInterval(() => { if (insertMore() || ++tries > 120) clearInterval(iv); }, 150); new MutationObserver(() => insertMore()).observe(document.body, { childList: true, subtree: true, }); document.addEventListener( "visibilitychange", () => { if (!document.hidden) setTimeout(insertMore, 120); }, { passive: true } ); } if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", boot); else boot(); })(); // footer (function () { function addColSpan() { // دور على العنصر اللي يحتوي "روابط مهمة" const target = document.querySelector(".enhanced_links_wrapper"); if (target) { // نطلع للأب اللي عنده class فيه mb-2.5 const parentDiv = target.closest('div[class*="mb-2.5"]'); if (parentDiv) { parentDiv.classList.add("col-span-2"); } } } if (document.readyState === "loading") { document.addEventListener("DOMContentLoaded", addColSpan); } else { addColSpan(); } })(); // product description — robust, cross-page accordion (Arabic + English keywords incl. "cause") (function () { "use strict"; const STYLE_ID = "accordion-details-style"; // Arabic keywords (existing) and English fallbacks so the same logic works across pages const AR_KEYS = [ // "لماذا", // "لماذا تختار", // "كيف", // "كيف يعمل", // "ماذا", // "ماذا يشمل", // "الاستخدام", // "الاستخدام المثالي", // "قائمة المكونات", ]; const EN_KEYS = []; const clean = (s) => (s || "") .replace(/[^\u0600-\u06FF\w\s؟?!:\-.,،]/g, "") .replace(/\s+/g, " ") .trim(); function startsWithAnyKey(txt) { if (!txt) return false; const t = (txt || "").trim(); // check if text ends with ? or : (Arabic or English) const endsWithQuestion = /[\?؟:]$/.test(t); if (!endsWithQuestion) return false; // also check lines that start with '•' or similar if (/^\s*[•\-\*]/.test(t)) return true; // if it ends with ? or :, consider it a question return true; } function ensureStyle() { if (document.getElementById(STYLE_ID)) return; const css = ` /* ====== أكورديون تفاصيل المنتج ====== */ .acc-item{ border-radius:12px; overflow:hidden; background:#f9fafb; } .acc-item + .acc-item{ margin-top:10px; } .acc-btn{ width:100%; display:flex; align-items:center; justify-content:space-between; padding:14px 16px; background:#f3f4f6; border:0; cursor:pointer; color:#111; font-size:16px; line-height:1.5; text-align:start; } .acc-btn .acc-title{ font-weight:600; } .acc-item.open .acc-btn{ background:#e5e7eb; } .acc-icon{ flex:0 0 auto; font-size:20px; font-weight:bold; line-height:1; color:#111; } .acc-panel{ display:none; padding:14px 16px; color:#333; background:#fff; } .acc-item.open .acc-panel{ display:block; } .acc-panel p{ margin:0 0 10px; } .acc-panel p:last-child{ margin-bottom:0; } @media (max-width: 768px){ .acc-btn{ font-size:15px; padding:12px; } } `.trim(); const s = document.createElement("style"); s.id = STYLE_ID; s.textContent = css; document.head.appendChild(s); } // containers to consider (broad so it runs across many pages) const CONTAINER_SELECTORS = [ "#details_table", ".more-tab-container", ".more-info-tabs__content", ".product-single__info", ".product-description", ".tab-pane", ]; let ACC_UID = 0; function findContainers() { const containers = new Set(); for (const sel of CONTAINER_SELECTORS) { document.querySelectorAll(sel).forEach((el) => containers.add(el)); } // also fallback: any element that contains a matching heading anywhere document.querySelectorAll("article, section, div").forEach((el) => { try { if (el.dataset && el.dataset.accDone) return; // cheap check: text includes any KEY term const txt = (el.textContent || "").slice(0, 200).toLowerCase(); if ( EN_KEYS.some((k) => txt.includes(k)) || AR_KEYS.some((k) => txt.includes(k)) ) { containers.add(el); } } catch (e) { /* ignore */ } }); return Array.from(containers); } function findHeadings(container) { const heads = []; // strong inside p container.querySelectorAll("p > strong, p > b").forEach((st) => { const txt = st.textContent || ""; if (startsWithAnyKey(txt)) heads.push(st.closest("p")); }); // headings container.querySelectorAll("h1,h2,h3,h4").forEach((h) => { const txt = h.textContent || ""; if (startsWithAnyKey(txt)) heads.push(h); }); // direct paragraphs container.querySelectorAll(":scope > p").forEach((p) => { const txt = p.textContent || ""; if (startsWithAnyKey(txt) && !heads.includes(p)) heads.push(p); }); // dedupe & sort by document order const uniq = Array.from(new Set(heads)); uniq.sort((a, b) => a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1 ); return uniq; } function makeAccordion(container) { if (!container || container.dataset.accDone === "1") return; const headings = findHeadings(container); if (!headings.length) return; container.dataset.accDone = "1"; // build accordion items for (let i = 0; i < headings.length; i++) { const head = headings[i]; const nextHead = headings[i + 1] || null; const item = document.createElement("div"); item.className = "acc-item"; const btn = document.createElement("button"); btn.type = "button"; btn.className = "acc-btn"; const titleSpan = document.createElement("span"); titleSpan.className = "acc-title"; titleSpan.textContent = (head.textContent || "").trim(); const icon = document.createElement("span"); icon.className = "acc-icon"; icon.textContent = "+"; btn.appendChild(titleSpan); btn.appendChild(icon); const panel = document.createElement("div"); panel.className = "acc-panel"; const pid = `acc-panel-${Date.now().toString(36)}-${++ACC_UID}`; panel.id = pid; panel.setAttribute("role", "region"); panel.hidden = true; panel.style.display = "none"; // move the nodes between this heading and the next heading into panel let cursor = head.nextSibling; const toMove = []; while (cursor && cursor !== nextHead) { const keep = cursor; cursor = cursor.nextSibling; if ( keep.nodeType === 1 || (keep.nodeType === 3 && keep.textContent.trim().length) ) { toMove.push(keep); } } head.parentNode.insertBefore(item, head); item.appendChild(btn); item.appendChild(panel); toMove.forEach((n) => panel.appendChild(n)); // remove original heading head.remove(); // accessibility btn.setAttribute("aria-controls", pid); btn.setAttribute("aria-expanded", "false"); // no per-button listener: handled by delegation below } // open first const first = container.querySelector(".acc-item"); if (first) { first.classList.add("open"); const ic = first.querySelector(".acc-icon"); if (ic) ic.textContent = "−"; const p = first.querySelector(".acc-panel"); if (p) { p.hidden = false; p.style.display = "block"; } const b = first.querySelector(".acc-btn"); if (b) b.setAttribute("aria-expanded", "true"); } // ensure delegation listener exists on container if (!container._accDelegated) { container._accDelegated = true; container.addEventListener( "click", (e) => { const btn = e.target.closest && e.target.closest(".acc-btn"); if (!btn || !container.contains(btn)) return; const item = btn.closest(".acc-item"); if (!item) return; const panel = item.querySelector(".acc-panel"); const icon = btn.querySelector(".acc-icon"); const isOpen = item.classList.toggle("open"); if (icon) icon.textContent = isOpen ? "−" : "+"; btn.setAttribute("aria-expanded", isOpen ? "true" : "false"); if (panel) { panel.hidden = !isOpen; panel.style.display = isOpen ? "block" : "none"; } }, { passive: true } ); } } function runAll() { const containers = findContainers(); containers.forEach((c) => makeAccordion(c)); } function boot() { ensureStyle(); if (document.readyState === "loading") { document.addEventListener("DOMContentLoaded", runAll); } else runAll(); // observe for dynamic content const mo = new MutationObserver((muts) => { for (const m of muts) { m.addedNodes.forEach((node) => { if (!(node instanceof Element)) return; // try to find containers within added node for (const sel of CONTAINER_SELECTORS) { node.querySelectorAll && node.querySelectorAll(sel).forEach((el) => makeAccordion(el)); } // or run a cheap check on the node itself if (startsWithAnyKey(node.textContent || "")) makeAccordion(node); }); } }); mo.observe(document.body, { childList: true, subtree: true }); } boot(); })(); //add links to phone nav (function () { "use strict"; const NEW_ID_MOBILE = "nav-know-more-mobile"; // عناصر القائمة (روابط الموبايل) const MOBILE_LINKS = [ ["/our-story/page-1632489326", "قصتنا"], ["/ar/hismile-research-centre/page-142563527", "مركز أبحاث هاي سمايل", "//itsak.tech/1752056485_0.webp"], ["/how-whitening-works/page-1271635003", " كيف تتم عملية تبييض الأسنان", "//itsak.tech/ResearchLanding.webp"], ["/ar/community-experience/page-735448168", "تجربة المجتمع"], ]; // عناصر بصورة + نص أسفل روابط الموبايل const MOBILE_IMAGE_LINKS = { ar: [ [ "https://hismile.online/ar/%D8%B4%D8%B1%D8%A7%D8%A6%D8%B7-%D8%A7%D9%84%D8%AA%D8%A8%D9%8A%D9%8A%D8%B6-v34/p1752053831", "http://itsak.tech/hisimle_v34.JPG", "شرائط التبييض V34", ], [ "https://hismile.online/ar/redirect/products/658415472", "http://itsak.tech/hisimle_banner3.JPG", "مرطب شفاه Hismile", ], ], en: [ [ "https://hismile.online/en/%D8%B4%D8%B1%D8%A7%D8%A6%D8%B7-%D8%A7%D9%84%D8%AA%D8%A8%D9%8A%D9%8A%D8%B6-v34/p1752053831", "http://itsak.tech/hisimle_v34_en.JPG", "V34 Whitening Strips", ], [ "https://hismile.online/en/%D9%85%D8%B1%D8%B7%D8%A8-%D8%B4%D9%81%D8%A7%D9%87-hismile-%D8%A8%D8%B2%D8%A8%D8%AF%D8%A9-%D8%A7%D9%84%D8%B4%D9%8A%D8%A7-%D9%88%D8%B2%D9%8A%D8%AA-%D8%A7%D9%84%D8%AC%D9%88%D8%AC%D9%88%D8%A8%D8%A7-%D8%AA%D8%B1%D8%B7%D9%8A%D8%A8-%D8%B9%D9%85%D9%8A%D9%82-%D9%88%D8%A7%D8%A8%D8%AA%D8%B3%D8%A7%D9%85%D8%A9-%D8%AC%D8%B0%D8%A7%D8%A8%D8%A9/p658415472/?lang=en", "http://itsak.tech/hisimle_banner3.JPG", "Hismile Lip Balm", ], ], }; function getMobileImageLinks() { try { const lang = (document.documentElement.lang || "").toLowerCase(); if (lang.startsWith("en")) { return MOBILE_IMAGE_LINKS.en; } else { return MOBILE_IMAGE_LINKS.ar; } } catch (e) { return MOBILE_IMAGE_LINKS.ar; // default to Arabic } } function localizeCaption(text) { // Since we now show language-specific captions directly, just return the text as-is return text; } function buildMobileLi() { const li = document.createElement("li"); li.id = NEW_ID_MOBILE; li.className = "lg:hidden text-sm font-bold"; // عنوان التبويب (mm-spn يستخدم ليفتح submenu) const span = document.createElement("span"); span.className = "!flex items-center gap-x-2"; span.textContent = "اعرف المزيد"; // قائمة فرعية const ul = document.createElement("ul"); MOBILE_LINKS.forEach((linkData) => { const liItem = document.createElement("li"); // Check if this is an image link (has 3 elements: href, label, image) if (linkData.length === 3) { const [href, label, imageSrc] = linkData; liItem.className = "text-center"; const a = document.createElement("a"); a.target = "_self"; a.href = href; a.className = "block"; const img = document.createElement("img"); img.src = imageSrc; img.alt = label; img.loading = "lazy"; const span = document.createElement("span"); span.className = "caption"; span.textContent = label; a.appendChild(img); a.appendChild(span); liItem.appendChild(a); } else { // Regular text link (has 2 elements: href, label) const [href, label] = linkData; liItem.className = "text-sm font-bold"; const a = document.createElement("a"); a.target = "_self"; a.href = href; a.textContent = label; liItem.appendChild(a); } ul.appendChild(liItem); }); li.appendChild(span); li.appendChild(ul); return li; } function insertMobile() { // لا تُضيف عنصر الموبايل إذا كانت اللغة إنجليزية try { const lang = (document.documentElement.lang || "").toLowerCase(); if (lang.startsWith("en")) return false; } catch (e) { /* ignore */ } const mobileMenu = document.querySelector("nav#mobile-menu > ul.main-menu"); if (!mobileMenu) return false; // إذا كان مضاف مسبقًا، خلاص if (mobileMenu.querySelector("#" + NEW_ID_MOBILE)) return true; // لقِ “اجمع ووفر” (نسخة الموبايل فقط) const mobileSaveAnchor = mobileMenu.querySelector( 'li.lg\\:hidden a[href*="/اجمع-ووفر/"], li.lg\\:hidden a[href*="%D8%A7%D8%AC%D9%85%D8%B9-%D9%88%D9%88%D9%81%D8%B1"]' ); const mobileSaveLi = mobileSaveAnchor ? mobileSaveAnchor.closest("li") : null; const liMore = buildMobileLi(); if (mobileSaveLi && mobileMenu.contains(mobileSaveLi)) { // ضعه قبل “اجمع ووفر” mobileSaveLi.insertAdjacentElement("beforebegin", liMore); } else { // وإن ما انوجد، حطّه آخر القائمة mobileMenu.appendChild(liMore); } return true; } // إدراج صور+نص في نهاية قائمة الموبايل (بعد "اجمع ووفر" إن وجد) function insertImageTilesAtEnd() { const ul = document.querySelector("nav#mobile-menu > ul.main-menu"); if (!ul) return false; // منع التكرار عبر علامة على أول عنصر const already = ul.querySelector('li[data-itsak-imgtiles="1"]'); if (already) return true; // العثور على "اجمع ووفر" (عنصر الموبايل فقط) const mobileSaveAnchor = ul.querySelector( 'li.lg\\:hidden a[href*="/اجمع-ووفر/"], li.lg\\:hidden a[href*="%D8%A7%D8%AC%D9%85%D8%B9-%D9%88%D9%88%D9%81%D8%B1"]' ); const saveLi = mobileSaveAnchor ? mobileSaveAnchor.closest("li") : null; // أنشئ العناصر وألحقها بعد saveLi أو في نهاية القائمة let insertionPoint = saveLi && ul.contains(saveLi) ? saveLi : ul.lastElementChild; let prev = insertionPoint; getMobileImageLinks().forEach(([href, imgSrc, caption], idx) => { const liImg = document.createElement("li"); liImg.className = "text-center lg:hidden"; if (idx === 0) liImg.setAttribute("data-itsak-imgtiles", "1"); const a = document.createElement("a"); a.className = "block"; a.href = href; a.target = "_self"; const img = document.createElement("img"); img.src = imgSrc; img.alt = caption; img.loading = "lazy"; const spanCaption = document.createElement("span"); spanCaption.className = "caption"; spanCaption.textContent = localizeCaption(caption); a.appendChild(img); a.appendChild(spanCaption); liImg.appendChild(a); if (prev) prev.insertAdjacentElement("afterend", liImg); else ul.appendChild(liImg); prev = liImg; }); return true; } function boot() { let tries = 0; const tick = () => { const a = insertMobile(); const b = insertImageTilesAtEnd(); if ((a && b) || ++tries > 80) clearInterval(iv); }; const iv = setInterval(tick, 150); tick(); // لو الواجهة أعادت بناء القوائم لاحقًا new MutationObserver(() => { insertMobile(); insertImageTilesAtEnd(); }).observe(document.body, { childList: true, subtree: true, }); // عند الرجوع للتبويب document.addEventListener( "visibilitychange", () => { if (!document.hidden) setTimeout(() => { insertMobile(); insertImageTilesAtEnd(); }, 120); }, { passive: true } ); } if (document.readyState === "loading") { document.addEventListener("DOMContentLoaded", boot); } else { boot(); } })();