/* Add custom Js code below */
document.addEventListener("DOMContentLoaded", function () {
let langButton = document.querySelector(".ps-language-currency button");
if (!langButton) return;
// إعادة تفعيل الزر في حال كان مخفيًا
langButton.style.display = "block";
langButton.style.visibility = "visible";
// حذف القائمة نهائيًا من الصفحة
let langDropdown = document.querySelector(".ps-language-currency .dropdown-menu");
if (langDropdown) {
langDropdown.remove();
}
// تعديل نص الزر فقط
langButton.innerHTML =
'' +
(document.documentElement.lang === "ar" ? "EN" : "AR") +
"";
// إلغاء وظيفة الضغط تمامًا
langButton.addEventListener("click", function (event) {
event.preventDefault();
event.stopPropagation();
// لا شيء يحدث عند الضغط
});
});
/* Add custom Js code below */
document.addEventListener("DOMContentLoaded", function () {
let menuButton = document.querySelector(".menu-btn");
if (menuButton) {
// حذف النص "القائمة" مع الإبقاء على الأيقونة
menuButton.childNodes.forEach((node) => {
if (node.nodeType === Node.TEXT_NODE && node.nodeValue.trim() === "القائمة") {
node.remove();
}
});
}
});
/* Add custom Js code below */
document.addEventListener("DOMContentLoaded", function () {
let logAcc = document.querySelector(".log-acc");
if (logAcc) {
logAcc.innerHTML = ""; // يفرغ المحتوى النصي دون حذف العنصر بالكامل
}
});
/* Add custom Js code below */
document.addEventListener("DOMContentLoaded", function () {
let topBar = document.createElement("div");
topBar.classList.add("top-bar");
const translations = {
ar: {
qomra: "قمرة",
business: "الأعمال",
showrooms: "معارضنا",
studio: "الاستوديو",
whatsapp: "واتساب",
},
en: {
qomra: "Qomra",
business: "Business",
showrooms: "Showrooms",
studio: "Studio",
whatsapp: "WhatsApp",
},
};
let lang = document.documentElement.lang || "ar";
topBar.innerHTML = `
`;
document.body.insertBefore(topBar, document.body.firstChild);
let lastScrollTop = 0;
window.addEventListener("scroll", function () {
let currentScroll = window.pageYOffset || document.documentElement.scrollTop;
document.querySelector(".top-bar").style.top = currentScroll > lastScrollTop ? "-50px" : "0";
lastScrollTop = currentScroll <= 0 ? 0 : currentScroll;
});
});
/* Add custom Js code below */
document.addEventListener("DOMContentLoaded", function () {
var vatBox = document.querySelector(".vat-saudibusiness");
var targetContainer = document.querySelector("salla-contacts .s-contacts-list");
if (vatBox && targetContainer) {
targetContainer.appendChild(vatBox);
}
});
/* Add custom Js code below */
document.addEventListener("DOMContentLoaded", function () {
var bannerHTML = `
`;
var categoryContainer = document.querySelector(".products-list, .products-grid, .salla-products-slider");
if (categoryContainer) {
categoryContainer.insertAdjacentHTML("beforebegin", bannerHTML);
}
});
/* Add custom Js code below */
document.addEventListener("DOMContentLoaded", function () {
document.querySelectorAll(".s-product-card-sale-price").forEach(function (priceContainer) {
var oldPrice = priceContainer.querySelector("span");
var newPrice = priceContainer.querySelector("h4");
if (oldPrice && newPrice) {
var oldPriceDiv = document.createElement("div");
oldPriceDiv.className = "custom-old-price";
oldPriceDiv.innerHTML = oldPrice.innerHTML;
priceContainer.insertBefore(oldPriceDiv, newPrice);
oldPrice.style.display = "none";
}
});
});
/* Add custom Js code below */
document.addEventListener("DOMContentLoaded", function () {
document.querySelectorAll(".ps-product__content").forEach((productSection) => {
const detailsContent = productSection.querySelector(".p-about");
if (detailsContent) {
const originalContent = detailsContent.innerHTML;
const featuresContent = extractFeatures(originalContent);
const videoContent = extractVideo(originalContent);
const cleanedContent = removeFeaturesAndVideo(originalContent);
productSection.innerHTML = `
${videoContent ? '- فيديو المنتج
' : ""}
- تفاصيل المنتج
${videoContent ? `
${videoContent}
` : ""}
${featuresContent ? `
${featuresContent}
` : ""}
${cleanedContent ? `
${cleanedContent}
` : ""}
`;
productSection.querySelectorAll(".tab").forEach((tab) => {
tab.addEventListener("click", () => {
productSection.querySelector(".tab.active").classList.remove("active");
tab.classList.add("active");
productSection.querySelector(".tab-pane.active").classList.remove("active");
productSection.querySelector(`#${tab.getAttribute("data-tab")}`).classList.add("active");
});
});
}
});
function extractFeatures(content) {
const featureMatches = content.match(/(.*?)<\/b><\/p>/g);
if (!featureMatches) return "";
return featureMatches
.map((feature) => {
const text = feature.replace(/<\/?p>|<\/?b>/g, "");
return `
${text}
`;
})
.join("");
}
function extractVideo(content) {
const videoMatch = content.match(/.*?<\/iframe>/);
return videoMatch ? videoMatch[0] : "";
}
function removeFeaturesAndVideo(content) {
const withoutFeatures = content.replace(/.*?<\/b><\/p>/g, "");
return withoutFeatures.replace(//g, "").trim();
}
});
/* Add custom Js code below */
document.addEventListener("DOMContentLoaded", function () {
const showMoreBtn = document.querySelector(".show-more");
if (showMoreBtn) {
showMoreBtn.addEventListener("click", function (e) {
e.preventDefault();
const detailsTab = document.querySelector(".tab[data-tab='product-details']");
if (detailsTab) {
detailsTab.click();
detailsTab.scrollIntoView({ behavior: "smooth" });
}
});
}
});
/* Add custom Js code below */
function applyCardEnhancements() {
const lang = document.documentElement.lang || 'ar';
const isArabic = lang.startsWith("ar");
document.querySelectorAll(".s-product-card-content").forEach((card) => {
if (card.classList.contains("custom-enhanced")) return;
card.classList.add("custom-enhanced");
const subContainer = card.querySelector(".s-product-card-content-sub");
const salePrice = card.querySelector(".s-product-card-sale-price h4");
const originalPrice = card.querySelector(".custom-old-price") || card.querySelector(".s-product-card-sale-price span");
// ✅ السعر شامل الضريبة
const taxNote = document.createElement("p");
taxNote.className = "tax-note";
taxNote.textContent = isArabic ? "شامل الضريبة" : "VAT included";
subContainer.appendChild(taxNote);
// ✅ تفاصيل الخصم
if (salePrice && originalPrice && originalPrice.textContent.trim() !== "") {
const newPrice = parseFloat(salePrice.textContent.replace(/[^\d.]/g, ""));
const oldPrice = parseFloat(originalPrice.textContent.replace(/[^\d.]/g, ""));
if (!isNaN(oldPrice) && !isNaN(newPrice) && oldPrice > newPrice) {
const discount = oldPrice - newPrice;
const discountPercent = Math.round((discount / oldPrice) * 100);
const detailsBox = document.createElement("div");
detailsBox.className = "product-extra-details";
detailsBox.innerHTML = `
${isArabic ? `وفر ${discount.toFixed(2)} ر.س` : `Save ${discount.toFixed(2)} SAR`}
${isArabic ? `خصم ${discountPercent}%` : `${discountPercent}% Off`}
`;
subContainer.appendChild(detailsBox);
salePrice.style.color = "#e53935";
if (originalPrice) originalPrice.style.color = "#444";
}
}
});
}
// ✅ نراقب الصفحة ديناميكيًا
const observer = new MutationObserver(() => {
setTimeout(() => applyCardEnhancements(), 200);
});
observer.observe(document.body, { childList: true, subtree: true });
// ✅ تشغيل أولي
document.addEventListener("DOMContentLoaded", () => {
setTimeout(() => applyCardEnhancements(), 300);
});
/* Add custom Js code below */
function addFreeShippingTag() {
const lang = document.documentElement.lang || 'ar';
const isArabic = lang.startsWith('ar');
document.querySelectorAll(".s-product-card-content").forEach((card) => {
if (card.classList.contains("free-shipping-tagged")) return; // تأكد انه ماينعاد
const priceElement = card.querySelector("h4, .s-product-card-price");
if (!priceElement) return;
const price = parseFloat(priceElement.textContent.replace(/[^\d.]/g, ""));
if (!isNaN(price) && price >= 1000) {
const shippingTag = document.createElement("div");
shippingTag.className = "free-shipping-sticker";
shippingTag.innerHTML = ` ${isArabic ? "شحن مجاني" : "Free Shipping"}`;
const subContainer = card.querySelector(".s-product-card-content-sub");
if (subContainer) {
subContainer.appendChild(shippingTag);
card.classList.add("free-shipping-tagged"); // علمنا انو هذا الكرت خلاص تم
}
}
});
}
// ملاحظة: بس نراقب ظهور المنتجات
const observerShipping = new MutationObserver(addFreeShippingTag);
observerShipping.observe(document.body, { childList: true, subtree: true });
// أول تشغيل
document.addEventListener("DOMContentLoaded", addFreeShippingTag);
/* Add custom Js code below */
document.addEventListener("DOMContentLoaded", function () {
const targetPath = "/DGrjyYy"; // رابط المنتج المستهدف
if (window.location.pathname.includes(targetPath)) {
const purchasesEl = document.querySelector(".purchases-num span span");
const remainingEl = document.querySelector(".remaining-div span");
if (purchasesEl) purchasesEl.textContent = "101"; // ← عدّل الرقم هنا
}
});