diff --git a/background.js b/background.js index f42e6b4..5a8b0d0 100644 --- a/background.js +++ b/background.js @@ -67,6 +67,11 @@ chrome.runtime.onMessage.addListener((message, sender, sendResponse) => { return true; } + if (message.type === 'OPEN_PERMISSION_PAGE') { + chrome.tabs.create({ url: chrome.runtime.getURL('claude-arabic-voice/permission.html') }); + return true; + } + if (message.type.startsWith('OFFSCREEN_RECORDING_')) { if (recordingTabId) { chrome.tabs.sendMessage(recordingTabId, message).catch(() => {}); diff --git a/claude-arabic-voice/content.js b/claude-arabic-voice/content.js index 563c31d..2f7b12d 100644 --- a/claude-arabic-voice/content.js +++ b/claude-arabic-voice/content.js @@ -70,7 +70,13 @@ return; // offscreen script restarts it automatically } stopListening(); - showStatus('error', '❌ خطأ: ' + getArabicError(message.payload.error)); + + if (message.payload.error === 'not-allowed') { + showStatus('error', '❌ الرجاء منح الصلاحية (تم فتح صفحة جديدة)'); + chrome.runtime.sendMessage({ type: 'OPEN_PERMISSION_PAGE' }); + } else { + showStatus('error', '❌ خطأ: ' + getArabicError(message.payload.error)); + } } else if (message.type === 'OFFSCREEN_RECORDING_END') { if (isListening) { // Unexpected end from offscreen while we still consider ourselves listening diff --git a/claude-arabic-voice/permission.html b/claude-arabic-voice/permission.html new file mode 100644 index 0000000..5238e5d --- /dev/null +++ b/claude-arabic-voice/permission.html @@ -0,0 +1,70 @@ + + + + + + السماح باستخدام الميكروفون + + + +
+
🎤
+

مطلوب إذن الميكروفون

+

ميزة الإملاء الصوتي تحتاج إلى إذن للوصول إلى الميكروفون لتعمل بشكل صحيح في الخلفية.

+

يرجى الضغط على الزر أدناه والموافقة على طلب الصلاحية من المتصفح.

+ +

+
+ + + diff --git a/claude-arabic-voice/permission.js b/claude-arabic-voice/permission.js new file mode 100644 index 0000000..842aee5 --- /dev/null +++ b/claude-arabic-voice/permission.js @@ -0,0 +1,19 @@ +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 = '✅ تم منح الصلاحية بنجاح! يمكنك إغلاق هذه النافذة والعودة إلى Claude.'; + + // Auto close after 3 seconds + setTimeout(() => { + window.close(); + }, 3000); + } catch (err) { + status.style.color = '#ff4d6d'; + status.textContent = '❌ حدث خطأ أو تم رفض الصلاحية: ' + err.message; + } +});