Made the preview bar only get created if a video is found.

This commit is contained in:
Ajay Ramachandran
2019-08-13 14:05:32 -04:00
parent aa95687b56
commit fadb294c98
2 changed files with 9 additions and 5 deletions

View File

@@ -25,10 +25,9 @@ var channelURL;
var channelWhitelisted = false;
// create preview bar
let progressBar = document.getElementsByClassName("ytp-progress-bar-container")[0] || document.getElementsByClassName("no-model cue-range-markers")[0];
var previewBar = new PreviewBar(progressBar);
var previewBar;
if(id = getYouTubeVideoID(document.URL)){ // Direct Links
if (id = getYouTubeVideoID(document.URL)) { // Direct Links
videoIDChange(id);
}
@@ -203,10 +202,15 @@ document.onkeydown = function(e){
}
function videoIDChange(id) {
//not a url change
if (sponsorVideoID == id) return;
if (previewBar == null) {
//create it
let progressBar = document.getElementsByClassName("ytp-progress-bar-container")[0] || document.getElementsByClassName("no-model cue-range-markers")[0];
previewBar = new PreviewBar(progressBar);
}
//warn them if they had unsubmitted times
if (previousVideoID != null) {
//get the sponsor times from storage