// Netflix-style Homepage for Salla
document.addEventListener('DOMContentLoaded', function() {
// 1. إنشاء الهيدر بأزرار الدعم والمنتجات
function createNetflixHeader() {
// إزالة الهيدر الحالي إذا موجود
const oldHeader = document.querySelector('header, .header, .s-header');
if (oldHeader) {
oldHeader.style.display = 'none';
}
// إنشاء الهيدر الجديد
const header = document.createElement('header');
header.className = 'netflix-header';
header.innerHTML = `
أفلام ومسلسلات لا حصر لها والمزيد
بسعر يبدأ من 35 رس. اشترك الآن واستمتع
هل أنت جاهز للمشاهدة؟ أدخل بريدك الإلكتروني لإنشاء عضويتك أو إعادة تشغيلها.
`;
// تطبيق تأثير التدرج على الصورة
hero.style.cssText = `
position: relative;
height: 100vh;
width: 100%;
background: linear-gradient(to top, #141414 0%, transparent 50%),
linear-gradient(to right, #141414 0%, transparent 30%),
url('https://images.unsplash.com/photo-1536440136628-849c177e76a1?ixlib=rb-1.2.1&auto=format&fit=crop&w=1925&q=80');
background-size: cover;
background-position: center;
background-repeat: no-repeat;
display: flex;
align-items: center;
justify-content: center;
text-align: center;
`;
// إضافة طبقة داكنة فوق الصورة
const overlay = document.createElement('div');
overlay.style.cssText = `
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: linear-gradient(to bottom, rgba(0,0,0,0.3) 0%, rgba(0,0,0,0.7) 100%);
z-index: 1;
`;
hero.appendChild(overlay);
document.body.appendChild(hero);
// جعل البانر هو المحتوى الرئيسي
document.body.insertBefore(hero, document.body.firstChild.nextSibling);
// حدث زر البدء
document.getElementById('start-watching').addEventListener('click', function() {
const email = document.querySelector('.email-form input').value;
if (email && email.includes('@')) {
alert('شكراً لتسجيلك! ستتلقى رابط التنشيط على بريدك الإلكتروني.');
// يمكنك إضافة تحويل إلى صفحة الدفع هنا
window.location.href = '/checkout';
} else {
alert('الرجاء إدخال بريد إلكتروني صحيح');
}
});
// حدث عند الضغط على Enter في حقل الإيميل
document.querySelector('.email-form input').addEventListener('keypress', function(e) {
if (e.key === 'Enter') {
document.getElementById('start-watching').click();
}
});
}
// 3. إخفاء جميع المنتجات نهائياً
function hideAllProducts() {
const selectors = [
'.product', '.products', '.product-list', '.product-grid',
'.product-item', '.product-card', '[class*="product"]',
'[class*="Product"]', '#products', 'main', 'section'
];
selectors.forEach(selector => {
document.querySelectorAll(selector).forEach(element => {
if (element.innerHTML.includes('منتج') ||
element.innerHTML.includes('product') ||
element.innerHTML.includes('Product') ||
element.classList.toString().includes('product')) {
element.style.display = 'none';
element.style.visibility = 'hidden';
element.style.opacity = '0';
element.style.height = '0';
element.style.overflow = 'hidden';
}
});
});
// إخفاء الفوتر أيضاً
document.querySelectorAll('footer, .footer, .s-footer').forEach(footer => {
footer.style.display = 'none';
});
}
// 4. ضمان بقاء الصفحة نظيفة
function cleanPage() {
// إزالة أي عناصر قد تظهر
setInterval(() => {
hideAllProducts();
// إخفاء أي عناصر جديدة قد تظهر
document.querySelectorAll('*').forEach(el => {
const text = el.textContent || '';
const classes = el.className || '';
if (text.includes('ريال') ||
text.includes('سعر') ||
text.includes('SAR') ||
classes.includes('price') ||
classes.includes('add-to-cart') ||
el.tagName === 'BUTTON' && text.includes('شراء')) {
el.style.display = 'none';
}
});
}, 1000);
}
// 5. تهيئة كل شيء
function initializeNetflixPage() {
// إخفاء كل شيء أولاً
document.body.style.overflow = 'hidden';
// إنشاء الهيدر
createNetflixHeader();
// إنشاء البانر الرئيسي
createHeroBanner();
// إخفاء المنتجات
hideAllProducts();
// تنظيف الصفحة باستمرار
cleanPage();
// إعادة تفعيل التمرير بعد تحميل كل شيء
setTimeout(() => {
document.body.style.overflow = 'auto';
}, 2000);
}
// بدء التحميل
setTimeout(initializeNetflixPage, 500);
// إعادة التهيئة عند تغيير المحتوى
const observer = new MutationObserver(initializeNetflixPage);
observer.observe(document.body, { childList: true, subtree: true });
});