mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-10 21:47:06 +03:00
Add end button for chapters
This commit is contained in:
@@ -801,6 +801,10 @@
|
|||||||
"bracketEnd": {
|
"bracketEnd": {
|
||||||
"message": "(End)"
|
"message": "(End)"
|
||||||
},
|
},
|
||||||
|
"End": {
|
||||||
|
"message": "End",
|
||||||
|
"description": "Button that skips to the end of a segment"
|
||||||
|
},
|
||||||
"hiddenDueToDownvote": {
|
"hiddenDueToDownvote": {
|
||||||
"message": "hidden: downvote"
|
"message": "hidden: downvote"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -264,7 +264,8 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
|
|||||||
<span id={"sponsorTimePreviewButton" + this.idSuffix}
|
<span id={"sponsorTimePreviewButton" + this.idSuffix}
|
||||||
className="sponsorTimeEditButton"
|
className="sponsorTimeEditButton"
|
||||||
onClick={(e) => this.previewTime(e.ctrlKey, e.shiftKey)}>
|
onClick={(e) => this.previewTime(e.ctrlKey, e.shiftKey)}>
|
||||||
{chrome.i18n.getMessage("preview")}
|
{sponsorTime.actionType !== ActionType.Chapter ? chrome.i18n.getMessage("preview")
|
||||||
|
: chrome.i18n.getMessage("End")}
|
||||||
</span>
|
</span>
|
||||||
): ""}
|
): ""}
|
||||||
|
|
||||||
@@ -574,19 +575,19 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
|
|||||||
previewTime(ctrlPressed = false, shiftPressed = false): void {
|
previewTime(ctrlPressed = false, shiftPressed = false): void {
|
||||||
const sponsorTimes = this.props.contentContainer().sponsorTimesSubmitting;
|
const sponsorTimes = this.props.contentContainer().sponsorTimesSubmitting;
|
||||||
const index = this.props.index;
|
const index = this.props.index;
|
||||||
|
|
||||||
const skipTime = sponsorTimes[index].segment[0];
|
|
||||||
// If segment starts at 0:00, start playback at the end of the segment
|
|
||||||
if (skipTime === 0) {
|
|
||||||
this.props.contentContainer().previewTime(sponsorTimes[index].segment[1]);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let seekTime = 2;
|
let seekTime = 2;
|
||||||
if (ctrlPressed) seekTime = 0.5;
|
if (ctrlPressed) seekTime = 0.5;
|
||||||
if (shiftPressed) seekTime = 0.25;
|
if (shiftPressed) seekTime = 0.25;
|
||||||
|
|
||||||
this.props.contentContainer().previewTime(skipTime - (seekTime * this.props.contentContainer().v.playbackRate));
|
const startTime = sponsorTimes[index].segment[0];
|
||||||
|
const endTime = sponsorTimes[index].segment[1];
|
||||||
|
const isChapter = sponsorTimes[index].actionType === ActionType.Chapter;
|
||||||
|
|
||||||
|
// If segment starts at 0:00, start playback at the end of the segment
|
||||||
|
const skipToEndTime = startTime === 0 || isChapter;
|
||||||
|
const skipTime = skipToEndTime ? endTime : (startTime - (seekTime * this.props.contentContainer().v.playbackRate));
|
||||||
|
|
||||||
|
this.props.contentContainer().previewTime(skipTime, !isChapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
inspectTime(): void {
|
inspectTime(): void {
|
||||||
|
|||||||
Reference in New Issue
Block a user