Made preview button functional

This commit is contained in:
Ajay Ramachandran
2020-03-11 19:56:16 -04:00
parent 37662138df
commit f100ee4738
3 changed files with 45 additions and 3 deletions

View File

@@ -116,7 +116,8 @@ var skipNoticeContentContainer: ContentContainer = () => ({
onMobileYouTube,
sponsorSubmissionNotice: submissionNotice,
resetSponsorSubmissionNotice,
changeStartSponsorButton
changeStartSponsorButton,
previewTime
});
//get messages from the background script and the popup
@@ -861,6 +862,27 @@ function getStartTimes(sponsorTimes: number[][], minimum?: number, hideHiddenSpo
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
function skipToTime(v, index, sponsorTimes, openNotice) {
if (!Config.config.disableAutoSkip || previewResetter !== null) {