-
-
Save bwasty/b841ef42f27e90d9c19567dd6081c59d to your computer and use it in GitHub Desktop.
lipyantar-language-reactor-netflix
This file contains 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
// bookmarklet-title: lipyantar-language-reactor-netflix | |
// bookmarklet-about: Transliterates Devanagari subtitles to ISO/IAST when using Language Reactor | |
let current_subtitle_element = null; | |
function transliterate_current_subtitle(timestamp) { | |
window.transliterationAnimFrameID = window.requestAnimationFrame(transliterate_current_subtitle); | |
let el = document.getElementById('lln-subs'); | |
if (!el || el == current_subtitle_element) | |
return; | |
let translit_div = document.createElement('div'); | |
translit_div.style = "font-size: 0.9em; color: lightgreen"; | |
translit_div.className = 'lln-whole-title-translation'; | |
let text = el.innerText; | |
let translit = Sanscript.t(text, 'devanagari', 'iso', {syncope: true}); | |
translit_div.innerText = translit; | |
el.insertAdjacentElement('afterend', translit_div); | |
current_subtitle_element = el; | |
} | |
function setupTransliteration() { | |
window.cancelAnimationFrame(window.transliterationAnimFrameID); | |
transliterate_current_subtitle(); | |
} | |
if (!window.Sanscript) { | |
let script = document.createElement('script'); | |
script.src = 'https://cdn.jsdelivr.net/npm/@sanskrit-coders/sanscript@1.2.0/sanscript.min.js'; | |
script.type = 'text/javascript'; | |
script.async = true; | |
script.onload = function(){ | |
setupTransliteration(); | |
}; | |
document.body.appendChild(script); | |
} | |
else { | |
setupTransliteration(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment