Default UUIDs to an empty list instead of null.

Resolves https://github.com/ajayyy/SponsorBlock/issues/252.
This commit is contained in:
Ajay Ramachandran
2020-02-08 17:45:22 -05:00
parent 158b76c17e
commit 5f21d3f96f

View File

@@ -13,7 +13,7 @@ var sponsorDataFound = false;
var previousVideoID = null; var previousVideoID = null;
//the actual sponsorTimes if loaded and UUIDs associated with them //the actual sponsorTimes if loaded and UUIDs associated with them
var sponsorTimes = null; var sponsorTimes = null;
var UUIDs = null; var UUIDs = [];
//what video id are these sponsors for //what video id are these sponsors for
var sponsorVideoID = null; var sponsorVideoID = null;
@@ -215,7 +215,7 @@ function resetValues() {
//reset sponsor times //reset sponsor times
sponsorTimes = null; sponsorTimes = null;
UUIDs = null; UUIDs = [];
sponsorLookupRetries = 0; sponsorLookupRetries = 0;
//empty the preview bar //empty the preview bar
@@ -613,7 +613,7 @@ function skipToTime(v, index, sponsorTimes, openNotice) {
} }
lastSponsorTimeSkipped = sponsorTimes[index][0]; lastSponsorTimeSkipped = sponsorTimes[index][0];
let currentUUID = UUIDs[index]; let currentUUID = UUIDs[index];
lastSponsorTimeSkippedUUID = currentUUID; lastSponsorTimeSkippedUUID = currentUUID;
@@ -627,17 +627,17 @@ function skipToTime(v, index, sponsorTimes, openNotice) {
vote(1, currentUUID, null); vote(1, currentUUID, null);
} }
} }
}
//send telemetry that a this sponsor was skipped //send telemetry that a this sponsor was skipped
if (Config.config.trackViewCount && !sponsorSkipped[index]) { if (Config.config.trackViewCount && !sponsorSkipped[index]) {
utils.sendRequestToServer("POST", "/api/viewedVideoSponsorTime?UUID=" + currentUUID); utils.sendRequestToServer("POST", "/api/viewedVideoSponsorTime?UUID=" + currentUUID);
if (!Config.config.disableAutoSkip) { if (!Config.config.disableAutoSkip) {
// Count this as a skip // Count this as a skip
Config.config.minutesSaved = Config.config.minutesSaved + (sponsorTimes[index][1] - sponsorTimes[index][0]) / 60; Config.config.minutesSaved = Config.config.minutesSaved + (sponsorTimes[index][1] - sponsorTimes[index][0]) / 60;
Config.config.skipCount = Config.config.skipCount + 1; Config.config.skipCount = Config.config.skipCount + 1;
sponsorSkipped[index] = true; sponsorSkipped[index] = true;
}
} }
} }
} }