Skip to content

Instantly share code, notes, and snippets.

@djsegal
Created April 27, 2024 12:38
Show Gist options
  • Save djsegal/fd9eea3c317dffd86aa964f2d3f235c3 to your computer and use it in GitHub Desktop.
Save djsegal/fd9eea3c317dffd86aa964f2d3f235c3 to your computer and use it in GitHub Desktop.
A bookmarklet for loading German subtitles on Netflix using Language Reactor
javascript:(function() { function setTracks() { let video = document.querySelector('video'); if (!video || !window.lln || !window.lln.vidMan) return; let isGoodTrack = ( window.lln.setMan.sourceLanguageCode === "de" && window.lln.setMan.translationLanguageCode === "en" ); if (!isGoodTrack) { window.lln.vidMan.setAudioTrack("A:2:1;2;de;0;0;"); window.lln.vidMan.setSubtitleTrack("ASR_A:2:1;2;de;0;0;"); video.pause(); return; } let subsContent = document.querySelector("#lln-subs-content"); if (subsContent && subsContent.textContent.trim() === "- Loading subtitles, please wait... -") { if (!video.paused) video.pause(); setTimeout(setTracks, 1000); return; } if (video.paused) video.play(); } function waitForLLN(tries = 0) { if (document.querySelector('video') && window.lln && window.lln.vidMan) { setTracks(); return; } if (tries > 30) { console.error("Custom language connector failed."); return; } setTimeout(function() { waitForLLN(tries + 1); }, 500); } waitForLLN();})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment