How davrous/dareangel works
Project Type and Purpose
• This is a cross-browser proof-of-concept extension (“Dare Angel”) that extracts images from the active tab, displays thumbnails in a popup/dashboard, calls a Computer Vision API to describe the image, then speaks the description via Bing TTS or the Web Speech API.
Main Components
a. Manifest (manifest.json)
– Declares extension metadata, permissions (tabs, activeTab, speech), and entry points (content scripts, browser action).
b. Content Script (start.ts → start.js)
– Injects into every page (per manifest) or upon user action. Scans the DOM to collect <img> elements and sends their URLs back to the dashboard.
c. Dashboard UI (dashboard.html, dashboard.css, dareangel.dashboard.ts → .js)
– Renders the list of thumbnails and handles user clicks to select an image.
d. Client Logic (dareangel.client.ts → .js)
– Orchestrates calls to Microsoft’s Computer Vision API to retrieve image descriptions.
e. TTS Client (BingTTSClient.ts → .js)
– Wraps calls to the Bing Speech API; falls back to the Web Speech API when no key is provided.
f. TypeScript Declarations (dts/… .d.ts)
– Provides ambient typing for browser and Web APIs.
g. Build Configuration (tsconfig.json)
– Controls the TS→JS compilation target, module resolution, source maps, etc.
External Services and Browser APIs
• Microsoft Computer Vision API (HTTP REST call)
• Bing Speech (Text-to-Speech) API (HTTP REST call)
• Web Speech API (built-in browser)
• Browser Messaging (chrome.runtime.sendMessage / browser.tabs.sendMessage)
• DOM APIs (document.querySelectorAll, createElement)
High-Level Workflow and Interactions
2. dashboard.js sends a message to start.js (content script) to scan images in the active tab.
3. start.js returns an array of image URLs to the dashboard.
4. Dashboard UI displays thumbnails; user clicks one.
5. dareangel.client.js takes the selected URL → issues Computer Vision API request → receives a textual description.
6. BingTTSClient.js or Web Speech API is invoked to vocalize the description.
7. UI may display the description text alongside playing the audio stream.
Architectural Patterns and Principles
• Event-driven / message-passing between UI and content script.
• Separation of concerns: UI, page-scanning logic, API orchestration, TTS logic all in distinct modules.
• Fallback strategy for TTS (use Web Speech if Bing key missing).
• Type safety and modularity via TypeScript + declaration files.
Guidance
• External Services (Computer Vision API, Bing TTS API).
• Browser APIs (Web Speech, Messaging, DOM).
• UI → Content Script (“scan images” message)
• Content Script → UI (“image URLs” message)
• UI/Client → Computer Vision API (HTTP POST with image URL)
• UI/Client → Bing TTS API (HTTP request)
• UI/Client → Web Speech API (fallback)
• Content scripts / logic modules in another (e.g., green)