88 ContentContainer ,
99 HashedValue ,
1010 Keybind ,
11+ PageType ,
1112 ScheduledTime ,
1213 SegmentUUID ,
1314 SkipToTimeParams ,
@@ -18,7 +19,6 @@ import {
1819 ToggleSkippable ,
1920 VideoID ,
2021 VideoInfo ,
21- PageType
2222} from "./types" ;
2323import Utils from "./utils" ;
2424import PreviewBar , { PreviewBarSegment } from "./js-components/previewBar" ;
@@ -948,13 +948,13 @@ async function sponsorsLookup(keepOldSubmissions = true) {
948948 setupVideoMutationListener ( ) ;
949949
950950 const showChapterMessage = Config . config . showUpsells
951- && Config . config . payments . lastCheck !== 0
951+ && Config . config . payments . lastCheck !== 0
952952 && ! noRefreshFetchingChaptersAllowed ( )
953953 && Config . config . showChapterInfoMessage
954954 && Config . config . skipCount > 200 ;
955955
956- if ( ! showChapterMessage
957- && Config . config . showChapterInfoMessage
956+ if ( ! showChapterMessage
957+ && Config . config . showChapterInfoMessage
958958 && Config . config . payments . freeAccess ) {
959959 Config . config . showChapterInfoMessage = false ;
960960
@@ -1238,7 +1238,7 @@ function getYouTubeVideoID(document: Document, url?: string): string | boolean {
12381238function getYouTubeVideoIDFromDocument ( hideIcon = true , pageHint = PageType . Watch ) : string | boolean {
12391239 const selector = "a.ytp-title-link[data-sessionlink='feature=player-title']" ;
12401240 // get ID from document (channel trailer / embedded playlist)
1241- const element = pageHint === PageType . Embed ? document . querySelector ( selector )
1241+ const element = pageHint === PageType . Embed ? document . querySelector ( selector )
12421242 : video ?. parentElement ?. parentElement ?. querySelector ( selector ) ;
12431243 const videoURL = element ?. getAttribute ( "href" ) ;
12441244 if ( videoURL ) {
@@ -1751,7 +1751,7 @@ function createButton(baseID: string, title: string, callback: () => void, image
17511751}
17521752
17531753function shouldAutoSkip ( segment : SponsorTime ) : boolean {
1754- return ( ! Config . config . manualSkipOnFullVideo || ! sponsorTimes ?. some ( ( s ) => s . category === segment . category && s . actionType === ActionType . Full ) )
1754+ return ( ! Config . config . manualSkipOnFullVideo || ! sponsorTimes ?. some ( ( s ) => s . category === segment . category && s . actionType === ActionType . Full ) )
17551755 && ( utils . getCategorySelection ( segment . category ) ?. option === CategorySkipOption . AutoSkip ||
17561756 ( Config . config . autoSkipOnMusicVideos && sponsorTimes ?. some ( ( s ) => s . category === "music_offtopic" )
17571757 && segment . actionType !== ActionType . Poi ) ) ;
@@ -1904,11 +1904,15 @@ function isSegmentCreationInProgress(): boolean {
19041904
19051905function cancelCreatingSegment ( ) {
19061906 if ( isSegmentCreationInProgress ( ) ) {
1907- sponsorTimesSubmitting . splice ( sponsorTimesSubmitting . length - 1 , 1 ) ;
1908- Config . config . unsubmittedSegments [ sponsorVideoID ] = sponsorTimesSubmitting ;
1907+ if ( sponsorTimesSubmitting . length > 1 ) { // If there's more than one segment: remove last
1908+ sponsorTimesSubmitting . pop ( ) ;
1909+ Config . config . unsubmittedSegments [ sponsorVideoID ] = sponsorTimesSubmitting ;
1910+ } else { // Otherwise delete the video entry & close submission menu
1911+ resetSponsorSubmissionNotice ( ) ;
1912+ sponsorTimesSubmitting = [ ] ;
1913+ delete Config . config . unsubmittedSegments [ sponsorVideoID ] ;
1914+ }
19091915 Config . forceSyncUpdate ( "unsubmittedSegments" ) ;
1910-
1911- if ( sponsorTimesSubmitting . length <= 0 ) resetSponsorSubmissionNotice ( ) ;
19121916 }
19131917
19141918 updateEditButtonsOnPlayer ( ) ;
0 commit comments