(function () { "use strict"; const hostname = location.hostname.replace(/^www\./, ""); if (hostname !== "kyefkhwlan.com") return; function setupKyefSEO() { if (!document.head) return; /* * 1. META ROBOTS * Apply to ALL pages. * Never override existing robots directives. */ const existingRobots = document.head.querySelector( 'meta[name="robots" i]' ); if (!existingRobots) { const robots = document.createElement("meta"); robots.setAttribute("name", "robots"); robots.setAttribute( "content", "index, follow, max-image-preview:large, " + "max-snippet:-1, max-video-preview:-1" ); document.head.appendChild(robots); } /* * The following additions are homepage-only. */ if (location.pathname !== "/") return; /* * 2. WEB SITE SCHEMA * Check recursively for existing WebSite schema. */ function hasWebSite(value) { if (!value || typeof value !== "object") { return false; } if (Array.isArray(value)) { return value.some(hasWebSite); } const types = [].concat(value["@type"] || []); if (types.includes("WebSite")) { return true; } return Object.values(value).some(hasWebSite); } const schemaExists = Array.from( document.querySelectorAll( 'script[type="application/ld+json"]' ) ).some(el => { try { return hasWebSite( JSON.parse(el.textContent) ); } catch (error) { return false; } }); if (!schemaExists) { const schema = { "@context": "https://schema.org", "@type": "WebSite", "@id": "https://kyefkhwlan.com/#website", "url": "https://kyefkhwlan.com/", "name": "كيف خولان", "alternateName": [ "مؤسسة كيف خولان", "Kyef Khwlan" ], "inLanguage": "ar" }; const script = document.createElement("script"); script.id = "kyefkhwlan-website-schema"; script.type = "application/ld+json"; script.textContent = JSON.stringify(schema); document.head.appendChild(script); } /* * 3. OPEN GRAPH SITE NAME * Homepage only. */ if (!document.head.querySelector( 'meta[property="og:site_name" i]' )) { const og = document.createElement("meta"); og.setAttribute("property", "og:site_name"); og.setAttribute("content", "كيف خولان"); document.head.appendChild(og); } } // Run as early as possible. if (document.head) { setupKyefSEO(); } else { document.addEventListener( "DOMContentLoaded", setupKyefSEO, { once: true } ); } })(); /* salla code*/ /* Add custom Js styles below */ (function () { function renderMultiColTables() { var selectors = [ ".product-details__description", ".product__description", "#description", ".description-content", "article", ".pro-details", ]; selectors.forEach(function (selector) { document.querySelectorAll(selector).forEach(processContainer); }); } function processContainer(targetElement) { var htmlContent = targetElement.innerHTML; var regex = /\|جدول\|([\s\S]*?)\|الجدول\|/g; if (!htmlContent.match(regex)) return; var newHtml = htmlContent.replace(regex, function (match, tableContent) { var cleanText = tableContent .replace(//gi, "\n") .replace(/<\/p>/gi, "\n") .replace(/<[^>]*>/g, "") .replace(/ /g, " "); var rows = cleanText.split("\n"); var tableHTML = ''; var isFirstRow = true; rows.forEach(function (row) { row = row.trim(); if (!row) return; var cols = row.split("|"); if (isFirstRow) { tableHTML += ""; cols.forEach(function (col) { tableHTML += ""; }); tableHTML += ""; isFirstRow = false; } else { tableHTML += ""; cols.forEach(function (col) { tableHTML += ""; }); tableHTML += ""; } }); tableHTML += "
" + col.trim() + "
" + col.trim() + "
"; return tableHTML; }); targetElement.innerHTML = newHtml; } function renderFAQ() { var selectors = [ ".product-details__description", ".product__description", "#description", ".description-content", "article", ".pro-details", ]; selectors.forEach(function (selector) { document.querySelectorAll(selector).forEach(processFAQ); }); } function processFAQ(targetElement) { var htmlContent = targetElement.innerHTML; var faqRegex = /\|اسئلة\|([\s\S]*?)\|نهاية\|/g; if (!htmlContent.match(faqRegex)) return; var newHtml = htmlContent.replace(faqRegex, function (match, faqContent) { var cleanText = faqContent .replace(//gi, "\n") .replace(/<\/p>/gi, "\n") .replace(/<[^>]*>/g, "") .replace(/ /g, " "); var lines = cleanText.split("\n"); var faqHTML = '
'; var schemaItems = []; var currentQ = ""; var currentA = ""; lines.forEach(function (line) { line = line.trim(); if (!line) return; if (line.startsWith("س")) { if (currentQ && currentA) { schemaItems.push({ "@type": "Question", "name": currentQ, "acceptedAnswer": { "@type": "Answer", "text": currentA } }); } currentQ = line.replace(/س\s*:\s*/, ""); faqHTML += '
'; faqHTML += '

' + currentQ + '

'; } else if (line.startsWith("ج")) { currentA = line.replace(/ج\s*:\s*/, ""); faqHTML += '

' + currentA + '

'; faqHTML += '
'; } }); if (currentQ && currentA) { schemaItems.push({ "@type": "Question", "name": currentQ, "acceptedAnswer": { "@type": "Answer", "text": currentA } }); } faqHTML += "
"; var faqSchema = `