/* أكواد تحسين الأداء — PlayUrPlay */ // Inject preconnect & preload into
(function () { try { var h = document.head; [ ["https://fonts.gstatic.com", true], ["https://cdn.salla.sa", true], ["https://static.salla.sa", true] ].forEach(function (item) { var link = document.createElement("link"); link.rel = "preconnect"; link.href = item[0]; if (item[1]) link.crossOrigin = "anonymous"; h.appendChild(link); }); var style = document.createElement("style"); style.textContent = "@font-face{font-display:swap!important}"; h.appendChild(style); var preload = document.createElement("link"); preload.rel = "preload"; preload.as = "image"; preload.href = "https://playurplay.com/path/to/hero-1920x700.webp"; // عدّل للرابط الفعلي preload.fetchPriority = "high"; h.appendChild(preload); } catch(e) {} })(); // Delay non-critical scripts (function () { const delayLoad = () => { document.querySelectorAll('script[data-delay]').forEach(s => { const n = document.createElement('script'); [...s.attributes].forEach(a => { if (a.name!=='data-delay') n.setAttribute(a.name, a.value); }); n.async = true; s.replaceWith(n); }); }; window.addEventListener('load', () => { if ('requestIdleCallback' in window) requestIdleCallback(delayLoad, {timeout:3000}); else setTimeout(delayLoad, 1200); }); })(); // Lazy load images & videos document.addEventListener('DOMContentLoaded', () => { let count = 0; document.querySelectorAll('img:not([loading])').forEach(img => { count++; if (count > 2) img.setAttribute('loading','lazy'); img.setAttribute('decoding','async'); if (count > 2) img.setAttribute('fetchpriority','low'); }); document.querySelectorAll('iframe,video').forEach(el => el.setAttribute('loading','lazy')); }); /* كود الترحيب — يبقى كما هو */ // تحقق إذا المستخدم زار الموقع من قبل if (!localStorage.getItem("welcome_shown")) { const popup = document.createElement("div"); popup.innerHTML = `🎉 مرحباً بك في متجر العـب لعبك!`; Object.assign(popup.style, { position: "fixed", bottom: "20px", left: "20px", background: "#1e1e1e", color: "#fff", padding: "15px 20px", borderRadius: "12px", fontSize: "16px", boxShadow: "0 0 10px rgba(0,0,0,0.5)", zIndex: 9999, }); document.body.appendChild(popup); setTimeout(() => popup.remove(), 8000); localStorage.setItem("welcome_shown", "true"); }