Last active
January 8, 2022 10:57
-
-
Save rousan/c8977f3f7dac79c03f0227c35eac1b47 to your computer and use it in GitHub Desktop.
Netflix doesn't provide any keyboard shortcut to toggle English subtitle, so inject the following script to enable that feature. Keyboard Shortcut: Ctrl + S
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.addEventListener("keypress", (evt) => { | |
if (evt.ctrlKey && evt.keyCode === 19) { | |
console.log("Subtitle shortcut triggered"); | |
const btn = document.querySelector(".button-nfplayerSubtitles"); | |
if (!btn) { | |
return; | |
} | |
const parent = btn.parentElement; | |
if (!parent) { | |
return; | |
} | |
btn.click(); | |
const allTracks = [...parent.querySelectorAll(".track-list-subtitles li.track")]; | |
const englishTrack = allTracks.find(track => track.textContent.toLowerCase().includes("english")); | |
if (!englishTrack) { | |
return; | |
} | |
const offTrack = allTracks.find(track => track.textContent.toLowerCase().includes("off")); | |
if (!offTrack) { | |
return; | |
} | |
if (englishTrack.getAttribute("class").includes("selected")) { | |
offTrack.click(); | |
} else { | |
englishTrack.click(); | |
} | |
btn.click(); | |
} | |
}); |
It seems to be not working anymore.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is so great!