/* Add custom JS code below */ (() => { "use strict"; const path = location.pathname.replace(/\/+$/, ""); const topics = [ ["تحديثات iOS والايفون", "/blog/ios-iphone-updates/c-737464829"], ["مشاكل وحلول الايفون", "/blog/iphone-problems-solutions/c-431035251"], ["الشحن والسماعات والملحقات", "/blog/iphone-chargers-accessories/c-1805529724"], ["ايفون 18 والحماية", "/blog/iphone-18-accessories-protection/c-1165709693"] ]; const WHATSAPP_NUMBER = "966566783130"; const clean = (value = "") => value.replace(/\s+/g, " ").trim(); function repeat(fn, limit = 20, delay = 500) { let n = 0; if (fn()) return; const timer = setInterval(() => { if (fn() || ++n >= limit) { clearInterval(timer); } }, delay); } /* ========================= BLOG ========================= */ function initBlogHub() { const allowed = path === "/blog" || topics.some((x) => path === x[1]); if (!allowed) return true; const feed = document.querySelector("salla-infinite-scroll"); if (!feed) return false; document .querySelector("#filters-menu") ?.classList.add("tr-force-hide"); document .querySelector("#blog-home-slider") ?.classList.add("tr-force-hide"); document .querySelector(".blog-home-slider") ?.classList.add("tr-force-hide"); if (!document.querySelector(".tr-hub")) { const current = topics.find((x) => path === x[1]); const hub = document.createElement("section"); hub.className = "tr-hub"; hub.innerHTML = `

${current ? current[0] : "مدونة تفاحة ريان التقنية"}

شروحات وتجارب تقنية عملية حول الايفون وتحديثات iOS والشحن والملحقات، بخطوات واضحة ومعلومات محدثة تساعدك على حل المشكلة واختيار المنتج المناسب.

${topics .map( (x) => `${x[0]}` ) .join("")}

${ current ? "أحدث المقالات في هذا القسم" : "أحدث الأدلة والشروحات" }

`; feed.parentNode?.insertBefore( hub, feed ); } [...feed.children].forEach((card) => { if ( card.classList.contains("tr-card") ) { return; } const links = [ ...card.querySelectorAll( 'a[href*="/blog/"]' ) ].filter( (a) => a.textContent.trim().length > 8 && !/اقرأ المزيد|عرض المزيد/i.test( a.textContent ) ); if (!links.length) return; links.sort( (a, b) => b.textContent.trim().length - a.textContent.trim().length ); const old = links[0]; const a = document.createElement("a"); a.href = old.href; a.textContent = old.textContent.trim(); a.className = "tr-link"; card.innerHTML = ""; card.appendChild(a); card.classList.add("tr-card"); }); return true; } /* ========================= ARTICLE ========================= */ function initSingleArticle() { if ( !/^\/blog\/.+\/a-\d+$/.test(path) ) { return true; } const main = document.querySelector( ".main-content.blog-category" ); if (!main) return false; if (main.dataset.trDone) { return true; } const layout = main.parentElement; const article = main.querySelector(":scope > article"); const aside = layout?.querySelector( 'aside[aria-label="Sidebar"]' ); if (!article) return false; main.dataset.trDone = "1"; main.classList.add( "tr-article-main" ); layout?.classList.add( "tr-article-layout" ); article.classList.add( "tr-article-body" ); [...main.children].forEach( (el) => { if (el.tagName === "IMG") { el.classList.add("tr-cover"); } } ); if ( !article.querySelector( ".tr-summary" ) ) { const firstP = [...article.children].find( (el) => el.tagName === "P" && el.textContent.trim().length >= 50 ); if (firstP) { const box = document.createElement( "section" ); box.className = "tr-summary"; const label = document.createElement( "strong" ); label.textContent = "الخلاصة السريعة"; firstP.parentNode?.insertBefore( box, firstP ); box.appendChild(label); box.appendChild(firstP); } } article .querySelectorAll("table") .forEach((table) => { if ( table.parentElement ?.classList.contains( "tr-table-wrap" ) ) { return; } const wrap = document.createElement("div"); wrap.className = "tr-table-wrap"; table.parentNode?.insertBefore( wrap, table ); wrap.appendChild(table); }); if (aside) { aside.classList.add( "tr-related" ); const relatedCards = [...aside.children].filter( (el) => el.tagName === "DIV" && el.classList.contains("mt-5") ); if ( relatedCards.length && !aside.querySelector( ".tr-related-grid" ) ) { const grid = document.createElement("div"); grid.className = "tr-related-grid"; relatedCards.forEach( (card) => grid.appendChild(card) ); aside.appendChild(grid); } layout?.appendChild(aside); } if ( layout && !layout.querySelector( ".tr-article-topics" ) ) { const section = document.createElement( "section" ); section.className = "tr-article-topics"; section.innerHTML = `

استكشف المزيد من الأدلة التقنية

`; layout.appendChild(section); } return true; } /* ========================= DIRECT PRODUCT OPEN ========================= */ function initDirectProductOpen() { if ( window.__trDirectProductOpen ) { return; } window.__trDirectProductOpen = true; document.addEventListener( "click", (event) => { const eventPath = event.composedPath ? event.composedPath() : []; const interactive = eventPath.some((el) => { if ( !(el instanceof Element) ) { return false; } return el.matches?.( "button,input,select,textarea,form," + "salla-add-product-button," + "salla-quantity-input," + ".btn--wishlist," + "[data-testid='store-product-add-to-cart']" ); }); if (interactive) return; const card = eventPath.find( (el) => el instanceof Element && el.matches?.( "salla-product-card," + "custom-salla-product-card," + "[data-testid='store-product-card']," + ".s-product-card-entry" ) ); if (!card) return; const links = [ ...(card.querySelectorAll?.( "a[href]" ) || []) ]; const productLink = links.find((a) => /\/p\d+(?:$|[?#])/i.test( a.href ) ) || links.find((a) => /\/p\d+/i.test( a.pathname ) ); if (!productLink) return; event.preventDefault(); event.stopPropagation(); event.stopImmediatePropagation(); location.href = productLink.href; }, true ); } /* ========================= TOP BAR ========================= */ function initTopStrip() { if ( document.querySelector( ".tr-top-strip" ) ) { return true; } const header = document.querySelector("header"); if (!header) return false; const strip = document.createElement("div"); strip.className = "tr-top-strip"; strip.innerHTML = `
أهلاً بك في تفاحة ريان
🚚 شحن مجاني للطلبات فوق 299 ريال
منتجات أصلية 100%
`; header.parentNode?.insertBefore( strip, header ); return true; } /* ========================= HEADER POLISH — V5 ========================= */ function initHeaderPolish() { const header = document.querySelector("header"); if (!header) return false; if (header.dataset.trHeaderV5 === "1") { return true; } header.dataset.trHeaderV5 = "1"; header.classList.add("tr-header-v5"); const links = [...header.querySelectorAll("a[href]")]; const brand = links.find((a) => { const img = a.querySelector("img"); if (!img) return false; try { const url = new URL(a.href, location.href); return url.origin === location.origin && (url.pathname === "/" || url.pathname === ""); } catch { return false; } }) || links.find((a) => a.querySelector("img")); if (brand) { brand.classList.add("tr-header-brand"); if (!brand.querySelector(".tr-header-brand-copy")) { const copy = document.createElement("span"); copy.className = "tr-header-brand-copy"; copy.innerHTML = ` تفاحة ريان أكثر من مجرد اكسسوارات `; brand.appendChild(copy); } } const candidates = [ ...header.querySelectorAll( "button, a, [role='button']" ) ]; const searchControl = candidates.find((el) => { if (el === brand || el.closest(".tr-header-brand")) return false; const haystack = clean([ el.getAttribute("aria-label") || "", el.getAttribute("title") || "", el.getAttribute("data-testid") || "", el.getAttribute("class") || "", el.textContent || "" ].join(" ")).toLowerCase(); return /بحث|search/.test(haystack); }); if (searchControl) { searchControl.classList.add("tr-header-search"); searchControl.setAttribute( "data-tr-placeholder", "ابحث عن منتجاتك المفضلة ..." ); } return true; } /* ========================= FOOTER ========================= */ function initFooter() { const footer = document.querySelector( "footer" ) || document.querySelector( ".store-footer" ) || document.querySelector( "#footer" ); if (!footer) return false; footer.classList.add( "tr-dark-footer" ); const headings = [ ...footer.querySelectorAll( "h2,h3,h4,h5,strong" ) ]; const contactHeading = headings.find( (el) => clean(el.textContent) === "تواصل معنا" ); if (contactHeading) { let node = contactHeading.parentElement; let contactColumn = null; for ( let i = 0; i < 6 && node && node !== footer; i++ ) { const parent = node.parentElement; if ( parent && parent.children.length >= 2 && parent.children.length <= 5 ) { contactColumn = node; break; } node = parent; } contactColumn ||= contactHeading.parentElement; if (contactColumn) { contactColumn.classList.add( "tr-footer-contact-hidden" ); contactColumn.parentElement ?.classList.add( "tr-footer-two-columns" ); } } if ( !footer.querySelector( ".tr-whatsapp-footer" ) ) { const socialLink = footer.querySelector( 'a[href*="tiktok"]' ) || footer.querySelector( 'a[href*="instagram"]' ); if (socialLink) { const socialContainer = socialLink.parentElement; const whatsapp = document.createElement("a"); whatsapp.className = "tr-whatsapp-footer"; whatsapp.href = `https://wa.me/${WHATSAPP_NUMBER}`; whatsapp.target = "_blank"; whatsapp.rel = "noopener noreferrer"; whatsapp.setAttribute( "aria-label", "تواصل معنا عبر واتساب" ); whatsapp.innerHTML = ` `; socialContainer ?.appendChild(whatsapp); } } const tiktok = footer.querySelector( 'a[href*="tiktok"]' ); const instagram = footer.querySelector( 'a[href*="instagram"]' ); const whatsapp = footer.querySelector( ".tr-whatsapp-footer" ); if ( tiktok && instagram && whatsapp ) { const row = tiktok.parentElement; row?.classList.add( "tr-footer-social-row" ); if ( whatsapp.parentElement !== row ) { row?.appendChild(whatsapp); } } return true; } /* ========================= HOME HERO — FIXED CDN ASSETS ========================= */ function initHomeHero() { if (path !== "") return true; if (document.querySelector(".tr-ref-home")) { return true; } const main = document.querySelector("#main-content") || document.querySelector("main"); if (!main) return false; const ASSETS = { hero: "https://cdn.files.salla.network/other/1517325416/b4fd3e48-27f1-471a-9a79-f5be09bf2c10-original.webp", airpods: "https://cdn.files.salla.network/other/1517325416/440e1f35-626e-4c27-bcc6-69501dbbeb6d-original.webp", watch: "https://cdn.files.salla.network/other/1517325416/66d72e0b-4908-41b4-b9d9-38722073be1f-original.webp", iphone: "https://cdn.files.salla.network/other/1517325416/7f124956-a9e6-475b-b8ac-9bce205ca0ea-original.webp", mac: "https://cdn.files.salla.network/other/1517325416/42e23d84-69be-415f-82dc-ae4dc8f0ac88-original.webp" }; const headings = [ ...document.querySelectorAll("h1,h2,h3") ]; const oldHeading = headings.find((el) => { if (el.closest(".tr-ref-home")) return false; const text = clean(el.textContent); return ( text.includes("شواحن واكسسوارات ايفون") || text.includes("شواحن واكسسوارات") || text.includes("اكسسوارات ايفون") ); }); let oldHero = null; if (oldHeading) { let node = oldHeading; let candidate = null; for (let i = 0; i < 8 && node?.parentElement; i++) { if (node === main) break; const rect = node.getBoundingClientRect?.(); if ( rect && rect.height >= 260 && rect.width >= Math.min(innerWidth * 0.65, 700) ) { candidate = node; } if (node.parentElement === main) { break; } node = node.parentElement; } oldHero = candidate || oldHeading.closest("section") || oldHeading.closest(".s-block"); } const findLink = (phrases, fallback = "/products") => { const links = [...document.querySelectorAll("a[href]")]; const found = links.find((a) => { const text = clean(a.textContent).toLowerCase(); return phrases.some((p) => text.includes(p.toLowerCase())); }); return found?.href || fallback; }; const home = document.createElement("section"); home.className = "tr-ref-home"; home.innerHTML = ` شواحن واكسسوارات ابل أصلية للايفون تشمل AirPods وMagSafe وApple Watch
منتجات أصلية 100% منتجات موثوقة ومختارة
شحن سريع وآمن إلى جميع مناطق المملكة
دفع آمن ومرن خيارات دفع متعددة
خدمة عملاء مميزة دعم قبل وبعد الشراء
`; if (oldHero?.parentNode) { oldHero.parentNode.insertBefore(home, oldHero); oldHero.classList.add("tr-old-hero-hidden"); } else { main.prepend(home); } const firstProduct = document.querySelector("salla-product-card") || document.querySelector("[data-testid='store-product-card']") || document.querySelector(".s-product-card-entry"); const productSection = firstProduct?.closest("section,.s-block") || firstProduct?.parentElement; if (productSection && !productSection.id) { productSection.id = "tr-products-start"; } return true; } /* ========================= HOME NATIVE PRODUCTS — V11 Official Salla component only ========================= */ function initNativeHomeProductsV11() { if (path !== "") return true; if ( document.querySelector( ".tr-native-products-v11" ) ) { return true; } const home = document.querySelector( ".tr-ref-home" ); if (!home) return false; /* نبني قسمًا مستقلًا بمكوّن سلة الرسمي. لا نقرأ أسماء أو أسعار أو صور المنتجات من DOM. */ const section = document.createElement("section"); section.className = "tr-native-products-v11"; section.innerHTML = `
اختيارات مميزة

منتجات مميزة

عرض جميع المنتجات
`; home.insertAdjacentElement( "afterend", section ); /* نخفي قسم "أحدث المنتجات" القديم فقط إذا تحقق شرطان: 1) العنوان مطابق حرفيًا. 2) نفس الغلاف يحتوي فعلاً بطاقات منتجات. لا نعدل محتوى البطاقة ولا DOM الداخلي للمنتجات. */ const headings = [ ...document.querySelectorAll( "h2,h3" ) ]; const oldHeading = headings.find((el) => { if ( el.closest( ".tr-native-products-v11" ) ) { return false; } return ( clean(el.textContent) === "أحدث المنتجات" ); }); if (oldHeading) { let node = oldHeading; for ( let i = 0; i < 6 && node && node !== document.body; i++ ) { const cards = node.querySelectorAll?.( "salla-product-card," + "custom-salla-product-card," + "[data-testid='store-product-card']," + ".s-product-card-entry" ) || []; if (cards.length >= 2) { node.classList.add( "tr-old-home-products-hidden-v11" ); break; } node = node.parentElement; } } return true; } /* ========================= HOME CLEANUP — V12 Hide only the two legacy visual blocks ========================= */ function initHomeCleanupV12() { if (path !== "") return true; const cleanText = (value = "") => value.replace(/\s+/g, " ").trim(); const groups = [ [ "سماعات واكسسوارات", "افياش ايفون أصلية", "بطاريات متنقلة", "سماعات ألعاب محيطية" ], [ "منتجات أصلية", "توصيل سريع", "أفضل الأسعار" ] ]; const hideGroup = (titles) => { const nodes = [ ...document.querySelectorAll( "h2,h3,h4,strong,p,span" ) ].filter((el) => titles.includes( cleanText(el.textContent) ) ); if (nodes.length < titles.length) { return false; } let node = nodes[0]; for ( let depth = 0; depth < 7 && node && node !== document.body; depth++ ) { const text = cleanText(node.textContent); if ( titles.every( (title) => text.includes(title) ) ) { node.classList.add( "tr-home-legacy-hidden-v12" ); return true; } node = node.parentElement; } return false; }; groups.forEach(hideGroup); return true; } /* ========================= ORIGINAL LATEST PRODUCTS — V12 Style only; never reparent or rewrite cards ========================= */ function initLatestProductsStyleV12() { if (path !== "") return true; if ( document.querySelector( ".tr-latest-products-v12" ) ) { return true; } const headings = [ ...document.querySelectorAll( "h2,h3" ) ]; const heading = headings.find((el) => { if ( el.closest( ".tr-native-products-v11" ) ) { return false; } return ( clean(el.textContent) === "أحدث المنتجات" ); }); if (!heading) return false; const cardSelector = "salla-product-card," + "custom-salla-product-card," + "[data-testid='store-product-card']," + ".s-product-card-entry"; let node = heading.parentElement; let section = null; for ( let i = 0; i < 6 && node && node !== document.body; i++ ) { const cards = node.querySelectorAll?.( cardSelector ) || []; if (cards.length >= 2) { section = node; break; } node = node.parentElement; } if (!section) return false; section.classList.add( "tr-latest-products-v12" ); heading.classList.add( "tr-latest-products-title-v12" ); const cards = [ ...section.querySelectorAll( cardSelector ) ]; cards.forEach((card) => { card.classList.add( "tr-latest-product-card-v12" ); }); return true; } repeat(initBlogHub, 20, 500); repeat(initSingleArticle, 12, 500); initDirectProductOpen(); repeat(initTopStrip, 20, 300); repeat(initHeaderPolish, 20, 300); repeat(initFooter, 20, 500); repeat(initHomeHero, 20, 500); repeat(initNativeHomeProductsV11, 20, 500); repeat(initHomeCleanupV12, 8, 400); repeat(initLatestProductsStyleV12, 12, 500); })(); /* ========================================================= V13 — PRODUCT PAGE V28 LAYOUT Moves the existing server-rendered description only. No content duplication, no schema injection. ========================================================= */ (() => { "use strict"; function initProductPageV28() { if ( !document.body || !document.body.classList.contains("product-single") ) { return true; } const topArea = document.querySelector( "body.product-single .top-area" ); if (!topArea) return false; const productRow = topArea.querySelector( ':scope > div[id^="product-"]' ); if (!productRow) return false; const description = productRow.querySelector( ".main-content > .product__description" ) || topArea.querySelector( ":scope > .product__description" ); if (!description) return false; description.classList.add( "tr-product-description-v28" ); if ( description.previousElementSibling !== productRow ) { productRow.insertAdjacentElement( "afterend", description ); } document.body.classList.add( "tr-product-page-v28" ); return true; } let tries = 0; const maxTries = 20; function run() { tries += 1; if ( initProductPageV28() || tries >= maxTries ) { return; } window.setTimeout(run, 250); } if (document.readyState === "loading") { document.addEventListener( "DOMContentLoaded", run, { once: true } ); } else { run(); } })(); /* ========================================================= V14 — HAMBURGER CATEGORY DRAWER Reuses Salla's existing mobile navigation inside the native side panel. No duplicated category links are generated. ========================================================= */ (() => { "use strict"; function initCategoryDrawerV29() { const panel = document.querySelector("#main-side-panel"); if (!panel) return false; const menu = panel.querySelector("nav.main-store-menu.mobile-menu"); if (!menu) return false; panel.classList.add("tr-category-drawer-v29"); const menuBlock = menu.parentElement; if (menuBlock) { const heading = menuBlock.querySelector("h2.side-panel__title"); if (heading) heading.textContent = "التصنيفات"; if (!menuBlock.querySelector(".tr-category-drawer-subtitle")) { const subtitle = document.createElement("p"); subtitle.className = "tr-category-drawer-subtitle"; subtitle.textContent = "اختر القسم الذي تبحث عنه"; if (heading) { heading.insertAdjacentElement("afterend", subtitle); } else { menuBlock.insertBefore(subtitle, menu); } } } menu.setAttribute("aria-label", "تصنيفات المتجر"); return true; } let tries = 0; const maxTries = 20; function runCategoryDrawerV29() { tries += 1; if (initCategoryDrawerV29() || tries >= maxTries) return; window.setTimeout(runCategoryDrawerV29, 250); } if (document.readyState === "loading") { document.addEventListener("DOMContentLoaded", runCategoryDrawerV29, { once:true }); } else { runCategoryDrawerV29(); } })(); /* ========================================================= V15 — DIRECT CATEGORY LINKS IN HAMBURGER / V30 Exact fix based on live console: the native parent .lg:hidden is display:none at desktop. Build a visible drawer list from the existing desktop header menu. ========================================================= */ (() => { "use strict"; function buildDirectCategoryDrawerV30() { const panel = document.querySelector("#main-side-panel"); if (!panel) return false; const content = panel.querySelector(".side-panel__content"); if (!content) return false; const sourceMenu = document.querySelector( ".store-header nav.main-store-menu:not(.mobile-menu) > ul.main-menu" ) || document.querySelector( "nav.main-store-menu:not(.mobile-menu) > ul.main-menu" ); if (!sourceMenu) return false; panel.classList.add( "tr-category-drawer-v30" ); let block = content.querySelector( ".tr-category-links-v30" ); if (!block) { block = document.createElement("section"); block.className = "tr-category-links-v30"; block.setAttribute( "aria-label", "تصنيفات المتجر" ); const title = document.createElement("h2"); title.className = "tr-category-links-v30__title"; title.textContent = "التصنيفات"; const subtitle = document.createElement("p"); subtitle.className = "tr-category-links-v30__subtitle"; subtitle.textContent = "اختر القسم الذي تبحث عنه"; const clonedList = sourceMenu.cloneNode(true); /* Avoid duplicate HTML ids in the cloned navigation. */ clonedList .querySelectorAll("[id]") .forEach(el => { el.removeAttribute("id"); }); clonedList .querySelectorAll("[data-id]") .forEach(el => { el.removeAttribute("data-id"); }); block.append( title, subtitle, clonedList ); content.prepend(block); } /* * Do not rely on Salla's breakpoint-hidden mobile block. * Keep it hidden and use the direct visible list above. */ const nativeMobileBlock = content.querySelector( ":scope > div.lg\\:hidden" ); if (nativeMobileBlock) { nativeMobileBlock.setAttribute( "aria-hidden", "true" ); } return true; } let attempts = 0; const maxAttempts = 24; function runV30() { attempts += 1; if ( buildDirectCategoryDrawerV30() || attempts >= maxAttempts ) { return; } window.setTimeout( runV30, 250 ); } if (document.readyState === "loading") { document.addEventListener( "DOMContentLoaded", runV30, { once:true } ); } else { runV30(); } })(); /* ========================================================= V16 — CUSTOM STORE CATEGORIES / V31 Uses the exact category names + URLs supplied by the merchant. ========================================================= */ (() => { "use strict"; const categories = [["منتجات ابل الاصلية", "https://ryt14.com/original-apple-accessories/c1269961980"], ["شواحن وكيابل", "https://ryt14.com/%D8%B4%D9%88%D8%A7%D8%AD%D9%86-%D9%88%D9%83%D9%8A%D8%A7%D8%A8%D9%84/c1248587679"], ["سماعات", "https://ryt14.com/%D8%B3%D9%85%D8%A7%D8%B9%D8%A7%D8%AA/c1981623705"], ["اكسسوارات ايفون", "https://ryt14.com/%D8%A7%D9%83%D8%B3%D8%B3%D9%88%D8%A7%D8%B1%D8%A7%D8%AA-%D8%A7%D9%8A%D9%81%D9%88%D9%86/c344371953"], ["ملحقات ايباد", "https://ryt14.com/%D9%85%D9%84%D8%AD%D9%82%D8%A7%D8%AA-%D8%A7%D9%84%D8%A7%D9%8A%D8%A8%D8%A7%D8%AF/c499608475"], ["باور بانك", "https://ryt14.com/%D8%A8%D8%B7%D8%A7%D8%B1%D9%8A%D8%A7%D8%AA-%D9%85%D8%AA%D9%86%D9%82%D9%84%D8%A9/c607129240"], ["اكسسوارات سيارة", "https://ryt14.com/%D8%A7%D9%83%D8%B3%D8%B3%D9%88%D8%A7%D8%B1%D8%A7%D8%AA-%D8%A7%D9%84%D8%B3%D9%8A%D8%A7%D8%B1%D8%A9/c965388773"], ["ساعات ذكية", "https://ryt14.com/%D8%B3%D8%A7%D8%B9%D8%A7%D8%AA-%D8%B0%D9%83%D9%8A%D8%A9/c1254259960"], ["جوالات ذكية", "https://ryt14.com/%D8%AC%D9%88%D8%A7%D9%84%D8%A7%D8%AA-%D8%B0%D9%83%D9%8A%D8%A9/c924448480"], ["قطع غيار ايفون", "https://ryt14.com/%D9%82%D8%B7%D8%B9-%D8%BA%D9%8A%D8%A7%D8%B1-%D8%A7%D9%84%D8%A7%D9%8A%D9%81%D9%88%D9%86/c1698486247"], ["العاب واكسسوارات الجوال", "https://ryt14.com/%D8%A7%D9%84%D8%B9%D8%A7%D8%A8-%D9%88%D8%A7%D9%83%D8%B3%D8%B3%D9%88%D8%A7%D8%B1%D8%A7%D8%AA-%D8%A7%D9%84%D8%AC%D9%88%D8%A7%D9%84/c190302438"], ["شنط لابتوب", "https://ryt14.com/%D8%B4%D9%86%D8%B7%D8%A7%D8%AA-%D9%84%D8%A7%D8%A8%D8%AA%D9%88%D8%A8-%D9%85%D9%86-%D8%A8%D9%88%D9%86%D9%8A%D9%83/c956483958"]]; function normalizePath(value) { try { const u = new URL(value, location.origin); return decodeURIComponent(u.pathname) .replace(/\/+$/, "") .trim(); } catch (_) { return ""; } } function buildCustomCategoriesV31() { const panel = document.querySelector("#main-side-panel"); if (!panel) return false; const content = panel.querySelector(".side-panel__content"); if (!content) return false; panel.classList.add( "tr-category-drawer-v30", "tr-category-drawer-v31" ); /* Remove any temporary V30/V31 category block before rebuilding. */ content .querySelectorAll(".tr-category-links-v30") .forEach(el => el.remove()); const block = document.createElement("section"); block.className = "tr-category-links-v30"; block.setAttribute("aria-label", "تصنيفات المتجر"); const title = document.createElement("h2"); title.className = "tr-category-links-v30__title"; title.textContent = "التصنيفات"; const subtitle = document.createElement("p"); subtitle.className = "tr-category-links-v30__subtitle"; subtitle.textContent = "اختر القسم الذي تبحث عنه"; const list = document.createElement("ul"); list.className = "main-menu tr-custom-categories-v31"; const currentPath = normalizePath(location.href); categories.forEach(([name, href]) => { const li = document.createElement("li"); li.className = "root-level"; const a = document.createElement("a"); a.href = href; a.target = "_self"; a.setAttribute("aria-label", name); if (currentPath && normalizePath(href) === currentPath) { a.setAttribute("aria-current", "page"); } const inner = document.createElement("div"); inner.className = "flex items-center gap-2.5"; const span = document.createElement("span"); span.textContent = name; inner.appendChild(span); a.appendChild(inner); li.appendChild(a); list.appendChild(li); }); block.append(title, subtitle, list); content.prepend(block); /* Hide Salla's breakpoint-hidden mobile block and drawer widgets. */ const nativeMobileBlock = content.querySelector(":scope > div.lg\\:hidden"); if (nativeMobileBlock) { nativeMobileBlock.setAttribute("aria-hidden", "true"); } content .querySelectorAll(":scope > .side-panel__widget, :scope > salla-apps-icons.side-panel__widget") .forEach(el => { el.setAttribute("aria-hidden", "true"); }); return true; } let attempts = 0; const maxAttempts = 24; function runV31() { attempts += 1; if (buildCustomCategoriesV31() || attempts >= maxAttempts) { return; } window.setTimeout(runV31, 250); } if (document.readyState === "loading") { document.addEventListener("DOMContentLoaded", runV31, { once:true }); } else { runV31(); } })(); /* ========================================================= V17 — CATEGORY PAGES / V32 Technical SEO/GEO cleanup: 1) keeps the real category H1 2) converts the duplicate product-count H1 to a paragraph 3) repairs alt="undefined" on category product images using the visible product name No schema injection. No fake content. ========================================================= */ (() => { "use strict"; function isCategoryPage() { return !!( document.body && document.body.classList.contains("product-index") && document.querySelector( 'salla-products-list[source="product.index"]' ) ); } function fixDuplicateCountHeading() { const current = document.querySelector("#page-main-title"); if (!current) return; if ( current.tagName === "H1" && !current.classList.contains( "tr-category-product-count-v32" ) ) { const p = document.createElement("p"); for ( const attr of [...current.attributes] ) { if (attr.name !== "id") { p.setAttribute( attr.name, attr.value ); } } p.id = "page-main-title"; p.classList.add( "tr-category-product-count-v32" ); while (current.firstChild) { p.appendChild( current.firstChild ); } current.replaceWith(p); } else { current.classList.add( "tr-category-product-count-v32" ); } } function repairProductImageAlt(root = document) { const cards = root.querySelectorAll ? root.querySelectorAll( "custom-salla-product-card" ) : []; cards.forEach(card => { const title = card.querySelector( ".s-product-card-content-title a" )?.textContent ?.replace(/\s+/g, " ") .trim(); if (!title) return; card .querySelectorAll( ".s-product-card-image img" ) .forEach(img => { const alt = (img.getAttribute("alt") || "") .trim(); if ( !alt || alt.toLowerCase() === "undefined" || alt.toLowerCase() === "null" ) { img.setAttribute( "alt", title ); } }); }); } function initCategoryV32() { if (!isCategoryPage()) { return true; } document.body.classList.add( "tr-category-page-v32" ); fixDuplicateCountHeading(); repairProductImageAlt(document); const list = document.querySelector( 'salla-products-list[source="product.index"]' ); if ( list && !window.__TR_CATEGORY_V32_OBSERVER__ ) { const observer = new MutationObserver( mutations => { for ( const mutation of mutations ) { mutation.addedNodes .forEach(node => { if ( node.nodeType !== 1 ) { return; } if ( node.matches?.( "custom-salla-product-card" ) ) { repairProductImageAlt( node.parentElement || node ); } else { repairProductImageAlt( node ); } }); } } ); observer.observe( list, { childList:true, subtree:true } ); window .__TR_CATEGORY_V32_OBSERVER__ = observer; } return true; } let attempts = 0; const maxAttempts = 24; function runV32() { attempts += 1; if ( initCategoryV32() || attempts >= maxAttempts ) { return; } window.setTimeout( runV32, 250 ); } if ( document.readyState === "loading" ) { document.addEventListener( "DOMContentLoaded", runV32, { once:true } ); } else { runV32(); } })(); /* ========================================================= V18 — PRODUCT TAGS / RELATED LINKS / V33 Finds the existing internal-link cluster above the purchase area, moves the SAME DOM node after the V28 full-width description, and styles it as lightweight related-topic chips. No duplication. No schema injection. No hidden text. ========================================================= */ (() => { "use strict"; function sameOriginLink(a) { try { return new URL(a.href, location.origin).origin === location.origin; } catch (_) { return false; } } function cleanText(value) { return (value || "") .replace(/\s+/g, " ") .trim(); } function scoreCandidate(el) { if (!el || el.nodeType !== 1) return -1; if ( el.matches( [ "nav.product-title-nav", ".product__description", ".tr-product-description-v28", ".flex.whitespace-nowrap", "form.product-form", "salla-installment", "salla-cashback-banner", "salla-gifting", "salla-bought-together", "salla-verified-review", "salla-quick-order", "[class*='price']", "[class*='quantity']" ].join(",") ) ) { return -1; } const links = [...el.querySelectorAll("a[href]")]; if (links.length < 3) return -1; const internalLinks = links.filter(sameOriginLink); if ( internalLinks.length < 3 || internalLinks.length / links.length < 0.8 ) { return -1; } const labels = internalLinks .map(a => cleanText(a.textContent)) .filter(Boolean); if (labels.length < 3) return -1; const fullText = cleanText(el.textContent); /* Exclude purchase/share/navigation clusters. */ if ( /مشاركة المنتج|أضف للمفضلة|أضف إلى السلة|اشتر الآن|اشترِ الآن|الرئيسية|facebook|whatsapp|instagram|tiktok/i .test(fullText) ) { return -1; } /* Product tags are normally many short anchor phrases. */ const averageLabelLength = labels.reduce((sum, x) => sum + x.length, 0) / labels.length; if (averageLabelLength > 55) return -1; return ( internalLinks.length * 10 - averageLabelLength ); } function findProductTagCluster(mainContent) { if (!mainContent) return null; const directChildren = [...mainContent.children]; const candidates = directChildren .map(el => ({ el, score: scoreCandidate(el) })) .filter(x => x.score >= 0) .sort((a, b) => b.score - a.score); if (candidates.length) { return candidates[0].el; } /* * Fallback: search one level deeper, while still excluding * description, form, share and purchasing controls. */ const nested = [...mainContent.querySelectorAll(":scope > div > div")] .map(el => ({ el, score: scoreCandidate(el) })) .filter(x => x.score >= 0) .sort((a, b) => b.score - a.score); return nested[0]?.el || null; } function initProductTagsV33() { if ( !document.body || !document.body.classList.contains("product-single") ) { return true; } const topArea = document.querySelector( "body.product-single .top-area" ); if (!topArea) return false; const productRow = topArea.querySelector( ':scope > div[id^="product-"]' ); if (!productRow) return false; const mainContent = productRow.querySelector( ":scope > .main-content" ); if (!mainContent) return false; const description = topArea.querySelector( ":scope > .tr-product-description-v28" ) || topArea.querySelector( ":scope > .product__description" ); /* * V28 should move the description first. * Wait briefly if it has not happened yet. */ if (!description) return false; if ( topArea.querySelector( ":scope > .tr-product-tags-v33-wrap" ) ) { return true; } const cluster = findProductTagCluster(mainContent); /* * Not every product has tags. In that case do nothing. */ if (!cluster) { document.body.classList.add( "tr-product-tags-v33-none" ); return true; } const wrap = document.createElement("section"); wrap.className = "tr-product-tags-v33-wrap"; wrap.setAttribute( "aria-label", "مواضيع مرتبطة بالمنتج" ); const title = document.createElement("div"); title.className = "tr-product-tags-v33__title"; title.textContent = "مواضيع مرتبطة"; cluster.classList.add( "tr-product-tags-v33" ); wrap.append(title, cluster); description.insertAdjacentElement( "afterend", wrap ); document.body.classList.add( "tr-product-tags-v33-ready" ); return true; } let attempts = 0; const maxAttempts = 28; function runV33() { attempts += 1; if ( initProductTagsV33() || attempts >= maxAttempts ) { return; } window.setTimeout( runV33, 250 ); } if (document.readyState === "loading") { document.addEventListener( "DOMContentLoaded", runV33, { once:true } ); } else { runV33(); } })();