fix: skip selectDubbedLanguage when disable_auto_dubbing is enabled
Problem
Fixes #3950 — "Disable auto dubbing" option ignored when defaultDubbedLanguage is set
When "Disable auto dubbing" and "Hide auto-dubbed options in menu" are both enabled, and a language is selected in defaultDubbedLanguage, YouTube still plays auto-dubbed audio.
Root Cause
In functions.js L461, selectDubbedLanguage() is called whenever player_default_dubbed_language is set — regardless of whether disable_auto_dubbing is enabled.
Execution order:
disableAutoDubbing()runs → selects original audio trackselectDubbedLanguage()runs → overwrites with auto-dubbed track
Since selectDubbedLanguage() runs last, it overrides the original track selection.
Fix
Add disable_auto_dubbing !== true check before calling selectDubbedLanguage():
// Before:
if (ImprovedTube.storage.player_default_dubbed_language && ImprovedTube.storage.player_default_dubbed_language !== 'disabled') {
ImprovedTube.selectDubbedLanguage();
}
// After:
if (ImprovedTube.storage.player_default_dubbed_language && ImprovedTube.storage.player_default_dubbed_language !== 'disabled' && ImprovedTube.storage.disable_auto_dubbing !== true) {
ImprovedTube.selectDubbedLanguage();
}
Testing
- [ ] Enable "Disable auto dubbing" + set defaultDubbedLanguage → should play original audio
- [ ] Disable "Disable auto dubbing" + set defaultDubbedLanguage → should play dubbed audio
- [ ] Enable "Disable auto dubbing" without defaultDubbedLanguage → should play original audio
Hi!
When "Disable auto dubbing" is enabled, the extension should completely avoid auto-generated dubs.
The logic should be:
- If the user has selected a language in
defaultDubbedLanguageand there is a real (non-auto-generated) dub available for that language → use it. - If there is no real dub for the selected
defaultDubbedLanguage(or only auto-generated dubs exist), then fall back to the original audio track.
In other words: we should only use the language from defaultDubbedLanguage when it's a real dub. Otherwise, original audio should be preferred over any auto-generated dubbing.
@muhamedfazalps
https://youtu.be/90yD3r_dCFY?si=1gJ-in_4XIT7DFv4 This is my YouTube channel to learn Spoken English. Please Subscribe to get latest notifications.Thank you.
On Tue, Jun 23, 2026, 9:56 PM MUHAMED FAZAL PS @.***> wrote:
muhamedfazalps left a comment (code-charity/youtube#3955) https://github.com/code-charity/youtube/pull/3955#issuecomment-4781276136
@communism420 https://github.com/communism420 Thanks for the detailed feedback! I have updated the fix to match the expected behavior:
Updated logic:
- disableAutoDubbing() runs first and selects the original audio track (fallback)
- selectDubbedLanguage(skipAutoGenerated=true) then tries to find a real (non-auto) dub for the selected language
- If a real dub exists → uses it (overriding the original selection)
- If no real dub exists → original audio remains from step 1
Key change: selectDubbedLanguage() now accepts a skipAutoGenerated parameter. When true, it only matches exact language codes (e.g. "en") and skips auto-generated dubs with numeric suffixes (e.g. "en.1", "en.2").
This means:
- Real dubs are still used when available (even with disable_auto_dubbing)
- Auto-generated dubs are properly skipped
- Original audio is the fallback when no real dub exists
Please review the updated changes!
— Reply to this email directly, view it on GitHub https://github.com/code-charity/youtube/pull/3955?email_source=notifications&email_token=AM6MBOGH64EP65OW4BTLXU35BKVUHA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTINZYGEZDONRRGM3KM4TFMFZW63VKON2WE43DOJUWEZLEUVSXMZLOOSWGM33PORSXEX3DNRUWG2Y#issuecomment-4781276136, or unsubscribe https://github.com/notifications/unsubscribe-auth/AM6MBOA6JZBXTJNASVUJEID5BKVUHAVCNFSNUABFKJSXA33TNF2G64TZHMYTEMZVGYZTINRUHNEXG43VMU5TINRTHA2DQMBRGI42C5QC . Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS https://github.com/notifications/mobile/ios/AM6MBOBABXLKB3IP76H2VZD5BKVUHA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTINZYGEZDONRRGM3KM4TFMFZW63VKON2WE43DOJUWEZLEUVSXMZLOOSVGM33PORSXEX3JN5ZQ and Android https://github.com/notifications/mobile/android/AM6MBOE7WB7YNYQW4CM4GUD5BKVUHA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTINZYGEZDONRRGM3KM4TFMFZW63VKON2WE43DOJUWEZLEUVSXMZLOOSXGM33PORSXEX3BNZSHE33JMQ. Download it today! You are receiving this because you are subscribed to this thread.Message ID: @.***>