Removed the need for getYouTubeVideoStartTime and made it check the current video time instead.

This commit is contained in:
Ajay Ramachandran
2019-08-21 14:16:52 -04:00
parent 118804e139
commit c1aebf45c8
2 changed files with 4 additions and 21 deletions

View File

@@ -10,9 +10,6 @@ var sponsorVideoID = null;
//these are sponsors that have been downvoted
var hiddenSponsorTimes = [];
//the time this video is starting at when first played, if not zero
var youtubeVideoStartTime = null;
//the video
var v;
@@ -259,9 +256,6 @@ function videoIDChange(id) {
resetValues();
//see if there is a video start time
youtubeVideoStartTime = getYouTubeVideoStartTime(document.URL);
sponsorsLookup(id);
//make sure everything is properly added
@@ -468,7 +462,7 @@ function checkSponsorTime(sponsorTimes, index, openNotice) {
lastTime = v.currentTime - 0.0001;
}
if (checkIfTimeToSkip(v.currentTime, sponsorTimes[index][0]) && !hiddenSponsorTimes.includes(index)) {
if (checkIfTimeToSkip(v.currentTime, sponsorTimes[index][0], sponsorTimes[index][1]) && !hiddenSponsorTimes.includes(index)) {
//skip it
skipToTime(v, index, sponsorTimes, openNotice);
@@ -479,13 +473,13 @@ function checkSponsorTime(sponsorTimes, index, openNotice) {
return false;
}
function checkIfTimeToSkip(currentVideoTime, startTime) {
function checkIfTimeToSkip(currentVideoTime, startTime, endTime) {
//If the sponsor time is in between these times, skip it
//Checks if the last time skipped to is not too close to now, to make sure not to get too many
// sponsor times in a row (from one troll)
//the last term makes 0 second start times possible only if the video is not setup to start at a different time from zero
return (Math.abs(currentVideoTime - startTime) < 3 && startTime >= lastTime && startTime <= currentVideoTime) ||
(lastTime == -1 && startTime == 0 && youtubeVideoStartTime == null)
(lastTime == -1 && startTime == 0 && currentVideoTime < endTime)
}
//skip fromt he start time to the end time for a certain index sponsor time