mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-09 13:07:05 +03:00
Removed the need for getYouTubeVideoStartTime and made it check the current video time instead.
This commit is contained in:
12
content.js
12
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
|
||||
|
||||
Reference in New Issue
Block a user