aboutsummaryrefslogtreecommitdiffstats
path: root/youtube/static/js/common.js
diff options
context:
space:
mode:
authorzrose584 <57181548+zrose584@users.noreply.github.com>2020-09-11 21:21:56 +0200
committerzrose584 <57181548+zrose584@users.noreply.github.com>2020-09-11 21:27:49 +0200
commit94ece08a1e04d9ba1f62000b04c7b7ca707c6ab6 (patch)
tree47afdb07ad9a4f07460fc8f28975251cf84cee00 /youtube/static/js/common.js
parent786d3eb445dfa601bcaca8ce7b5688d86a922377 (diff)
downloadyt-local-94ece08a1e04d9ba1f62000b04c7b7ca707c6ab6.tar.lz
yt-local-94ece08a1e04d9ba1f62000b04c7b7ca707c6ab6.tar.xz
yt-local-94ece08a1e04d9ba1f62000b04c7b7ca707c6ab6.zip
hotkeys.js: add 'c' for transcript
Diffstat (limited to 'youtube/static/js/common.js')
-rw-r--r--youtube/static/js/common.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/youtube/static/js/common.js b/youtube/static/js/common.js
new file mode 100644
index 0000000..f2e62fe
--- /dev/null
+++ b/youtube/static/js/common.js
@@ -0,0 +1,23 @@
+Q = document.querySelector.bind(document);
+function text(msg) { return document.createTextNode(msg); }
+function clearNode(node) { while (node.firstChild) node.removeChild(node.firstChild); }
+function toMS(s) {
+ var s = Math.floor(s);
+ var m = Math.floor(s/60); var s = s % 60;
+ return `0${m}:`.slice(-3) + `0${s}`.slice(-2);
+}
+
+
+var cur_tt_idx = 0;
+function getActiveTranscriptTrackIdx() {
+ let tts = Q("video").textTracks;
+ if (!tts.length) return;
+ for (let i=0; i < tts.length; i++) {
+ if (tts[i].mode == "showing") {
+ cur_tt_idx = i;
+ return cur_tt_idx;
+ }
+ }
+ return cur_tt_idx;
+}
+function getActiveTranscriptTrack() { return Q("video").textTracks[getActiveTranscriptTrackIdx()]; } \ No newline at end of file