How munadil16/yt-ext works
Project type and purpose
• This is a lightweight Chrome browser extension (“yt-ext”) whose sole purpose is to let users change YouTube’s playback speed up to 10×.
• Key indicators: presence of manifest.json, background.js, content.js, popup.html, and instructions about “load unpacked” and “open YouTube” in the README.
File structure
• manifest.json – declares extension metadata, permissions (e.g., activeTab, scripting), background and content scripts, popup UI.
• background.js – long-lived event listeners; typically routes messages between the popup and content script or manages state if needed.
• content.js – injected into YouTube pages; directly interacts with the page’s DOM (e.g., finds the <video> element and adjusts playbackRate).
• .gitignore, README.md – ancillary files, not part of runtime.
README for additional insights
• No larger architecture described—functionality is straightforward.
a. Main components:
1. Chrome Browser Extension Host
2. manifest.json (configuration)
3. Popup UI (popup.html + script.js + styles.css)
4. background.js (optional router, event hub)
5. content.js (injected script on YouTube pages)
6. YouTube Webpage (video player API)
7. User (triggering UI)
b. Relationships & interactions:
• Popup script captures speed selection → sends chrome.runtime.sendMessage to background or directly to content script.
• background.js (if used) receives message → relays to content.js via chrome.tabs.sendMessage.
• content.js (already injected in the YouTube tab) receives the message → locates video element → sets video.playbackRate to the new value.
c. Architectural patterns & principles:
• Event-driven, message-passing architecture.
• Single responsibility: UI code lives in popup, page manipulation in content, routing in background.
d. Key technologies & frameworks:
• Manifest V3 (or V2 depending on version)
• Chrome Extension APIs: chrome.runtime, chrome.tabs, chrome.scripting
• Vanilla JS, HTML, CSS