/* Add custom code below */ document.addEventListener("DOMContentLoaded", () => { const ulElement = document.querySelector("footer ul"); const targetContainer = document.querySelector("footer .flex.w-full.flex-col-reverse"); if (ulElement && targetContainer) { targetContainer.appendChild(ulElement); } }); document.addEventListener("DOMContentLoaded", function () { // إنشاء عنصر الرابط let whatsappButton = document.createElement("a"); whatsappButton.href = "https://wa.me/966580427530"; // استبدل رقم_واتسابك برقمك بصيغة دولية whatsappButton.target = "_blank"; whatsappButton.classList.add("whatsapp-button"); // إنشاء صورة داخل الزر let whatsappIcon = document.createElement("img"); whatsappIcon.src = "https://roaaj.sa/svg-image-1.svg"; whatsappIcon.alt = "WhatsApp"; // إضافة الصورة إلى الرابط whatsappButton.appendChild(whatsappIcon); // إضافة الزر إلى الـ body document.body.appendChild(whatsappButton); }); setTimeout(function() { var meta = document.createElement('meta'); meta.name = "google-site-verification"; meta.content = "YrnIt56xuz_ystvmJ9n3k-dRGVaTECVqy6rv8SWz3iI"; document.head.appendChild(meta); console.log("تمت إضافة العلامة الوصفية بنجاح!"); }, 3000); // تأخير 3 ثوانٍ /* Add custom Js code below */ document.addEventListener("DOMContentLoaded", () => { const ulElement = document.querySelector("footer ul"); const targetContainer = document.querySelector("footer .flex.w-full.flex-col-reverse"); if (ulElement && targetContainer) { targetContainer.appendChild(ulElement); } }); document.addEventListener("DOMContentLoaded", function () { let whatsappButton = document.createElement("a"); whatsappButton.href = "https://wa.me/966580427530"; whatsappButton.target = "_blank"; whatsappButton.classList.add("whatsapp-button"); let whatsappIcon = document.createElement("img"); whatsappIcon.src = "https://roaaj.sa/svg-image-1.svg"; whatsappIcon.alt = "WhatsApp"; whatsappButton.appendChild(whatsappIcon); document.body.appendChild(whatsappButton); }); setTimeout(function() { var meta = document.createElement('meta'); meta.name = "google-site-verification"; meta.content = "YrnIt56xuz_ystvmJ9n3k-dRGVaTECVqy6rv8SWz3iI"; document.head.appendChild(meta); console.log("تمت إضافة العلامة الوصفية بنجاح!"); }, 3000); // حل مشكلة التمرير اللانهائي في سلة (function () { let isBlogPage = window.location.pathname === "/blog"; // تحقق مما إذا كنت في صفحة المدونة let lastUrl = window.location.href; let wasOnPostPage = false; // تتبع ما إذا كنت قادمًا من تدوينة // تحقق من URL عند التحميل الأولي if (isBlogPage && window.location.search.includes("page=")) { console.log("Page parameter detected on blog page load, redirecting..."); window.location.href = "https://bayounishop.com.sa/blog"; } // راقب تغييرات URL setInterval(function () { const currentUrl = window.location.href; if (currentUrl !== lastUrl) { console.log("URL changed to: " + currentUrl); isBlogPage = window.location.pathname === "/blog"; // تحديث حالة الصفحة // إذا كنت قادمًا من صفحة تدوينة (تحتوي على /blog/ وليس فقط /blog) if (!isBlogPage && window.location.pathname.includes("/blog/")) { wasOnPostPage = true; } // أعد التوجيه فقط إذا كنت في المدونة وقادمًا من تدوينة if (isBlogPage && window.location.search.includes("page=") && wasOnPostPage) { console.log("Page parameter detected after returning from post, redirecting..."); window.location.href = "https://bayounishop.com.sa/blog"; wasOnPostPage = false; // إعادة تعيين } lastUrl = currentUrl; } }, 500); // تحقق كل نصف ثانية })(); document.addEventListener("DOMContentLoaded", function () { // البحث عن td يحتوي على النص المطلوب const tdList = document.querySelectorAll('td'); tdList.forEach(td => { if (td.innerHTML.includes("المغسلة: 100سمx50سمx25cm")) { // تعديل المحتوى فقط لهذا العنصر let newContent = ` المغسلة: 100 سم × 50 سم × 25 سم
الرف: 100 سم × 50 سم × 10 سم `; td.innerHTML = newContent; } }); }); // تحديد جميع العناصر في الصفحة let cells = document.querySelectorAll('td'); // مصفوفة من الجمل والاستبدالات المطلوبة const replacements = [ { match: 'المادة سيراميك مع حوض', replace: text => text.replace('المادة ', '') }, { match: 'cm', replace: text => text.replace('cm', 'سم') // إذا كنت تريد الحذف ضع '' }, { match: ' x ', replace: text => text.replace(' x ', '×') // إذا كنت تريد الحذف ضع '' }, { match: 'x ', replace: text => text.replace('x ', '×') // إذا كنت تريد الحذف ضع '' }, { match: 'نعم، المادة من السيراميك مع حوض مغسلة من الفخار الحقيقي المقاوم للتشقق.', replace: () => 'نعم الحوض من الفخار الحقيقي المقاوم للتشقق' } ]; // المرور على كل عنصر وتطبيق الاستبدالات cells.forEach(cell => { replacements.forEach(({ match, replace }) => { if (cell.innerHTML.includes(match)) { cell.innerHTML = replace(cell.innerHTML); } }); }); let productDescription = document.querySelector('.product__description.leading-7'); if (productDescription) { let existingTable = productDescription.querySelector('table'); if (!existingTable) { let bulletList = productDescription.querySelector('ul'); if (bulletList) { // مصفوفات لتخزين الصفوف let rowsWithProps = []; let rowsFreeText = []; let listItems = bulletList.querySelectorAll(':scope > li'); listItems.forEach(item => { let nestedList = item.querySelector('ul'); if (nestedList) { let mainText = item.childNodes[0].textContent.trim(); let subItems = []; nestedList.querySelectorAll('li').forEach(subItem => { subItems.push(subItem.textContent.trim()); }); rowsWithProps.push([mainText || 'تفاصيل إضافية', subItems.join(' / ')]); } else { let text = item.textContent.trim(); let parts = text.split(/[::]/); if (parts.length >= 2) { rowsWithProps.push([parts[0].trim(), parts.slice(1).join(':').trim()]); } else { rowsFreeText.push(text); } } }); // إنشاء دالة لإنشاء جدول خصائص function createTable(rows, headers) { let table = document.createElement('table'); table.style.border = '1px solid #ddd'; table.style.borderCollapse = 'collapse'; table.style.width = '100%'; table.style.marginBottom = '16px'; let thead = document.createElement('thead'); let headerRow = document.createElement('tr'); headers.forEach(text => { let th = document.createElement('th'); th.textContent = text; th.style.border = '1px solid #ddd'; th.style.padding = '8px'; th.style.backgroundColor = '#f4f4f4'; th.style.textAlign = 'right'; headerRow.appendChild(th); }); thead.appendChild(headerRow); table.appendChild(thead); let tbody = document.createElement('tbody'); rows.forEach(([col1, col2]) => { let row = document.createElement('tr'); [col1, col2].forEach(cellText => { let td = document.createElement('td'); td.textContent = cellText; td.style.border = '1px solid #ddd'; td.style.padding = '8px'; row.appendChild(td); }); tbody.appendChild(row); }); table.appendChild(tbody); return table; } // إنشاء دالة لعرض النصوص الحرة كمعلومات إضافية function createFreeTextTable(rows) { let table = document.createElement('table'); table.style.border = '1px solid #ddd'; table.style.borderCollapse = 'collapse'; table.style.width = '100%'; let thead = document.createElement('thead'); let headerRow = document.createElement('tr'); let th = document.createElement('th'); th.textContent = 'معلومات إضافية'; th.style.border = '1px solid #ddd'; th.style.padding = '8px'; th.style.backgroundColor = '#f9f9f9'; th.style.textAlign = 'right'; th.colSpan = 2; headerRow.appendChild(th); thead.appendChild(headerRow); table.appendChild(thead); let tbody = document.createElement('tbody'); rows.forEach(text => { let row = document.createElement('tr'); let td = document.createElement('td'); td.textContent = text; td.colSpan = 2; td.style.border = '1px solid #ddd'; td.style.padding = '8px'; row.appendChild(td); tbody.appendChild(row); }); table.appendChild(tbody); return table; } // إنشاء الجداول النهائية let finalFragment = document.createDocumentFragment(); if (rowsWithProps.length > 0) { let propsTable = createTable(rowsWithProps, ['الخاصية', 'الوصف']); finalFragment.appendChild(propsTable); } if (rowsFreeText.length > 0) { let extraTable = createFreeTextTable(rowsFreeText); finalFragment.appendChild(extraTable); } // استبدال القائمة بالجدول/الجداول bulletList.replaceWith(finalFragment); } } } document.addEventListener("DOMContentLoaded", function () { const dimensionPattern = /(\d+)\s*سم\s*[×xX]\s*(\d+)\s*سم\s*[×xX]\s*(\d+)\s*(سم|cm)/gi; document.querySelectorAll("h1, h2, h3, p").forEach(function (el) { if (el.children.length === 0 && !el.dataset.fixed) { let text = el.textContent; // استبدال cm بكلمة "سم" text = text.replace(/\s*cm\b/gi, " سم"); // إضافة مسافة بين الرقم و"سم" إذا كانت ملتصقة text = text.replace(/(\d+)\s*سم/gi, "$1 سم"); // استبدال x أو X أو × بـ "×" فقط إذا لم تكن جزءاً من كلمة إنجليزية من 3 أحرف أو أكثر text = text.replace(/(?${text}`; } else { el.textContent = text; } // منع التكرار el.dataset.fixed = "true"; } }); });