From 57de51475f4232731fcfb1001bdb439c7602b917 Mon Sep 17 00:00:00 2001 From: Ajay Date: Thu, 6 Jan 2022 16:26:59 -0500 Subject: [PATCH] Add option to disable showing full video segments --- public/_locales/en/messages.json | 4 ++++ public/options/options.html | 16 ++++++++++++++++ src/config.ts | 2 ++ src/content.ts | 14 +++++++++++++- 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/public/_locales/en/messages.json b/public/_locales/en/messages.json index d7855a69..ac7cbe09 100644 --- a/public/_locales/en/messages.json +++ b/public/_locales/en/messages.json @@ -624,6 +624,10 @@ "muteSegments": { "message": "Allow segments that mute audio instead of skip" }, + "fullVideoSegments": { + "message": "Show an icon when a video is entirely an advertisement", + "description": "Referring to the category pill that is now shown on videos that are entirely sponsor or entirely selfpromo" + }, "colorFormatIncorrect": { "message": "Your color is formatted incorrectly. It should be a 3 or 6 digit hex code with a number sign at the beginning." }, diff --git a/public/options/options.html b/public/options/options.html index 1fbcf1b1..657b2d4d 100644 --- a/public/options/options.html +++ b/public/options/options.html @@ -66,6 +66,22 @@
+
+ + +
+
+
+
+

diff --git a/src/config.ts b/src/config.ts index b4a1a9cd..ae6f45aa 100644 --- a/src/config.ts +++ b/src/config.ts @@ -21,6 +21,7 @@ interface SBConfig { showTimeWithSkips: boolean, disableSkipping: boolean, muteSegments: boolean, + fullVideoSegments: boolean, trackViewCount: boolean, trackViewCountInPrivate: boolean, dontShowNotice: boolean, @@ -177,6 +178,7 @@ const Config: SBObject = { showTimeWithSkips: true, disableSkipping: false, muteSegments: true, + fullVideoSegments: true, trackViewCount: true, trackViewCountInPrivate: true, dontShowNotice: false, diff --git a/src/content.ts b/src/content.ts index 07bf607c..2b719591 100644 --- a/src/content.ts +++ b/src/content.ts @@ -687,7 +687,7 @@ async function sponsorsLookup(id: string, keepOldSubmissions = true) { const hashPrefix = (await utils.getHash(id, 1)).substr(0, 4); const response = await utils.asyncRequestToServer('GET', "/api/skipSegments/" + hashPrefix, { categories, - actionTypes: Config.config.muteSegments ? [ActionType.Skip, ActionType.Mute, ActionType.Full] : [ActionType.Skip, ActionType.Full], + actionTypes: getEnabledActionTypes(), userAgent: `${chrome.runtime.id}`, ...extraRequestData }); @@ -768,6 +768,18 @@ async function sponsorsLookup(id: string, keepOldSubmissions = true) { lookupVipInformation(id); } +function getEnabledActionTypes(): ActionType[] { + const actionTypes = [ActionType.Skip]; + if (Config.config.muteSegments) { + actionTypes.push(ActionType.Mute); + } + if (Config.config.fullVideoSegments) { + actionTypes.push(ActionType.Full); + } + + return actionTypes; +} + function lookupVipInformation(id: string): void { updateVipInfo().then((isVip) => { if (isVip) {