diff options
author | Ajay <[email protected]> | 2022-03-27 14:25:53 -0400 |
---|---|---|
committer | Ajay <[email protected]> | 2022-03-27 14:25:53 -0400 |
commit | d2c50d2562b8154267f316803f8b4ebab69856c3 (patch) | |
tree | 06cae22d1651ba03a0c64b823ad0934ade85cf21 | |
parent | 5d72498aac3db3b074a2db60490bc17cc26a3015 (diff) | |
download | SponsorBlock-d2c50d2562b8154267f316803f8b4ebab69856c3.tar.gz SponsorBlock-d2c50d2562b8154267f316803f8b4ebab69856c3.zip |
Reverse segments to skip content
-rw-r--r-- | src/config.ts | 2 | ||||
-rw-r--r-- | src/content.ts | 32 |
2 files changed, 22 insertions, 12 deletions
diff --git a/src/config.ts b/src/config.ts index 5113460f..64ef44ca 100644 --- a/src/config.ts +++ b/src/config.ts @@ -206,7 +206,7 @@ const Config: SBObject = { opacity: "0.7" }, "sponsor": { - color: "#00d400", + color: "#807EFB", opacity: "0.7" }, "preview-sponsor": { diff --git a/src/content.ts b/src/content.ts index a3352b3b..f591a83b 100644 --- a/src/content.ts +++ b/src/content.ts @@ -789,6 +789,27 @@ async function sponsorsLookup(id: string, keepOldSubmissions = true) { const oldSegments = sponsorTimes || []; sponsorTimes = recievedSegments; + if (sponsorTimes) { + // Reverse times so that it only watches the skipped info + const newTimes: SponsorTime[] = []; + const oldTimes = sponsorTimes.sort((a, b) => a.segment[0] - b.segment[0]); + let cursor = 0; + for (const time of oldTimes) { + if (time.segment[0] > cursor) { + newTimes.push({ + segment: [cursor, time.segment[0]], + source: SponsorSourceType.Local, + actionType: ActionType.Skip, + category: "sponsor" as Category, + UUID: null + }); + } + + cursor = Math.max(cursor, time.segment[1]); + } + sponsorTimes = newTimes; + } + // Hide all submissions smaller than the minimum duration if (Config.config.minDuration !== 0) { for (const segment of sponsorTimes) { @@ -1472,21 +1493,10 @@ function shouldSkip(segment: SponsorTime): boolean { async function createButtons(): Promise<void> { if (onMobileYouTube) return; - controls = await utils.wait(getControls).catch(); - - // Add button if does not already exist in html - createButton("startSegment", "sponsorStart", () => closeInfoMenuAnd(() => startOrEndTimingNewSegment()), "PlayerStartIconSponsorBlocker.svg"); - createButton("cancelSegment", "sponsorCancel", () => closeInfoMenuAnd(() => cancelCreatingSegment()), "PlayerCancelSegmentIconSponsorBlocker.svg"); - createButton("delete", "clearTimes", () => closeInfoMenuAnd(() => clearSponsorTimes()), "PlayerDeleteIconSponsorBlocker.svg"); - createButton("submit", "SubmitTimes", submitSponsorTimes, "PlayerUploadIconSponsorBlocker.svg"); - createButton("info", "openPopup", openInfoMenu, "PlayerInfoIconSponsorBlocker.svg"); - const controlsContainer = getControls(); if (Config.config.autoHideInfoButton && !onInvidious && controlsContainer && playerButtons["info"]?.button && !controlsWithEventListeners.includes(controlsContainer)) { controlsWithEventListeners.push(controlsContainer); - - AnimationUtils.setupAutoHideAnimation(playerButtons["info"].button, controlsContainer); } } |