aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAjay Ramachandran <[email protected]>2019-08-23 20:59:13 -0400
committerAjay Ramachandran <[email protected]>2019-08-23 20:59:13 -0400
commitde376176db988c3e4353d3ca72e274778158d4d2 (patch)
tree67e9fb78be29dcb0761ff15c7da50e99fbc954ed
parente63389cfa3bc4a0704dc526813cdbb07556b8abf (diff)
downloadSponsorBlock-de376176db988c3e4353d3ca72e274778158d4d2.tar.gz
SponsorBlock-de376176db988c3e4353d3ca72e274778158d4d2.zip
Fixed preview bar being added too soon.
-rw-r--r--content.js18
1 files changed, 10 insertions, 8 deletions
diff --git a/content.js b/content.js
index a1f4066c..df376d69 100644
--- a/content.js
+++ b/content.js
@@ -28,7 +28,7 @@ var channelURL;
var channelWhitelisted = false;
// create preview bar
-var previewBar;
+var previewBar = null;
// Direct Links
videoIDChange(getYouTubeVideoID(document.URL));
@@ -206,7 +206,9 @@ function resetValues() {
sponsorLookupRetries = 0;
//empty the preview bar
- previewBar.set([], [], 0);
+ if (previewBar !== null) {
+ previewBar.set([], [], 0);
+ }
//reset sponsor data found check
sponsorDataFound = false;
@@ -214,11 +216,16 @@ function resetValues() {
function videoIDChange(id) {
//if the id has not changed return
- if (sponsorVideoID === id) return
+ if (sponsorVideoID === id) return;
//set the global videoID
sponsorVideoID = id;
+ resetValues();
+
+ //id is not valid
+ if (!id) return;
+
//setup the preview bar
if (previewBar == null) {
//create it
@@ -226,11 +233,6 @@ function videoIDChange(id) {
previewBar = new PreviewBar(progressBar);
}
- resetValues();
-
- //id is not valid
- if (id === false) return;
-
//warn them if they had unsubmitted times
if (previousVideoID != null) {
//get the sponsor times from storage