Fix starting segments when there is a t=? in the url

This commit is contained in:
Ajay Ramachandran
2021-10-02 17:13:30 -04:00
parent 5f34a777f1
commit 8605e23fbb
3 changed files with 59 additions and 2 deletions

View File

@@ -16,6 +16,7 @@ import * as Chat from "./js-components/chat";
import { getCategoryActionType } from "./utils/categoryUtils";
import { SkipButtonControlBar } from "./js-components/skipButtonControlBar";
import { Tooltip } from "./render/Tooltip";
import { getStartTimeFromUrl } from "./utils/urlParser";
// Hack to get the CSS loaded on permission-based sites (Invidious)
utils.wait(() => Config.config !== null, 5000, 10).then(addCSS);
@@ -775,22 +776,25 @@ function retryFetch(): void {
function startSkipScheduleCheckingForStartSponsors() {
if (!switchingVideos && sponsorTimes) {
// See if there are any starting sponsors
let startingSegmentTime = -1;
let startingSegmentTime = getStartTimeFromUrl(document.URL) || -1;
let found = false;
let startingSegment: SponsorTime = null;
for (const time of sponsorTimes) {
if (time.segment[0] <= video.currentTime && time.segment[0] > startingSegmentTime && time.segment[1] > video.currentTime
&& getCategoryActionType(time.category) === CategoryActionType.Skippable) {
startingSegmentTime = time.segment[0];
startingSegment = time;
found = true;
break;
}
}
if (startingSegmentTime === -1) {
if (!found) {
for (const time of sponsorTimesSubmitting) {
if (time.segment[0] <= video.currentTime && time.segment[0] > startingSegmentTime && time.segment[1] > video.currentTime
&& getCategoryActionType(time.category) === CategoryActionType.Skippable) {
startingSegmentTime = time.segment[0];
startingSegment = time;
found = true;
break;
}
}