mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-08 20:47:11 +03:00
Made preview button functional
This commit is contained in:
@@ -51,7 +51,8 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
|
|||||||
</span>
|
</span>
|
||||||
|
|
||||||
<span id={"sponsorTimePreviewButton" + this.props.index + this.props.idSuffix}
|
<span id={"sponsorTimePreviewButton" + this.props.index + this.props.idSuffix}
|
||||||
className="sponsorTimeEditButton">
|
className="sponsorTimeEditButton"
|
||||||
|
onClick={this.previewTime.bind(this)}>
|
||||||
{chrome.i18n.getMessage("preview")}
|
{chrome.i18n.getMessage("preview")}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
@@ -63,6 +64,24 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
previewTime(): void {
|
||||||
|
let sponsorTimes = this.props.contentContainer().sponsorTimesSubmitting;
|
||||||
|
let index = this.props.index;
|
||||||
|
|
||||||
|
let skipTime = sponsorTimes[index][0];
|
||||||
|
|
||||||
|
// if (document.getElementById("startTimeMinutes" + index) != null) {
|
||||||
|
// //edit is currently open, use that time
|
||||||
|
|
||||||
|
// skipTime = getSponsorTimeEditTimes("startTime", index);
|
||||||
|
|
||||||
|
// //save the edit
|
||||||
|
// saveSponsorTimeEdit(index, false);
|
||||||
|
// }
|
||||||
|
|
||||||
|
this.props.contentContainer().previewTime(skipTime - 2);
|
||||||
|
}
|
||||||
|
|
||||||
deleteTime(): void {
|
deleteTime(): void {
|
||||||
let sponsorTimes = this.props.contentContainer().sponsorTimesSubmitting;
|
let sponsorTimes = this.props.contentContainer().sponsorTimesSubmitting;
|
||||||
let index = this.props.index;
|
let index = this.props.index;
|
||||||
|
|||||||
@@ -116,7 +116,8 @@ var skipNoticeContentContainer: ContentContainer = () => ({
|
|||||||
onMobileYouTube,
|
onMobileYouTube,
|
||||||
sponsorSubmissionNotice: submissionNotice,
|
sponsorSubmissionNotice: submissionNotice,
|
||||||
resetSponsorSubmissionNotice,
|
resetSponsorSubmissionNotice,
|
||||||
changeStartSponsorButton
|
changeStartSponsorButton,
|
||||||
|
previewTime
|
||||||
});
|
});
|
||||||
|
|
||||||
//get messages from the background script and the popup
|
//get messages from the background script and the popup
|
||||||
@@ -861,6 +862,27 @@ function getStartTimes(sponsorTimes: number[][], minimum?: number, hideHiddenSpo
|
|||||||
return startTimes;
|
return startTimes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skip to exact time in a video and autoskips
|
||||||
|
*
|
||||||
|
* @param time
|
||||||
|
*/
|
||||||
|
function previewTime(time: number) {
|
||||||
|
video.currentTime = time;
|
||||||
|
|
||||||
|
// Unpause the video if needed
|
||||||
|
if (video.paused){
|
||||||
|
video.play();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start preview resetter
|
||||||
|
if (previewResetter !== null){
|
||||||
|
clearTimeout(previewResetter);
|
||||||
|
}
|
||||||
|
|
||||||
|
previewResetter = setTimeout(() => previewResetter = null, 4000);
|
||||||
|
}
|
||||||
|
|
||||||
//skip from the start time to the end time for a certain index sponsor time
|
//skip from the start time to the end time for a certain index sponsor time
|
||||||
function skipToTime(v, index, sponsorTimes, openNotice) {
|
function skipToTime(v, index, sponsorTimes, openNotice) {
|
||||||
if (!Config.config.disableAutoSkip || previewResetter !== null) {
|
if (!Config.config.disableAutoSkip || previewResetter !== null) {
|
||||||
|
|||||||
@@ -17,7 +17,8 @@ interface ContentContainer {
|
|||||||
onMobileYouTube: boolean,
|
onMobileYouTube: boolean,
|
||||||
sponsorSubmissionNotice: SubmissionNotice,
|
sponsorSubmissionNotice: SubmissionNotice,
|
||||||
resetSponsorSubmissionNotice: () => void,
|
resetSponsorSubmissionNotice: () => void,
|
||||||
changeStartSponsorButton: (showStartSponsor: any, uploadButtonVisible: any) => Promise<boolean>
|
changeStartSponsorButton: (showStartSponsor: any, uploadButtonVisible: any) => Promise<boolean>,
|
||||||
|
previewTime: (time: number) => void
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user