diff --git a/public/_locales/en/messages.json b/public/_locales/en/messages.json index f40530e1..a88d05a0 100644 --- a/public/_locales/en/messages.json +++ b/public/_locales/en/messages.json @@ -209,6 +209,15 @@ "enableViewTrackingInPrivate": { "message": "Enable Skip Count Tracking In Private/Incognito tabs" }, + "enableTrackDownvotes": { + "message": "Store segment downvotes" + }, + "whatTrackDownvotes": { + "message": "Any segments you downvote will remain hidden even after refreshing" + }, + "trackDownvotesWarning": { + "message": "Warning: Disabling this will delete all previously stored downvotes" + }, "enableQueryByHashPrefix": { "message": "Query By Hash Prefix" }, diff --git a/public/options/options.html b/public/options/options.html index 37e606c7..6bf76b3b 100644 --- a/public/options/options.html +++ b/public/options/options.html @@ -440,6 +440,20 @@ + +
+
+ + +
+ +
__MSG_whatTrackDownvotes__
+
diff --git a/src/config.ts b/src/config.ts index fe4b60d6..cf3dad1c 100644 --- a/src/config.ts +++ b/src/config.ts @@ -22,6 +22,7 @@ interface SBConfig { fullVideoSegments: boolean, trackViewCount: boolean, trackViewCountInPrivate: boolean, + trackDownvotes: boolean, dontShowNotice: boolean, noticeVisibilityMode: NoticeVisbilityMode, hideVideoPlayerControls: boolean, @@ -138,6 +139,7 @@ const Config: SBObject = { fullVideoSegments: true, trackViewCount: true, trackViewCountInPrivate: true, + trackDownvotes: true, dontShowNotice: false, noticeVisibilityMode: NoticeVisbilityMode.FadedForAutoSkip, hideVideoPlayerControls: false, diff --git a/src/options.ts b/src/options.ts index bcf3f824..b0245c6b 100644 --- a/src/options.ts +++ b/src/options.ts @@ -87,6 +87,7 @@ async function init() { const reverse = optionsElements[i].getAttribute("data-toggle-type") === "reverse"; const confirmMessage = optionsElements[i].getAttribute("data-confirm-message"); + const confirmOnTrue = optionsElements[i].getAttribute("data-confirm-on") !== "false"; if (optionResult != undefined) checkbox.checked = reverse ? !optionResult : optionResult; @@ -101,8 +102,9 @@ async function init() { // Add click listener checkbox.addEventListener("click", async () => { // Confirm if required - if (checkbox.checked && confirmMessage && !confirm(chrome.i18n.getMessage(confirmMessage))){ - checkbox.checked = false; + if (confirmMessage && ((confirmOnTrue && checkbox.checked) || (!confirmOnTrue && !checkbox.checked)) + && !confirm(chrome.i18n.getMessage(confirmMessage))){ + checkbox.checked = !checkbox.checked; return; } @@ -135,6 +137,11 @@ async function init() { document.documentElement.setAttribute("data-theme", "light"); } break; + case "trackDownvotes": + if (!checkbox.checked) { + Config.local.downvotedSegments = {}; + } + break; } // If other options depend on this, hide/show them diff --git a/src/utils.ts b/src/utils.ts index 747eaba4..7ee3be4c 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -490,8 +490,8 @@ export default class Utils { } async addHiddenSegment(videoID: VideoID, segmentUUID: string, hidden: SponsorHideType) { - if (chrome.extension.inIncognitoContext) return; - + if (chrome.extension.inIncognitoContext || !Config.config.trackDownvotes) return; + const hashedVideoID = (await this.getHash(videoID, 1)).slice(0, 4) as VideoID & HashedValue; const UUIDHash = await this.getHash(segmentUUID, 1);