How z4kkyhub/chrome-ext-youtube-focus-suite works
Purpose and Extension Entry Points
YouTube Focus Suite is a Manifest V3 Chrome extension that combines two independently toggled YouTube behaviors: distraction-reduced video viewing and Shorts removal/redirecting. Chrome loads the extension definition from manifest.json; its runtime entry points are the service worker background.js, toolbar popup popup/popup.html, and YouTube content scripts under content/.
Manifest and Runtime Topology
manifest.json defines the extension’s permissions, host matching, content-script injection, popup, and declarative rules integration. The browser executes background.js in the MV3 service-worker lifecycle, injects feature-specific scripts/CSS into applicable YouTube pages, and opens popup/popup.html as the user-facing settings surface.
Focus Mode Feature
Focus mode targets video-watch pages and removes related videos, comments, and supporting UI through page-level CSS and DOM behavior:
• content/focus-mode.js
• content/focus-mode.css
The content script applies or removes the focus presentation based on persisted state and exposes an in-page control near the video player. This is the feature boundary most coupled to YouTube’s changing DOM structure.
Shorts Suppression Feature
Shorts removal is split between regular-page filtering and direct-navigation prevention:
• content/hide-shorts.js
• content/hide-shorts.css
• rules/shorts-redirect.json
The content layer hides Shorts cards/sections across home, subscriptions, search, and related-content surfaces. Declarative network rules redirect navigations to /shorts/* back to the home page, avoiding a content-script-only redirect path.
Settings and User Control Flow
The toolbar UI in popup/popup.html and popup/popup.js lets users toggle Focus Mode and Hide Shorts separately; styling is contained in popup/popup.css. State is stored in Chrome sync storage, so popup changes propagate to content-script behavior across signed-in Chrome instances. Focus Mode additionally accepts page-local toggling through its injected video-page button.
Background Coordination and Platform Boundaries
background.js is the privileged extension-side coordinator for browser events, state defaults or updates, and ruleset enablement as required by the Shorts setting. Content scripts operate within YouTube page contexts and should limit responsibility to DOM observation/manipulation. Chrome extension APIs—especially synchronized storage and declarative network request rules—form the key boundary between persistent settings, browser-level navigation handling, and page-level UI changes.
Infrastructure and Maintenance Constraints
This is a client-only browser extension: no backend, database, or external API service is indicated. It relies on Chrome/Chromium extension APIs and YouTube’s rendered DOM. The primary operational risk is YouTube markup changes; selectors and DOM handling in content/focus-mode.js and content/hide-shorts.js are the likely maintenance points.
Main entry points: manifest.json Extension manifest · focus-mode.js Focus Mode · hide-shorts.js Hide Shorts · background.js Background coordinator
Components 13
Extension runtime
- Extension manifest · Declares entry points, permissions, injection, and rules.
manifest.json - Background coordinator · Coordinates defaults, browser events, and ruleset state.
background.js - Sync settings · Persists independently toggled feature settings.
- Declarative rules · Applies browser-level Shorts navigation handling.
- Shorts redirect rules · Redirects /shorts/ navigations to home.
rules/shorts-redirect.json
Toolbar settings
- Settings popup · Toolbar surface for both feature toggles.
popup/popup.html - Popup controls · Reads and updates feature settings.
popup/popup.js - Popup styling
popup/popup.css
YouTube page layer
- Focus Mode · Controls watch-page UI and in-page toggle.
content/focus-mode.js - Focus presentation · Hides related videos, comments, and supporting UI.
content/focus-mode.css - Hide Shorts · Filters Shorts surfaces across YouTube pages.
content/hide-shorts.js - Shorts filtering
content/hide-shorts.css - YouTube rendered DOM · Selector-sensitive target for content scripts.
Connections 17
- Extension manifest → Background coordinator: starts
- Extension manifest → Settings popup: opens as toolbar popup
- Extension manifest → Focus Mode: injects on watch pages
- Extension manifest → Hide Shorts: injects on YouTube pages
- Extension manifest → Shorts redirect rules: registers ruleset
- Settings popup → Popup controls: loads
- Settings popup → Popup styling: styles with
- Popup controls → Sync settings: updates toggles
- Background coordinator → Sync settings: initializes and coordinates
- Background coordinator → Declarative rules: enables by Shorts setting
- Declarative rules → Shorts redirect rules: activates
- Focus Mode → Sync settings: reads and updates Focus state
- Hide Shorts → Sync settings: reads Hide Shorts state
- Focus Mode → Focus presentation: applies
- Hide Shorts → Shorts filtering: applies
- Focus Mode → YouTube rendered DOM: manipulates watch-page UI
- Hide Shorts → YouTube rendered DOM: hides Shorts surfaces