mirror of
https://github.com/SoPat712/videospeed.git
synced 2025-08-21 18:08:46 -04:00
cleanup formatting + comments
This commit is contained in:
12
inject.js
12
inject.js
@@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user