Skip to content

Instantly share code, notes, and snippets.

@ghukill
Last active December 10, 2017 00:54
Show Gist options
  • Save ghukill/6a151b696c751784658485775f78a8ed to your computer and use it in GitHub Desktop.
Save ghukill/6a151b696c751784658485775f78a8ed to your computer and use it in GitHub Desktop.
English subs for Hela Sverige bakar (All of Sweden Bakes)
/*
To use:
- begin playback
- make sure Google Chrome page translation is turned on
- turn on video player subs (will be Swedish with flickering English)
- paste code below into JS console
- enjoy!
*/
// create div for subtitles
$("head").append("<style id='eng_subs_style'>#eng_subs p font font{ font-size:3.5em; }</style>")
$("#bonnier-html-player").prepend("<div id='eng_subs' style='color:white; text-align:center; height:64px;'><p style='padding-top:19px;'>GOOBERTRONIC</p></div>");
// define function to capture ephemeral english subtitles and add to div
var full = null;
function get_eng_subs() {
// capture subs
l1 = $("#subtitlespan1 font font").text().replace(/\n|\r/g, "");
l2 = $("#subtitlespan2 font font").text().replace(/\n|\r/g, "");
full_new = l1 + " " + l2;
if (full_new != ' ' && full_new != full) {
full = full_new;
$("#eng_subs p font font").text(full);
}
// rerun
setTimeout(get_eng_subs, 100);
}
// hide swedish subs
$("#subtitlediv").css('visibility','hidden');
// run poll
setTimeout(get_eng_subs, 100);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment