diff --git a/manifest/manifest.json b/manifest/manifest.json index aea11c66..62889abb 100644 --- a/manifest/manifest.json +++ b/manifest/manifest.json @@ -1,7 +1,7 @@ { "name": "__MSG_fullName__", "short_name": "SponsorBlock", - "version": "5.11.5", + "version": "5.11.7", "default_locale": "en", "description": "__MSG_Description__", "homepage_url": "https://sponsor.ajay.app", diff --git a/maze-utils b/maze-utils index 67799eeb..de2cda1e 160000 --- a/maze-utils +++ b/maze-utils @@ -1 +1 @@ -Subproject commit 67799eebf03238a999e24de1ce9bddcb919b7c99 +Subproject commit de2cda1e75eb88560dd94546197b674e7f044788 diff --git a/src/content.ts b/src/content.ts index 25632f7a..9c299fe9 100644 --- a/src/content.ts +++ b/src/content.ts @@ -306,7 +306,8 @@ function messageListener(request: Message, sender: unknown, sendResponse: (respo for (const segment of importedSegments) { if (!sponsorTimesSubmitting.some( (s) => Math.abs(s.segment[0] - segment.segment[0]) < 1 - && Math.abs(s.segment[1] - segment.segment[1]) < 1)) { + && Math.abs(s.segment[1] - segment.segment[1]) < 1 + && s.description === segment.description)) { const hasChaptersPermission = (Config.config.showCategoryWithoutPermission || Config.config.permissions["chapter"]); if (segment.category === "chapter" && (!utils.getCategorySelection("chapter") || !hasChaptersPermission)) { diff --git a/src/utils/exporter.ts b/src/utils/exporter.ts index 85e1b383..c3f2ee2d 100644 --- a/src/utils/exporter.ts +++ b/src/utils/exporter.ts @@ -34,9 +34,12 @@ function exportTime(segment: SponsorTime): string { export function importTimes(data: string, videoDuration: number): SponsorTime[] { const lines = data.split("\n"); + const timeRegex = /(?:((?:\d+:)?\d+:\d+)+(?:\.\d+)?)|(?:\d+(?=s| second))/g; + const anyLineHasTime = lines.some((line) => timeRegex.test(line)); + const result: SponsorTime[] = []; for (const line of lines) { - const match = line.match(/(?:((?:\d+:)?\d+:\d+)+(?:\.\d+)?)|(?:\d+(?=s| second))/g); + const match = line.match(timeRegex); if (match) { const startTime = getFormattedTimeToSeconds(match[0]); if (startTime !== null) { @@ -71,6 +74,18 @@ export function importTimes(data: string, videoDuration: number): SponsorTime[] result.push(segment); } + } else if (!anyLineHasTime) { + // Adding chapters with placeholder times + const segment: SponsorTime = { + segment: [0, 0], + category: "chapter" as Category, + actionType: ActionType.Chapter, + description: line, + source: SponsorSourceType.Local, + UUID: generateUserID() as SegmentUUID + }; + + result.push(segment); } }