diff --git a/content.js b/content.js index 367e2bc6..0170b9da 100644 --- a/content.js +++ b/content.js @@ -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 diff --git a/utils.js b/utils.js index 3e7fc7b5..dfc515f7 100644 --- a/utils.js +++ b/utils.js @@ -23,15 +23,4 @@ function getYouTubeVideoID(url) { return false; } } -} - -//returns the start time of the video if there was one specified (ex. ?t=5s) -function getYouTubeVideoStartTime(url) { - let searchParams = new URL(url).searchParams; - let startTime = searchParams.get("t"); - if (startTime == null) { - startTime = searchParams.get("time_continue"); - } - - return startTime; -} +} \ No newline at end of file