cleanup formatting + comments

This commit is contained in:
Ilya Grigorik
2019-04-26 21:38:18 -07:00
parent fb5c2ea330
commit 2310423c94

View File

@@ -1,11 +1,11 @@
var tc = { var tc = {
settings: { settings: {
lastSpeed: 1.0, // default 1x lastSpeed: 1.0, // default 1x
speeds: {}, // empty object to hold speed for each source speeds: {}, // empty object to hold speed for each source
displayKeyCode: 86, // default: V displayKeyCode: 86, // default: V
rememberSpeed: false, // default: false rememberSpeed: false, // default: false
audioBoolean: false, // default: false audioBoolean: false, // default: false
startHidden: false, // default: false startHidden: false, // default: false
keyBindings: [], keyBindings: [],
blacklist: ` blacklist: `
@@ -110,6 +110,9 @@
this.parent = target.parentElement || parent; this.parent = target.parentElement || parent;
this.document = target.ownerDocument; this.document = target.ownerDocument;
this.id = Math.random().toString(36).substr(2, 9); this.id = Math.random().toString(36).substr(2, 9);
// settings.speeds[] ensures that same source used across video tags (e.g. fullscreen on YT) retains speed setting
// this.speed is a controller level variable that retains speed setting across source switches (e.g. video quality, playlist change)
this.speed = 1.0; this.speed = 1.0;
if (!tc.settings.rememberSpeed) { if (!tc.settings.rememberSpeed) {
@@ -413,11 +416,14 @@
mediaTags.forEach(function(v) { mediaTags.forEach(function(v) {
var id = v.dataset['vscid']; var id = v.dataset['vscid'];
var controller = document.querySelector(`div[data-vscid="${id}"]`); var controller = document.querySelector(`div[data-vscid="${id}"]`);
// Don't change video speed if the video has a different controller // Don't change video speed if the video has a different controller
if (e && !(targetController == controller)) { if (e && !(targetController == controller)) {
return; return;
} }
if(controller){
// Controller may have been (force) removed by the site, guard to prevent crashes but run the command
if (controller) {
showController(controller); showController(controller);
} }