mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-06 19:47:04 +03:00
Add auto and manual skip at start
This commit is contained in:
@@ -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"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user