mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-12 22:47:18 +03:00
Remove the unsubmittedSegments entry when removing the last segment
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
|||||||
ContentContainer,
|
ContentContainer,
|
||||||
HashedValue,
|
HashedValue,
|
||||||
Keybind,
|
Keybind,
|
||||||
|
PageType,
|
||||||
ScheduledTime,
|
ScheduledTime,
|
||||||
SegmentUUID,
|
SegmentUUID,
|
||||||
SkipToTimeParams,
|
SkipToTimeParams,
|
||||||
@@ -18,7 +19,6 @@ import {
|
|||||||
ToggleSkippable,
|
ToggleSkippable,
|
||||||
VideoID,
|
VideoID,
|
||||||
VideoInfo,
|
VideoInfo,
|
||||||
PageType
|
|
||||||
} from "./types";
|
} from "./types";
|
||||||
import Utils from "./utils";
|
import Utils from "./utils";
|
||||||
import PreviewBar, { PreviewBarSegment } from "./js-components/previewBar";
|
import PreviewBar, { PreviewBarSegment } from "./js-components/previewBar";
|
||||||
@@ -948,13 +948,13 @@ async function sponsorsLookup(keepOldSubmissions = true) {
|
|||||||
setupVideoMutationListener();
|
setupVideoMutationListener();
|
||||||
|
|
||||||
const showChapterMessage = Config.config.showUpsells
|
const showChapterMessage = Config.config.showUpsells
|
||||||
&& Config.config.payments.lastCheck !== 0
|
&& Config.config.payments.lastCheck !== 0
|
||||||
&& !noRefreshFetchingChaptersAllowed()
|
&& !noRefreshFetchingChaptersAllowed()
|
||||||
&& Config.config.showChapterInfoMessage
|
&& Config.config.showChapterInfoMessage
|
||||||
&& Config.config.skipCount > 200;
|
&& Config.config.skipCount > 200;
|
||||||
|
|
||||||
if (!showChapterMessage
|
if (!showChapterMessage
|
||||||
&& Config.config.showChapterInfoMessage
|
&& Config.config.showChapterInfoMessage
|
||||||
&& Config.config.payments.freeAccess) {
|
&& Config.config.payments.freeAccess) {
|
||||||
Config.config.showChapterInfoMessage = false;
|
Config.config.showChapterInfoMessage = false;
|
||||||
|
|
||||||
@@ -1238,7 +1238,7 @@ function getYouTubeVideoID(document: Document, url?: string): string | boolean {
|
|||||||
function getYouTubeVideoIDFromDocument(hideIcon = true, pageHint = PageType.Watch): string | boolean {
|
function getYouTubeVideoIDFromDocument(hideIcon = true, pageHint = PageType.Watch): string | boolean {
|
||||||
const selector = "a.ytp-title-link[data-sessionlink='feature=player-title']";
|
const selector = "a.ytp-title-link[data-sessionlink='feature=player-title']";
|
||||||
// get ID from document (channel trailer / embedded playlist)
|
// get ID from document (channel trailer / embedded playlist)
|
||||||
const element = pageHint === PageType.Embed ? document.querySelector(selector)
|
const element = pageHint === PageType.Embed ? document.querySelector(selector)
|
||||||
: video?.parentElement?.parentElement?.querySelector(selector);
|
: video?.parentElement?.parentElement?.querySelector(selector);
|
||||||
const videoURL = element?.getAttribute("href");
|
const videoURL = element?.getAttribute("href");
|
||||||
if (videoURL) {
|
if (videoURL) {
|
||||||
@@ -1751,7 +1751,7 @@ function createButton(baseID: string, title: string, callback: () => void, image
|
|||||||
}
|
}
|
||||||
|
|
||||||
function shouldAutoSkip(segment: SponsorTime): boolean {
|
function shouldAutoSkip(segment: SponsorTime): boolean {
|
||||||
return (!Config.config.manualSkipOnFullVideo || !sponsorTimes?.some((s) => s.category === segment.category && s.actionType === ActionType.Full))
|
return (!Config.config.manualSkipOnFullVideo || !sponsorTimes?.some((s) => s.category === segment.category && s.actionType === ActionType.Full))
|
||||||
&& (utils.getCategorySelection(segment.category)?.option === CategorySkipOption.AutoSkip ||
|
&& (utils.getCategorySelection(segment.category)?.option === CategorySkipOption.AutoSkip ||
|
||||||
(Config.config.autoSkipOnMusicVideos && sponsorTimes?.some((s) => s.category === "music_offtopic")
|
(Config.config.autoSkipOnMusicVideos && sponsorTimes?.some((s) => s.category === "music_offtopic")
|
||||||
&& segment.actionType !== ActionType.Poi));
|
&& segment.actionType !== ActionType.Poi));
|
||||||
@@ -1904,11 +1904,15 @@ function isSegmentCreationInProgress(): boolean {
|
|||||||
|
|
||||||
function cancelCreatingSegment() {
|
function cancelCreatingSegment() {
|
||||||
if (isSegmentCreationInProgress()) {
|
if (isSegmentCreationInProgress()) {
|
||||||
sponsorTimesSubmitting.splice(sponsorTimesSubmitting.length - 1, 1);
|
if (sponsorTimesSubmitting.length > 1) { // If there's more than one segment: remove last
|
||||||
Config.config.unsubmittedSegments[sponsorVideoID] = sponsorTimesSubmitting;
|
sponsorTimesSubmitting.pop();
|
||||||
|
Config.config.unsubmittedSegments[sponsorVideoID] = sponsorTimesSubmitting;
|
||||||
|
} else { // Otherwise delete the video entry & close submission menu
|
||||||
|
resetSponsorSubmissionNotice();
|
||||||
|
sponsorTimesSubmitting = [];
|
||||||
|
delete Config.config.unsubmittedSegments[sponsorVideoID];
|
||||||
|
}
|
||||||
Config.forceSyncUpdate("unsubmittedSegments");
|
Config.forceSyncUpdate("unsubmittedSegments");
|
||||||
|
|
||||||
if (sponsorTimesSubmitting.length <= 0) resetSponsorSubmissionNotice();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updateEditButtonsOnPlayer();
|
updateEditButtonsOnPlayer();
|
||||||
|
|||||||
Reference in New Issue
Block a user