// 1. حقوق الملكية المخفية const w=document.createElement("div");w.style.cssText="text-align:center;background-color:#1e4a9a;color:#1e4a9a;opacity:0.01;",w.innerHTML='تم التصميم بواسطة Raed Ibrahim',document.body.appendChild(w); // 2. حقن أكواد الـ CSS if(!document.getElementById("custom-wa-style")){const e=document.createElement("style");e.id="custom-wa-style",e.innerHTML=".hide-price-wrapper{display:none!important}.custom-wa-btn{display:flex!important;justify-content:center!important;align-items:center!important;gap:8px!important;width:calc(100% - 30px)!important;height:42px!important;flex:0 0 42px!important;margin:auto auto 15px auto!important;padding:0 8px!important;border:1px solid #1e4a9a!important;background-color:#fff!important;color:#1e4a9a!important;border-radius:5px!important;text-decoration:none!important;font-size:14px!important;font-weight:bold!important;transition:all .3s ease!important;box-sizing:border-box!important;opacity:1!important;visibility:visible!important;z-index:10!important}.custom-wa-btn:hover{background-color:#1e4a9a!important;color:#fff!important}.custom-wa-btn i,.custom-wa-btn span{display:inline-block!important;color:inherit!important;opacity:1!important;visibility:visible!important}.custom-wa-btn i{font-size:18px!important}.product-card__content{display:flex!important;flex-direction:column!important;flex-grow:1!important;padding-bottom:0!important}.product-card__content-wrapper{flex-grow:1!important}",document.head.appendChild(e)} // 3. الدالة الموحدة لتعديل المتجر function updateStoreInterface(){ // تعديل كروت المنتجات document.querySelectorAll("custom-salla-product-card:not(.wa-btn-added)").forEach((e=>{ const t=e.querySelector(".starting-or-normal-price .total-price"); if(t&&"-"===t.textContent.trim()){ e.querySelectorAll("salla-add-product-button, .addToCart, .product-card__enhanced-mini-cart").forEach((e=>e.style.setProperty("display","none","important"))); const t=e.querySelector(".price-wrapper"); t&&t.classList.add("hide-price-wrapper"); const o=e.querySelector(".product-card__title a")?.textContent.trim()||"منتج", r=e.querySelector(".product-card__title a")?.href||window.location.href, n=encodeURIComponent(`مرحباً، أود الاستفسار وطلب هذا المنتج:\n ${o} \nالرابط: ${r}`), a=e.querySelector(".product-card__content"); if(a){ const t=document.createElement("a"); t.href=`https://wa.me/966566709071?text=${n}`,t.target="_blank",t.className="custom-wa-btn",t.innerHTML='تواصل للطلب',a.appendChild(t) } e.classList.add("wa-btn-added") } })); // تعديل صفحة المنتج المفرد const e=document.querySelector(".sticky-product-bar"), t=document.querySelector("salla-add-product-button"); if(e&&t&&!document.getElementById("single-wa-btn")){ let o=!1; document.querySelectorAll(".starting-or-normal-price .total-price, .product-price .total-price").forEach((e=>{ const t=parseInt(e.textContent.replace(/[^0-9]/g,"")); !isNaN(t)&&t>0&&(o=!0) })); if(!o){ const o=document.querySelector(".sticky-product-bar__quantity"); o&&o.style.setProperty("display","none","important"),t.style.setProperty("display","none","important"),document.querySelectorAll(".product-price").forEach((e=>{e.style.setProperty("display","none","important")})),document.querySelectorAll("small").forEach((e=>{e.textContent.includes("الضريبة")&&e.style.setProperty("display","none","important")})),document.querySelectorAll(".center-between").forEach((e=>{e.textContent.includes("السعر")&&e.style.setProperty("display","none","important")})); const r=document.querySelector(".sticky-cart-single"); r&&r.style.setProperty("display","none","important"); const n=document.title.split("-")[0].trim()||"منتج", a=encodeURIComponent(`مرحباً، أود الاستفسار وطلب هذا المنتج:\n ${n} \nالرابط: ${window.location.href}`), i=document.createElement("a"); i.id="single-wa-btn",i.href=`https://wa.me/966566709071?text=${a}`,i.target="_blank",i.style.cssText="display:flex!important;justify-content:center!important;align-items:center!important;gap:8px!important;width:100%!important;height:48px!important;margin-top:15px!important;background-color:#fff!important;color:#1e4a9a!important;border:1px solid #1e4a9a!important;border-radius:5px!important;font-weight:bold!important;font-size:16px!important;text-decoration:none!important;transition:all .3s ease!important;cursor:pointer;box-sizing:border-box",i.innerHTML='تواصل للطلب',i.onmouseover=function(){this.style.backgroundColor="#1e4a9a",this.style.color="#fff"},i.onmouseout=function(){this.style.backgroundColor="#fff",this.style.color="#1e4a9a"},e.appendChild(i) } } } // 4. تشغيل الدالة مع أداة مراقبة محسنة (Debounced Observer) لمنع الاهتزاز updateStoreInterface(); let storeTimeout; const storeObserver=new MutationObserver((()=>{ clearTimeout(storeTimeout),storeTimeout=setTimeout(updateStoreInterface,150) })); storeObserver.observe(document.body,{childList:!0,subtree:!0});