// --- Đoạn cần cập nhật trong file engine.js --- ajaxHooker.protect(); ajaxHooker.filter([{ url: '.m3u8', method: 'GET' }]); ajaxHooker.hook(async request => { if (request.url.includes('.m3u8') && (request.url.includes('?') || request.url.includes('.cloudfront.net'))) { const videoKey = request.url.split('?')[0]; const isTrialFormat = request.url.includes('_0001.m3u8') || request.url.includes('preview'); if (isTrialFormat) { // ... (Đoạn mã lấy session và gọi Server giữ nguyên) ... try { // ... fetch Server ... if (response.ok && data.fullUrl) { currentVideoKey = videoKey; // Lệnh 1: Luôn tráo link cho trình duyệt web chính để mở khóa VIP request.url = data.fullUrl; // Lệnh 2: CHỈ đẩy link cho Mini Player nếu công tắc đang BẬT if (window.isMiniPlayerEnabled !== false) { window.real_m3u8_url = data.fullUrl; } if (data.isFreeTrial) showToast(`🎁 Đã dùng ${data.viewsTaken}/5 lượt xem miễn phí thiết bị`); } else { showToast("❌ Hết 5 lượt xem thử trên thiết bị này! Vui lòng nâng cấp VIP."); document.getElementById('auth-panel').style.display = 'block'; document.getElementById('vip-floating-btn').style.display = 'none'; } } catch (e) { console.error("Lỗi", e); } } else { if (currentVideoKey !== videoKey) { currentVideoKey = videoKey; // Nếu video miễn phí, cũng chỉ nạp vào Mini Player nếu công tắc BẬT if (window.isMiniPlayerEnabled !== false) { window.real_m3u8_url = request.url; } } } } }); // ---------------------------------------------- function mainLoop() { document.querySelectorAll("div.homeAdPop, div.vue-nice-modal-root, .exo-native-widget, div.preview-ui").forEach(s => s.remove()); if (window.real_m3u8_url && window.real_m3u8_url !== (window.his_m3u8_url || '')) { window.his_m3u8_url = window.real_m3u8_url; startHls(window.real_m3u8_url); } } function startHls(url) { const container = document.getElementById('mini-player-container'), videoElement = document.getElementById('mini-video'); container.style.display = 'block'; if (Hls.isSupported()) { const hls = new Hls({ maxBufferLength: 30 }); hls.loadSource(url); hls.attachMedia(videoElement); hls.on(Hls.Events.MANIFEST_PARSED, () => videoElement.play().catch(() => {})); } else if (videoElement.canPlayType('application/vnd.apple.mpegurl')) { videoElement.src = url; videoElement.play(); } }