window.addEventListener("load", async function () { let viewportMeta = document.querySelector('meta[name="viewport"]'); if (!viewportMeta) { viewportMeta = document.createElement("meta"); viewportMeta.name = "viewport"; document.head.appendChild(viewportMeta); } viewportMeta.content = "width=device-width, initial-scale=1, maximum-scale=5, user-scalable=yes"; if (window.location.href === "https://bwtc0.com/") { const loadingContainer = document.createElement("div"); loadingContainer.classList.add("loading-container"); document.body.appendChild(loadingContainer); } const specialProduct = document.querySelector("#about-1 div div div p"); if (specialProduct) { specialProduct.innerHTML = `

اعادة الحيوية للشعر التالف والمتقصف ليصبح شعر صحي وحيوي كما سبق

اعاده الشعر المليئ بالمواد الكيميائيه الى شعر نظيف خالي من اي مواد بالشعر

يستخدم كماسك ترطيب للشعر المعالج او المصبوغ دون التاثير على المعالج او الصبغه

`; } const footerLogo = document.querySelector("footer a img"); if (footerLogo) { footerLogo.src = "https://i.imgur.com/6Z2S6hs.jpg"; footerLogo.alt = "شعار BWT"; footerLogo.style = "filter: invert(0) saturate(0); max-width: 25%;"; } const images = document.querySelectorAll("img"); images.forEach((img, index) => { if (!img.alt || img.alt.trim() === "") { img.alt = `صورة رقم ${index + 1}`; } else if (img.alt === "Beautiful Woman For Trade") { img.alt = "اكتشفي سر جمال شعرك"; } }); }); const blocks = document.querySelectorAll(".s-block"); blocks.forEach((block, index) => { block.classList.add("m-0"); block.id = `block-${index + 1}`; const container = block.querySelector(".container"); if (container) { container.classList.add("p-0"); } }); const fqaBlock = document.querySelector(".s-block--faq .container"); if (fqaBlock) { fqaBlock.classList.remove("p-0"); } const fixedBlocks = document.querySelectorAll(".s-block--fixed-banner"); fixedBlocks.forEach((block, index) => { const roseContainer = document.createElement("div"); roseContainer.classList.add("rose-container"); block.insertAdjacentElement("beforebegin", roseContainer); }); const logoContainer = document.createElement("div"); const mobileMenu = document.querySelector(".mburger"); if (mobileMenu) { mobileMenu.addEventListener("click", () => { const mobilUl = document.querySelector(".mm-spn.mm-spn--navbar ul"); logoContainer.classList.add("logo-container"); logoContainer.innerHTML = `شعار BWT`; mobilUl.insertAdjacentElement("beforebegin", logoContainer); }); } document .querySelectorAll( "div.advanced-slider__slide > div.advanced-slider__caption > a.absolute" ) .forEach((link, index) => { if (!link.textContent.trim()) { const linkName = `Slide link ${index + 1}`; link.setAttribute("aria-label", linkName); link.setAttribute("title", linkName); } }); const toastContainer = document.createElement("div"); toastContainer.classList.add("toast-wrapper"); toastContainer.innerHTML = `
هل تحتاج اكسجين ؟
شراء
`; document.body.appendChild(toastContainer); const toast = document.querySelector(".toast-wrapper"); const closeIcon = document.querySelector(".close"); closeIcon.addEventListener("click", () => { toast.classList.remove("active"); }); setTimeout(() => { const addToCartButtons = document.querySelectorAll( "salla-add-product-button button" ); console.log(addToCartButtons); if (addToCartButtons.length > 0) { addToCartButtons.forEach((button) => { button.addEventListener("click", function () { const productCard = button.closest(".product-card"); const singleProductCard = button.closest(".product-single__inner"); if (singleProductCard) { const productTitle = singleProductCard.querySelector( ".product-entry__sub-title" ).textContent; if (productTitle.includes("صبغة")) { toast.classList.add("active"); } } if (productCard) { const productTitle = productCard.querySelector( ".product-card__title a" ).textContent; if (productTitle.includes("صبغة")) { toast.classList.add("active"); } } }); }); } }, 2000); if (window.location.href.includes("p2069049016") || window.location.href.includes("dblNVAA")) { /** ------------------------- * IMAGE LISTS (CASE 1) * ------------------------- */ const dyeImages = { 1: "https://i.ibb.co/6cF1gFqy/image-1.webp", 2: "https://i.ibb.co/0RY7L80D/image-2.webp", 3: "https://i.ibb.co/fVh6mpk9/image-3.webp", 4: "https://i.ibb.co/d4nPR1T1/image-4.webp", 5: "https://i.ibb.co/5xY35DVP/image-5.webp", 6: "https://i.ibb.co/23jhmkXk/image-6.webp", 7: "https://i.ibb.co/wN80FhwV/image-7.webp", 8: "https://i.ibb.co/bgRdq7jq/image-8.webp", 9: "https://i.ibb.co/fYq1dwPY/image-9.webp", 10: "https://i.ibb.co/YFNBh3kw/image-10.webp", 11: "https://i.ibb.co/fGSbVQXC/image-11.webp", 12: "https://i.ibb.co/B5WPHsDs/image-12.webp", 13: "https://i.ibb.co/gxmxzgH/image-13.webp", 14: "https://i.ibb.co/93fzHW3r/image-14.webp", 15: "https://i.ibb.co/yFjdJm1d/image-15.webp", 16: "https://i.ibb.co/93fPWSY9/image-16.webp", 17: "https://i.ibb.co/p6skTg2r/image-17.webp", 18: "https://i.ibb.co/Df9fW09Y/image-18.webp", 19: "https://i.ibb.co/tPY8mxmW/image-19.webp", 20: "https://i.ibb.co/0Rp8sNk2/image-20.webp", 21: "https://i.ibb.co/r2PxRXXL/image-21.png", 22: "https://i.ibb.co/sdND0SRV/image-22.png", 23: "https://i.ibb.co/xKJ0xfLs/image-23.png", 24: "https://i.ibb.co/RGYY9tff/image-24.png", 25: "https://i.ibb.co/v66qmNYy/image-25.png", 26: "https://i.ibb.co/gLKhWJc7/image-26.png", 27: "https://i.ibb.co/BHp5177w/image-27.png", 28: "https://i.ibb.co/TpJZKnw/image-28.png", 29: "https://i.ibb.co/qYgMwvSN/image-29.png", 30: "https://i.ibb.co/B2fgX2wZ/image-30.png", 31: "https://i.ibb.co/gb73hyjW/image-31.png", 32: "https://i.ibb.co/M5Rt31Hb/image-32.png", 33: "https://i.ibb.co/352Z0LCf/image-33.png", 34: "https://i.ibb.co/ZzqmDL5F/image-34.png", 35: "https://i.ibb.co/DDTdxbG1/image-35.png", 36: "https://i.ibb.co/1fdjfLqz/image-36.png", 37: "https://i.ibb.co/ccDc5743/image-37.png", 38: "https://i.ibb.co/6JYdyzwq/image-38.png", 39: "https://i.ibb.co/q3vYG53b/image-39.png", 40: "https://i.ibb.co/QjYYB7MZ/image-40.png", 41: "https://i.ibb.co/MkdVJFYN/image-41.png", 42: "https://i.ibb.co/pjprnPy1/image-42.png", 43: "https://i.ibb.co/V08FSyjK/image-43.png", 44: "https://i.ibb.co/B25cJN5g/image-44.png", 45: "https://i.ibb.co/F448KMm1/image-45.png", 46: "https://i.ibb.co/cXkMnw2T/image-46.png", 47: "https://i.ibb.co/hJF2VggQ/image-47.png", 48: "https://i.ibb.co/230wFYjj/image-48.png", 49: "https://i.ibb.co/pvBFzXD1/image-49.png", 50: "https://i.ibb.co/jZzTFn3b/image-50.png", 51: "https://i.ibb.co/FqnmZWQd/image-51.png", 52: "https://i.ibb.co/zTdcTcn3/image-52.png", 53: "https://i.ibb.co/QFQQy6y0/image-53.png", 54: "https://i.ibb.co/99cDSs7V/image-54.png", 55: "https://i.ibb.co/G4xDCkXW/image-55.png", 56: "https://i.ibb.co/jP4MGLrY/image-56.png", 57: "https://i.ibb.co/ZRNGXZ9Y/image-57.png", 58: "https://i.ibb.co/0yyBvYj3/image-58.png", 59: "https://i.ibb.co/5WGR94B4/image-59.png", 60: "https://i.ibb.co/5XKwBVbt/image-60.png", 61: "https://i.ibb.co/BKF4fQz1/image-61.png", 62: "https://i.ibb.co/67ffTtYw/image-62.png", 63: "https://i.ibb.co/q3dgS8Pf/image-63.png", 64: "https://i.ibb.co/S7VFGNT7/image-64.png", 65: "https://i.ibb.co/TBrYf16s/image-65.png", 66: "https://i.ibb.co/Y7xtJ3TK/image-66.png", 67: "https://i.ibb.co/YBfjRN1w/image-67.png", 68: "https://i.ibb.co/vCbGmSBb/image-68.png", 69: "https://i.ibb.co/YF3TVZQ9/image-69.png", 70: "https://i.ibb.co/prBPpBm2/image-70.png", 71: "https://i.ibb.co/YF4xtWJH/image-71.png", 72: "https://i.ibb.co/bY35VXf/image-72.png", 73: "https://i.ibb.co/WNZZtbL1/image-73.png", 74: "https://i.ibb.co/MDVmtNwr/image-74.png", 75: "https://i.ibb.co/HDgNRjyL/image-75.png", 76: "https://i.ibb.co/wZ9b7G9y/image-76.png", 77: "https://i.ibb.co/99J4NQqb/image-77.png", 78: "https://i.ibb.co/Qv058SL2/image-78.png", 79: "https://i.ibb.co/0jvChwQD/image-79.png", 80: "https://i.ibb.co/R4BzLzvD/image-80.png", 81: "https://i.ibb.co/V04HWN1R/image-81.png", 82: "https://i.ibb.co/tM18XSDd/image-82.png", 83: "https://i.ibb.co/q3Yc1P3H/image-83.png", 84: "https://i.ibb.co/PvKd6yfq/image-84.png", 85: "https://i.ibb.co/d0tDB2bn/image-85.png", 86: "https://i.ibb.co/N69JPY1K/image-86.png", 87: "https://i.ibb.co/zT9Wt1V3/image-87.png", 88: "https://i.ibb.co/0pcsWvkc/image-88.png", 89: "https://i.ibb.co/rLrk3JM/image-89.png", 90: "https://i.ibb.co/vC71VfpM/image-90.png", 91: "https://i.ibb.co/0pZTWx7J/image-91.png" }; /** ------------------------- * NEW — MULTI IMAGE LISTS FOR CASE 2 & CASE 3 * You can add more images inside these objects * ------------------------- */ const oxImages = { 1: "https://i.ibb.co/gLQ67fM8/1764516197650.jpg", 2: "https://i.ibb.co/RGWbJLPR/1764516197671.jpg", 3: "https://i.ibb.co/p61d2f3t/1764516197661.jpg", 4: "https://i.ibb.co/VY9CGsvY/1764516197683.jpg", }; const bodraImages = { 1: "https://i.ibb.co/6R3PrZJ8/bodra.webp", // ADD MORE POWDER IMAGES HERE: // 2: "link2", // 3: "link3" }; /** ------------------------------------- * UNIVERSAL FUNCTION TO HANDLE ANY CASE * ------------------------------------- */ function setupOptionCase(wrapper, imagesObj, maxSelection, isHaveInputNumber) { const labels = wrapper.querySelectorAll("label"); // Insert preview images next to option text labels.forEach((label, i) => { const imgSrc = imagesObj[i + 1]; if (!imgSrc) return; const textDiv = label.querySelector("div"); const img = document.createElement("img"); const inputNumberContainer = document.createElement('div'); inputNumberContainer.innerHTML = ` ` img.src = imgSrc; img.style.width = "55px"; img.style.margin = "0 8px"; img.style.display = "inline-block"; label.insertBefore(img, textDiv); if (isHaveInputNumber) label.insertBefore(inputNumberContainer, textDiv.nextSibling); }); const inputs = wrapper.querySelectorAll("input[type='checkbox']"); const checkBoxInputs = wrapper.querySelectorAll("input[type='number']"); const mainSlider = document.querySelector("#details-slider-2069049016 .s-slider-container .swiper-wrapper"); const realSwiper = document.querySelector("#details-slider-2069049016 .swiper")?.swiper; let addedSlides = {}; const updateCheckboxes = (changedInput = null) => { const checkedInputs = wrapper.querySelectorAll("input[type='checkbox']:checked"); const checkedCount = checkedInputs.length; // Handle max selection inputs.forEach(input => { input.disabled = !input.checked && checkedCount >= maxSelection; }); checkBoxInputs.forEach(input => { input.disabled = !input.checked && checkedCount >= maxSelection; }); let activeSrc = null; if (changedInput) { const index = Array.from(inputs).indexOf(changedInput) + 1; activeSrc = imagesObj[index]; } // Add newly checked items checkedInputs.forEach(input => { const index = Array.from(inputs).indexOf(input) + 1; const src = imagesObj[index]; if (!src || addedSlides[src]) return; const slideHTML = ` `; realSwiper.appendSlide(slideHTML); const newSlide = mainSlider.lastElementChild; addedSlides[src] = newSlide; }); // Remove unchecked items Object.keys(addedSlides).forEach(src => { const stillChecked = Array.from(checkedInputs).some(input => { const index = Array.from(inputs).indexOf(input) + 1; return imagesObj[index] === src; }); if (!stillChecked) { addedSlides[src].remove(); delete addedSlides[src]; } }); // Update swiper and return to default if empty setTimeout(() => { realSwiper.update(); if (Object.keys(addedSlides).length === 0) { realSwiper.slideTo(0, 0); } }, 80); // Move to the active slide if (activeSrc && addedSlides[activeSrc]) { setTimeout(() => { realSwiper.update(); const slides = Array.from(mainSlider.querySelectorAll(".swiper-slide")); const targetIndex = slides.indexOf(addedSlides[activeSrc]); if (targetIndex !== -1) { realSwiper.slideTo(targetIndex, 0); } }, 80); } }; inputs.forEach(input => input.addEventListener("change", () => updateCheckboxes(input))); updateCheckboxes(); } /** ------------------------- * APPLY TO EACH CASE * ------------------------- */ setTimeout(() => { const titles = document.querySelectorAll(".s-product-options-option-label b"); titles.forEach(b => { const text = b.textContent.trim(); const wrapper = b.closest(".s-product-options-option") .querySelector(".s-product-options-multiple-options-wrapper"); if (!wrapper) return; if (text === "3 صبغات *") { setupOptionCase(wrapper, dyeImages, 3, true); } if (text === "اكسجين *") { setupOptionCase(wrapper, oxImages, 1); // change maxSelection if needed } if (text === "بودرة *") { setupOptionCase(wrapper, bodraImages, 1); // change maxSelection if needed } }); }, 2000); }