document.getElementById('grantBtn').addEventListener('click', async () => { const status = document.getElementById('status'); try { const stream = await navigator.mediaDevices.getUserMedia({ audio: true }); // Stop the tracks immediately since we only needed to ask for permission stream.getTracks().forEach(track => track.stop()); status.style.color = '#00d67e'; status.textContent = '✅ تم منح الصلاحية بنجاح! يمكنك إغلاق هذه النافذة والعودة إلى الإضافة.'; // Auto close after 3 seconds setTimeout(() => { window.close(); }, 3000); } catch (err) { status.style.color = '#ff4d6d'; status.textContent = '❌ حدث خطأ أو تم رفض الصلاحية: ' + err.message; } });