Skip to content

Added feature to mute thumbnil previews#3681

Merged
ImprovedTube merged 2 commits intocode-charity:masterfrom
pswitchy:feat/mutebutton
Mar 7, 2026
Merged

Added feature to mute thumbnil previews#3681
ImprovedTube merged 2 commits intocode-charity:masterfrom
pswitchy:feat/mutebutton

Conversation

@pswitchy
Copy link
Copy Markdown
Contributor

@pswitchy pswitchy commented Mar 7, 2026

📋 Problem

YouTube natively mutes thumbnail previews only on initial page refresh. When hovering over a different video, the preview can start playing with audio—which is intrusive and annoying for users browsing their feed.

💡 Solution

Enhanced the existing muteThumbnailPreviews feature to forcefully mute every new thumbnail preview on hover, not just on initial page load.


🛠 Changes

js&css/extension/www.youtube.com/general/general.js

  • Added forceMute(): Attaches volumechange and play event listeners to each preview <video> element to immediately re-mute if YouTube's code tries to unmute it.
  • Added isPreviewVideo(): Helper for cleaner preview container detection.
  • Optimization: Uses _itMuteEnforced flag to ensure listeners are only attached once per video element.
  • MutationObserver: Now watches for src attribute changes to catch when YouTube reuses the same <video> element for a different hover preview.

js&css/web-accessible/www.youtube.com/playlist-cleaner.js (New)

  • Added missing stub file referenced in manifest.json web_accessible_resources—its absence was preventing the extension from loading.

⚙️ How It Works

  1. Initial Load: All existing preview videos are force-muted.
  2. Observation: A MutationObserver watches for new preview <video> elements and src attribute changes.
  3. Enforcement: Each preview video gets volumechange + play listeners that re-mute instantly if audio is restored.
  4. Scoped Impact: Only preview containers are targeted (#inline-preview-player, ytd-video-preview, etc.)—the main player is unaffected.

✅ Testing

  • All 25 existing unit tests pass
  • Manually verified it's working

@ImprovedTube ImprovedTube merged commit 50b3c27 into code-charity:master Mar 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants