document.addEventListener('DOMContentLoaded', function() {
let logo = document.querySelector('.navbar-brand');
let footerBox = document.querySelector('footer > div.store-footer__inner > div > div.lg\\:col-span-2.rtl\\:lg\\:pl-20.ltr\\:lg\\:pr-20 a.flex.items-center.m-0');
if (logo && footerBox) {
// تصغير h3
let h3 = footerBox.querySelector('a > h3');
if (h3)
h3.style.fontSize = '0';
// نسخ الشعار
let clone = logo.cloneNode(true);
footerBox.appendChild(clone);
}
console.log(logo);
console.log(footerBox);
});
document.querySelector("body > div.app-inner.flex.flex-col.min-h-full > header > div.main-nav-container.shadow-default.bg-white > div > div > div .flex.items-center.justify-end").innerHTML+=
` `;
window.Salla.onReady(function() {
console.log('Salla Ready - Attempting to move main menu...');
// انتظر قليلاً للتأكد من تحميل جميع المكونات الداخلية
setTimeout(function() {
// ابحث عن عنصر القائمة الرئيسية
const customMainMenuElement = document.querySelector('custom-main-menu');
if (!customMainMenuElement) {
console.error('Salla Helper: Custom main menu element not found.');
return;
}
// ابحث عن الهيدر.
const storeHeader = document.querySelector('header.store-header');
if (!storeHeader) {
console.error('Salla Helper: Store header element not found.');
return;
}
// ابحث عن العنصر الذي يأتي بعد الهيدر مباشرة.
// سنستخدم الهيدر نفسه كمرجع لوضع القائمة بعده.
const elementAfterHeader = storeHeader; // الهيدر نفسه هو العنصر الذي سنضيف القائمة بعده
// نحصل على الأخ الذي يلي الهيدر مباشرة في شجرة DOM
const nextSiblingElement = elementAfterHeader.nextElementSibling;
console.log('Found customMainMenuElement:', customMainMenuElement);
console.log('Found storeHeader:', storeHeader);
console.log('Found nextSiblingElement (placeholder for insertion):', nextSiblingElement);
// قم بإزالة العنصر من موقعه الأصلي (داخل الهيدر)
if (customMainMenuElement && customMainMenuElement.parentNode) {
customMainMenuElement.remove();
console.log('Custom main menu element removed from its original position.');
} else {
console.error('Custom main menu element not found in DOM to remove.');
return;
}
// قم بإدراج العنصر الجديد في المكان المحدد
if (nextSiblingElement) {
// أدخل العنصر الجديد قبل العنصر التالي للهيدر
// نستخدم parentNode للهيدر لوضع العنصر الجديد فيه، قبل العنصر التالي
storeHeader.parentNode.insertBefore(customMainMenuElement, nextSiblingElement);
console.log('Custom main menu inserted before the next sibling element.');
} else {
// إذا لم يكن هناك عنصر تالي للهيدر، أضفه بعد الهيدر مباشرة في نفس المستوى
storeHeader.parentNode.appendChild(customMainMenuElement);
console.log('Custom main menu appended after the header element.');
}
console.log('Salla Helper: Custom main menu moved successfully.');
// في حال واجهت مشاكل مع فتح القائمة للجوال بعد النقل، قد تحتاج إلى إعادة تهيئة
// السكريبتات المسؤولة عن ذلك. مثلاً، إذا كانت هناك دالة تهيئة اسمها SallaMobileMenu.init():
// if (typeof SallaMobileMenu !== 'undefined' && SallaMobileMenu.init) {
// SallaMobileMenu.init();
// }
}, 500); // تأخير لضمان تحميل المكونات
});
document.addEventListener("DOMContentLoaded", function() {
const header = document.querySelector("body.index header.store-header");
if (header) {
const wrapper = document.createElement("div");
wrapper.classList.add("video-wrapper");
const video = document.createElement("video");
video.classList.add("custom-video");
video.src = "https://raw.githack.com/elwa2/Videos/main/IMG_5376.mp4";
video.autoplay = true;
video.loop = true;
video.muted = true;
video.playsInline = true;
wrapper.appendChild(video);
header.parentNode.insertBefore(wrapper, header.nextSibling);
}
});
(function() {
let attempts = 0;
const maxAttempts = 10;
/**
* دالة لاستخراج اسم المتجر من عنوان الصفحة
* المثال: "التخفيضات - tidy brand" -> تأخذ "tidy brand"
*/
function getStoreName() {
try {
let fullTitle = document.title; // جلب العنوان كامل من المتصفح
if (fullTitle.includes('-')) {
// إذا كان العنوان يحتوي على شرطة، نقسمه ونأخذ الجزء الأخير
let parts = fullTitle.split('-');
return parts[parts.length - 1].trim();
}
return fullTitle; // إذا لم توجد شرطة، نأخذ العنوان كما هو
} catch (e) {
return "المتجر"; // اسم احتياطي في حال حدوث خطأ
}
}
/**
* البحث عن رقم الواتساب من فوتر الموقع (خاص بمنصة سلة)
*/
function findNumberAndInit() {
const footerWaLink = document.querySelector('footer.store-footer a[href*="wa.me"]');
if (footerWaLink) {
let href = footerWaLink.getAttribute('href');
let extractedNumber = href.split('wa.me/')[1].split('?')[0];
buildWhatsappButton(extractedNumber);
} else if (attempts < maxAttempts) {
attempts++;
setTimeout(findNumberAndInit, 500);
} else {
// الرقم الافتراضي في حال لم يتم العثور على رقم في الموقع
buildWhatsappButton("966539170830");
}
}
/**
* بناء وتصميم زر الواتساب العائم
*/
function buildWhatsappButton(whatsappNumber) {
if (document.querySelector('.salla-whatsapp-floating')) return;
// إضافة التنسيقات (CSS) للزر
const style = document.createElement('style');
style.innerHTML = `
.salla-whatsapp-floating {
position: fixed;
bottom: 30px;
right: 30px;
width: 60px;
height: 60px;
background-color: #25d366;
color: #fff;
border-radius: 50%;
text-align: center;
font-size: 30px;
box-shadow: 2px 2px 15px rgba(0,0,0,0.2);
z-index: 999999;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.3s ease;
text-decoration: none !important;
cursor: pointer;
}
.salla-whatsapp-floating:hover {
background-color: #128c7e;
transform: scale(1.1);
}
/* تأثير النبض خلف الزر */
.salla-whatsapp-floating::after {
content: "";
position: absolute;
width: 100%;
height: 100%;
background-color: #25d366;
border-radius: 50%;
z-index: -1;
animation: pulse-whatsapp 2s infinite;
}
@keyframes pulse-whatsapp {
0% { transform: scale(1); opacity: 0.6; }
100% { transform: scale(1.6); opacity: 0; }
}
.salla-whatsapp-floating svg {
width: 35px;
height: 35px;
fill: #fff;
}
@media (max-width: 768px) {
.salla-whatsapp-floating {
bottom: 20px;
right: 20px;
width: 55px;
height: 55px;
}
}
`;
document.head.appendChild(style);
// إنشاء عنصر الرابط (Link) للزر
const waLink = document.createElement('a');
waLink.className = 'salla-whatsapp-floating';
waLink.setAttribute('aria-label', 'تواصل معنا عبر واتساب');
waLink.innerHTML = `
`;
/**
* وظيفة النقر على الزر وتجهيز الرسالة
*/
waLink.addEventListener('click', function(e) {
e.preventDefault();
// الحصول على اسم المتجر من الـ Title
const storeName = getStoreName();
// الرسالة الافتراضية
let message = `السلام عليكم، أرغب في الاستفسار عن منتجات ${storeName}`;
const currentUrl = window.location.href;
// محاولة جلب اسم المنتج إذا كان العميل في صفحة منتج
const productTitleElement = document.querySelector('h1.text-xl, h1.t-title, .main-content h1');
if (currentUrl.includes('/p') && productTitleElement) {
let productName = productTitleElement.innerText.trim();
message = `السلام عليكم، أرغب في الاستفسار عن هذا المنتج من ${storeName}:\n\n*المنتج:* ${productName}\n*الرابط:* ${currentUrl}`;
}
// فتح الواتساب في نافذة جديدة
const finalWaUrl = `https://wa.me/${whatsappNumber}?text=${encodeURIComponent(message)}`;
window.open(finalWaUrl, '_blank');
});
document.body.appendChild(waLink);
console.log("WhatsApp Button Loaded for Store: " + getStoreName());
}
// بدء التشغيل عند اكتمال تحميل الصفحة
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', findNumberAndInit);
} else {
findNumberAndInit();
}
})();
document.addEventListener("DOMContentLoaded",(function(){function e(){var e=document.querySelector("salla-trust-badges.s-trust-badges-wrapper");return!!e&&(e.remove(),!0)}if(!e()){var t=setInterval((function(){e()&&clearInterval(t)}),500);setTimeout((function(){clearInterval(t)}),1e4)}}));