From 081058c07e10a4123efcce813918873887eb78c5 Mon Sep 17 00:00:00 2001 From: zrose584 <57181548+zrose584@users.noreply.github.com> Date: Sat, 12 Sep 2020 10:20:43 +0200 Subject: default to last textTrack --- youtube/static/js/common.js | 11 ++++++++++- youtube/static/js/transcript-table.js | 3 ++- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'youtube') diff --git a/youtube/static/js/common.js b/youtube/static/js/common.js index f2e62fe..4c7ee51 100644 --- a/youtube/static/js/common.js +++ b/youtube/static/js/common.js @@ -20,4 +20,13 @@ function getActiveTranscriptTrackIdx() { } return cur_tt_idx; } -function getActiveTranscriptTrack() { return Q("video").textTracks[getActiveTranscriptTrackIdx()]; } \ No newline at end of file +function getActiveTranscriptTrack() { return Q("video").textTracks[getActiveTranscriptTrackIdx()]; } + +function getDefaultTranscriptTrackIdx() { + let tts = Q("video").textTracks; + return tts.length - 1; +} + +window.addEventListener('DOMContentLoaded', function() { + cur_tt_idx = getDefaultTranscriptTrackIdx(); +}); diff --git a/youtube/static/js/transcript-table.js b/youtube/static/js/transcript-table.js index 235b1e4..6b57911 100644 --- a/youtube/static/js/transcript-table.js +++ b/youtube/static/js/transcript-table.js @@ -87,6 +87,7 @@ window.addEventListener('DOMContentLoaded', function() { option.appendChild(text(tt.label)); select_tt.appendChild(option); } + select_tt.selectedIndex = getDefaultTranscriptTrackIdx(); select_tt.addEventListener("change", loadCues); divR.appendChild(select_tt); @@ -96,7 +97,7 @@ window.addEventListener('DOMContentLoaded', function() { divR.appendChild(table_tt); tts.addEventListener("change", (e) => { - console.log(e); + // console.log(e); var idx = getActiveTranscriptTrackIdx(); // sadly not provided by 'e' if (tts[idx].mode == "showing") { select_tt.selectedIndex = idx; -- cgit v1.2.3