aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAjay <[email protected]>2023-07-28 20:42:06 -0400
committerAjay <[email protected]>2023-07-28 20:42:06 -0400
commitd12d847f2febd411cc80d393639a3392b1516011 (patch)
tree62673bc6bd136e6fb2e18b064aa2948f70b545d2
parent31a9de252d2ec29ca08171cf3e9150bf7591603f (diff)
downloadSponsorBlock-d12d847f2febd411cc80d393639a3392b1516011.tar.gz
SponsorBlock-d12d847f2febd411cc80d393639a3392b1516011.zip
Fix it sometimes looping instead of going to next video when autoskipping at the end for playlists
Fix #1804
-rw-r--r--src/content.ts7
-rw-r--r--src/utils/pageUtils.ts4
2 files changed, 9 insertions, 2 deletions
diff --git a/src/content.ts b/src/content.ts
index 6dfea5fb..ad39b0b6 100644
--- a/src/content.ts
+++ b/src/content.ts
@@ -24,7 +24,7 @@ import SubmissionNotice from "./render/SubmissionNotice";
import { Message, MessageResponse, VoteResponse } from "./messageTypes";
import { SkipButtonControlBar } from "./js-components/skipButtonControlBar";
import { getStartTimeFromUrl } from "./utils/urlParser";
-import { getControls, getExistingChapters, getHashParams, isVisible } from "./utils/pageUtils";
+import { getControls, getExistingChapters, getHashParams, isPlayingPlaylist, isVisible } from "./utils/pageUtils";
import { CategoryPill } from "./render/CategoryPill";
import { AnimationUtils } from "./utils/animationUtils";
import { GenericUtils } from "./utils/genericUtils";
@@ -1592,8 +1592,11 @@ function skipToTime({v, skipTime, skippingSegments, openNotice, forceAutoSkip, u
// for some reason you also can't skip to 1 second before the end
if (v.loop && v.duration > 1 && skipTime[1] >= v.duration - 1) {
v.currentTime = 0;
- } else if (navigator.vendor === "Apple Computer, Inc." && v.duration > 1 && skipTime[1] >= v.duration) {
+ } else if (v.duration > 1 && skipTime[1] >= v.duration
+ && (navigator.vendor === "Apple Computer, Inc." || isPlayingPlaylist())) {
+ console.log("doing workaround")
// MacOS will loop otherwise #1027
+ // Sometimes playlists loop too #1804
v.currentTime = v.duration - 0.001;
} else {
if (inMuteSegment(skipTime[1], true)) {
diff --git a/src/utils/pageUtils.ts b/src/utils/pageUtils.ts
index ab4d5619..2b79c2ec 100644
--- a/src/utils/pageUtils.ts
+++ b/src/utils/pageUtils.ts
@@ -93,4 +93,8 @@ export function getExistingChapters(currentVideoID: VideoID, duration: number):
}
return chapters;
+}
+
+export function isPlayingPlaylist() {
+ return !!document.URL.includes("&list=");
} \ No newline at end of file