Skip to content

Conversation

dewan-sahib
Copy link
Contributor

@dewan-sahib dewan-sahib commented Jul 10, 2025

Fixes: Issue #3013
This PR introduces a feature to automatically mute audio during YouTube ads (both skippable and unskippable), and restore the user's original unmute state after the ad ends.

Features:

  • Detects ad playback using player.classList.contains("ad-showing") + video.duration < 40
  • Saves mute state before ad and restores it after
  • Works on:
    • Skippable ads
    • Unskippable ads
    • SPA transitions
    • Full page reloads
  • Uses a short fallback retry loop to handle late DOM availability
  • Controlled by the "Mute Ads" option in the settings UI

Files Touched:

  • general.js – Added "Mute Ads" setting to dropdown
  • player.js – Added muteAds() logic
  • functions.js
    • Hooked muteAds() into movie_player mutation
    • Added fallback loader for full reloads

Kindly let me know if any changes are needed.

@ImprovedTube
Copy link
Member

Thank you! @dewan-sahib - As of now (2025) it enabled reviewability on github and github change logs, if you don't submit beautifcation changes by your IDE ("+4,054 -2,740").

Besides we can also look for a github action - or develope one, to adjust such PRs automatically.

@ImprovedTube
Copy link
Member

hi @dewan-sahib

@ImprovedTube ImprovedTube marked this pull request as draft August 26, 2025 22:21
@ImprovedTube ImprovedTube marked this pull request as draft August 26, 2025 22:21
@dewan-sahib
Copy link
Contributor Author

Hello @ImprovedTube , apologies for the delay. I had some personal matters to take care of and was away from open source for a while. I’m back now and will address the feedback within the next week. Thanks for your patience.

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