Add auto and manual skip at start

This commit is contained in:
Ajay Ramachandran
2021-07-15 16:01:22 -04:00
parent 0dd2d18b07
commit a839480a33
3 changed files with 30 additions and 9 deletions

View File

@@ -281,6 +281,10 @@
"skip_category": { "skip_category": {
"message": "Skip {0}?" "message": "Skip {0}?"
}, },
"skip_to_category": {
"message": "Skip to {0}?",
"description": "Used for skipping to things (Skip to Highlight)"
},
"skipped": { "skipped": {
"message": "Skipped" "message": "Skipped"
}, },

View File

@@ -83,7 +83,9 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta
: "category_" + this.segments[0].category + "_short") || chrome.i18n.getMessage("category_" + this.segments[0].category); : "category_" + this.segments[0].category + "_short") || chrome.i18n.getMessage("category_" + this.segments[0].category);
let noticeTitle = categoryName + " " + chrome.i18n.getMessage("skipped"); let noticeTitle = categoryName + " " + chrome.i18n.getMessage("skipped");
if (!this.autoSkip) { if (!this.autoSkip) {
noticeTitle = chrome.i18n.getMessage("skip_category").replace("{0}", categoryName); const messageId = utils.getCategoryActionType(this.segments[0].category) === CategoryActionType.Skippable
? "skip_category" : "skip_to_category";
noticeTitle = chrome.i18n.getMessage(messageId).replace("{0}", categoryName);
} }
//add notice //add notice

View File

@@ -696,26 +696,41 @@ function retryFetch(): void {
function startSkipScheduleCheckingForStartSponsors() { function startSkipScheduleCheckingForStartSponsors() {
if (!switchingVideos) { if (!switchingVideos) {
// See if there are any starting sponsors // See if there are any starting sponsors
let startingSponsor = -1; let startingSegmentTime = -1;
let startingSegment: SponsorTime = null;
for (const time of sponsorTimes) { for (const time of sponsorTimes) {
if (time.segment[0] <= video.currentTime && time.segment[0] > startingSponsor && time.segment[1] > video.currentTime if (time.segment[0] <= video.currentTime && time.segment[0] > startingSegmentTime && time.segment[1] > video.currentTime
&& utils.getCategoryActionType(time.category) === CategoryActionType.Skippable) { && utils.getCategoryActionType(time.category) === CategoryActionType.Skippable) {
startingSponsor = time.segment[0]; startingSegmentTime = time.segment[0];
startingSegment = time;
break; break;
} }
} }
if (startingSponsor === -1) { if (startingSegmentTime === -1) {
for (const time of sponsorTimesSubmitting) { for (const time of sponsorTimesSubmitting) {
if (time.segment[0] <= video.currentTime && time.segment[0] > startingSponsor && time.segment[1] > video.currentTime if (time.segment[0] <= video.currentTime && time.segment[0] > startingSegmentTime && time.segment[1] > video.currentTime
&& utils.getCategoryActionType(time.category) === CategoryActionType.Skippable) { && utils.getCategoryActionType(time.category) === CategoryActionType.Skippable) {
startingSponsor = time.segment[0]; startingSegmentTime = time.segment[0];
startingSegment = time;
break; break;
} }
} }
} }
if (startingSponsor !== -1) { // For highlight category
startSponsorSchedule(undefined, startingSponsor); const poiSegments = sponsorTimes
.filter((time) => time.segment[1] > video.currentTime && utils.getCategoryActionType(time.category) === CategoryActionType.POI)
.sort((a, b) => b.segment[0] - a.segment[0]);
for (const time of poiSegments) {
const skipOption = utils.getCategorySelection(time.category)?.option;
if (skipOption !== CategorySkipOption.ShowOverlay) {
skipToTime(video, time.segment, [time], true);
if (skipOption === CategorySkipOption.AutoSkip) break;
}
}
if (startingSegmentTime !== -1) {
startSponsorSchedule(undefined, startingSegmentTime);
} else { } else {
startSponsorSchedule(); startSponsorSchedule();
} }