/* Add custom Js styles below */ // ====== تعديل تنسيق وهيدر الصفحة لصفحات /tag- ====== // يشغّل فقط لو الـ URL يحتوي على "/tag-" (function () { 'use strict'; if (location.href.indexOf('/tag-') === -1) return; // خروج سريع إذا مش صفحة تاج const XPATH = '//*[@id="app"]/div[3]/div/div/div[1]/h1'; let applied = false; // تطبيق التغييرات عند وجود العنصر function applyIfFound() { if (applied) return; const node = document.evaluate(XPATH, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; if (!node) return false; // 1) تغيير المارجن توب node.style.marginTop = '50px'; // 2) الحصول على نص العنصر وتحديث العنوان والميتا const titleText = (node.textContent || '').trim(); if (titleText) { // وثبّت try { document.title = titleText; } catch (e) { /* ignore */ } // دالة لاضافة/تحديث ميتا بسهولة function upsertMeta(attrName, isProperty = false) { const selector = isProperty ? `meta[property="${attrName}"]` : `meta[name="${attrName}"]`; let el = document.head.querySelector(selector); if (!el) { el = document.createElement('meta'); if (isProperty) el.setAttribute('property', attrName); else el.setAttribute('name', attrName); document.head.appendChild(el); } el.setAttribute('content', titleText); } upsertMeta('title', false); // <meta name="title" content="..."> upsertMeta('og:title', true); // <meta property="og:title" content="..."> upsertMeta('twitter:title', false); // <meta name="twitter:title" content="..."> } applied = true; return true; } // حاول التطبيق الآن (إن كان DOM جاهز) if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', applyIfFound); } else { setTimeout(applyIfFound, 0); } // إذا العنصر يظهر بعد تحميل الصفحة (مثلاً SPA أو تحميل ديناميكي)، نراقب DOM const observer = new MutationObserver(() => { if (applyIfFound()) { observer.disconnect(); } }); observer.observe(document.documentElement || document.body, { childList: true, subtree: true }); // نراقب تغيّر عنوان الـ URL في صفحات SPA (pushState/replaceState/popstate) (function() { const wrap = (fnName) => { const original = history[fnName]; history[fnName] = function () { const ret = original.apply(this, arguments); window.dispatchEvent(new Event('urlchange')); return ret; }; }; wrap('pushState'); wrap('replaceState'); window.addEventListener('popstate', () => window.dispatchEvent(new Event('urlchange'))); window.addEventListener('urlchange', () => { // إذا خرجنا من /tag- نوقف المراقبة لاحقاً if (location.href.indexOf('/tag-') === -1) { observer.disconnect(); applied = false; return; } // لو دخلنا صفحة /tag- جديدة نعيد المحاولة applied = false; setTimeout(() => { if (applyIfFound()) observer.disconnect(); }, 50); }); })(); })(); // ====== تعديل تنسيق وهيدر الصفحة لصفحات /tag- ====== // ====== تعديل تنسيق FAQ ====== (function () { // ===== inject styles (once) ===== if (!document.getElementById('seo-faq-pro-styles')) { const css = ` /* container tweaks (optional) */ .seo-faq-wrapper { width:100%; } /* السؤال (الهيدر) */ .seo-faq-h3 { cursor: pointer !important; background: #008249 !important; color: #fff !important; padding: 14px 16px !important; border-radius: 8px !important; margin: 12px 0 6px 0 !important; display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 1rem; line-height: 1.2; border: none; outline: none; } .seo-faq-h3:focus { box-shadow: 0 0 0 3px rgba(0,130,73,0.15); } /* السهم */ .seo-faq-h3 .seo-faq-chevron { width: 20px; height: 20px; display: inline-block; transition: transform 250ms ease; flex: 0 0 20px; } .seo-faq-h3[aria-expanded="true"] .seo-faq-chevron { transform: rotate(180deg); } .seo-faq-chevron svg { display:block; width:100%; height:100%; } /* الإجابة */ .seo-faq-answer { display: block !important; max-height: 0; overflow: hidden; transition: max-height 320ms ease, padding 220ms ease; background: #fff; padding: 0 16px; border-radius: 8px; border: 1px solid rgba(0,0,0,0.06); margin-bottom: 6px; box-sizing: border-box; } .seo-faq-answer.open { /* max-height set inline */ } /* روابط داخل الإجابة بلون أخضر */ .seo-faq-answer a, .SEO-Content p a { color: #008249 !important; text-decoration: underline !important; } /* نص الفقرة داخل الإجابة */ .seo-faq-answer p { margin: 12px 0; } /* اختياري: إذا أردت أن تبدو الإجابة ككتلة واحدة داخل الفقرة */ .seo-faq-answer .inner { padding: 12px 0; } `; const st = document.createElement('style'); st.id = 'seo-faq-pro-styles'; st.appendChild(document.createTextNode(css)); document.head.appendChild(st); } // ===== selectors to look for ===== const CONTAINER_SELECTORS = [ ".SEO-Content", "#app > div.container > div > div > div.flex.min-h-screen" ]; // توليد id فريد function uid(prefix = 'seofaq') { return prefix + '-' + Math.random().toString(36).slice(2, 9); } // تفعيل الأكورديون داخل حاوية محددة function activateFaqIn(container) { if (!container || container.dataset.seoFaqActivated === '1') return; container.dataset.seoFaqActivated = '1'; container.classList.add('seo-faq-wrapper'); const headings = Array.from(container.querySelectorAll('h3')); if (!headings.length) return; headings.forEach((h3, idx) => { if (h3.dataset.seoFaqProcessed === '1') return; const p = h3.nextElementSibling; if (!p || p.tagName.toLowerCase() !== 'p') { h3.dataset.seoFaqProcessed = '1'; return; } // wrap answer content for padding control const answerWrapper = document.createElement('div'); answerWrapper.className = 'seo-faq-answer'; const inner = document.createElement('div'); inner.className = 'inner'; // انقل محتوى الفقرة داخل inner while (p.firstChild) inner.appendChild(p.firstChild); answerWrapper.appendChild(inner); // استبدل <p> بعنصر الإجابة p.parentNode.replaceChild(answerWrapper, p); // اضف صفات الـ accessibility على الهيدر const panelId = uid('panel'); const btnId = uid('btn'); h3.setAttribute('role', 'button'); h3.setAttribute('id', btnId); h3.setAttribute('aria-controls', panelId); h3.setAttribute('aria-expanded', 'false'); h3.classList.add('seo-faq-h3'); // اجعل الهيدر قابلاً للتركيز لو لم يكن كذلك if (!h3.hasAttribute('tabindex')) h3.setAttribute('tabindex', '0'); // أنشئ عنصر السهم (SVG) داخل الهيدر const chevron = document.createElement('span'); chevron.className = 'seo-faq-chevron'; chevron.innerHTML = ` <svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"> <path d="M6.23 8.21a.75.75 0 0 1 1.06-.02L12 12.9l4.71-4.71a.75.75 0 0 1 1.06 1.06l-5.24 5.24a.75.75 0 0 1-1.06 0L6.25 9.25a.75.75 0 0 1-.02-1.04z" fill="currentColor"/> </svg> `; // أضف السهم إلى الهيدر (نضعه في النهاية) h3.appendChild(chevron); // ضع الـ panel attributes answerWrapper.setAttribute('id', panelId); answerWrapper.setAttribute('role', 'region'); answerWrapper.setAttribute('aria-labelledby', btnId); // أعد ضبط maxHeight لضمان الانطلاقة الصحيحة answerWrapper.style.maxHeight = '0'; // حدث الفتح/الغلق function openPanel() { // أغلق الباقي في نفس الحاوية (سلوك سؤال واحد مفتوح) const otherOpened = container.querySelectorAll('.seo-faq-h3[aria-expanded="true"]'); otherOpened.forEach(o => { if (o === h3) return; const pid = o.getAttribute('aria-controls'); const panel = document.getElementById(pid); if (panel) { panel.style.maxHeight = '0'; o.setAttribute('aria-expanded', 'false'); } }); answerWrapper.style.maxHeight = (answerWrapper.scrollHeight + 24) + 'px'; h3.setAttribute('aria-expanded', 'true'); answerWrapper.classList.add('open'); } function closePanel() { answerWrapper.style.maxHeight = '0'; h3.setAttribute('aria-expanded', 'false'); answerWrapper.classList.remove('open'); } function togglePanel() { const isOpen = h3.getAttribute('aria-expanded') === 'true'; if (isOpen) closePanel(); else openPanel(); } // النقر h3.addEventListener('click', togglePanel); // لوحة المفاتيح: Enter/Space لتبديل، Arrow Up/Down للتنقل بين الهيدرز h3.addEventListener('keydown', function (ev) { const key = ev.key || ev.keyCode; if (key === 'Enter' || key === ' ' || key === 13 || key === 32) { ev.preventDefault(); togglePanel(); return; } if (key === 'ArrowDown' || key === 'Down' || key === 40) { ev.preventDefault(); const next = headings[(idx + 1) % headings.length]; if (next) next.focus(); return; } if (key === 'ArrowUp' || key === 'Up' || key === 38) { ev.preventDefault(); const prev = headings[(idx - 1 + headings.length) % headings.length]; if (prev) prev.focus(); return; } if (key === 'Home' || key === 36) { ev.preventDefault(); const first = headings[0]; if (first) first.focus(); return; } if (key === 'End' || key === 35) { ev.preventDefault(); const last = headings[headings.length - 1]; if (last) last.focus(); return; } }); // وسمت المعالجة h3.dataset.seoFaqProcessed = '1'; }); } // حاول التفعيل فورًا function findAndActivateOnce() { for (let sel of CONTAINER_SELECTORS) { const node = document.querySelector(sel); if (node) activateFaqIn(node); } } findAndActivateOnce(); // راقب DOM لتفعيل لو المحتوى محمّل بعدين const observer = new MutationObserver((mutations) => { for (let sel of CONTAINER_SELECTORS) { const node = document.querySelector(sel); if (node) activateFaqIn(node); } }); observer.observe(document.documentElement || document.body, { childList: true, subtree: true }); console.log("SEO-FAQ PRO loaded — professional FAQ enabled."); })(); // ====== تعديل تنسيق FAQ ======