mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-06 11:37:02 +03:00
Add auto and manual skip at start
This commit is contained in:
@@ -281,6 +281,10 @@
|
||||
"skip_category": {
|
||||
"message": "Skip {0}?"
|
||||
},
|
||||
"skip_to_category": {
|
||||
"message": "Skip to {0}?",
|
||||
"description": "Used for skipping to things (Skip to Highlight)"
|
||||
},
|
||||
"skipped": {
|
||||
"message": "Skipped"
|
||||
},
|
||||
|
||||
@@ -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);
|
||||
let noticeTitle = categoryName + " " + chrome.i18n.getMessage("skipped");
|
||||
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
|
||||
|
||||
@@ -696,26 +696,41 @@ function retryFetch(): void {
|
||||
function startSkipScheduleCheckingForStartSponsors() {
|
||||
if (!switchingVideos) {
|
||||
// See if there are any starting sponsors
|
||||
let startingSponsor = -1;
|
||||
let startingSegmentTime = -1;
|
||||
let startingSegment: SponsorTime = null;
|
||||
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) {
|
||||
startingSponsor = time.segment[0];
|
||||
startingSegmentTime = time.segment[0];
|
||||
startingSegment = time;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (startingSponsor === -1) {
|
||||
if (startingSegmentTime === -1) {
|
||||
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) {
|
||||
startingSponsor = time.segment[0];
|
||||
startingSegmentTime = time.segment[0];
|
||||
startingSegment = time;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (startingSponsor !== -1) {
|
||||
startSponsorSchedule(undefined, startingSponsor);
|
||||
// For highlight category
|
||||
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 {
|
||||
startSponsorSchedule();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user