aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAjay Ramachandran <[email protected]>2019-08-21 14:16:52 -0400
committerAjay Ramachandran <[email protected]>2019-08-21 14:16:52 -0400
commitc1aebf45c84e8141053eb736d8b29365fb12713b (patch)
treea9a41415e78aa4b476523e73f6fef197566c4764
parent118804e139edc2acb8fc85d27ba554b5be20a4c9 (diff)
downloadSponsorBlock-c1aebf45c84e8141053eb736d8b29365fb12713b.tar.gz
SponsorBlock-c1aebf45c84e8141053eb736d8b29365fb12713b.zip
Removed the need for getYouTubeVideoStartTime and made it check the current video time instead.
-rw-r--r--content.js12
-rw-r--r--utils.js13
2 files changed, 4 insertions, 21 deletions
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