mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-08 04:27:15 +03:00
Add option to disable tracking downvotes and clear when disabled
This commit is contained in:
@@ -209,6 +209,15 @@
|
|||||||
"enableViewTrackingInPrivate": {
|
"enableViewTrackingInPrivate": {
|
||||||
"message": "Enable Skip Count Tracking In Private/Incognito tabs"
|
"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": {
|
"enableQueryByHashPrefix": {
|
||||||
"message": "Query By Hash Prefix"
|
"message": "Query By Hash Prefix"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -441,6 +441,20 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div data-type="toggle" data-sync="trackDownvotes" data-confirm-on="false" data-confirm-message="trackDownvotesWarning">
|
||||||
|
<div class="switch-container">
|
||||||
|
<label class="switch">
|
||||||
|
<input id="trackDownvotes" type="checkbox" checked>
|
||||||
|
<span class="slider round"></span>
|
||||||
|
</label>
|
||||||
|
<label class="switch-label" for="trackDownvotes">
|
||||||
|
__MSG_enableTrackDownvotes__
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="small-description">__MSG_whatTrackDownvotes__</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div data-type="button-press" data-sync="copyDebugInformation" data-confirm-message="copyDebugInformation">
|
<div data-type="button-press" data-sync="copyDebugInformation" data-confirm-message="copyDebugInformation">
|
||||||
<div class="option-button trigger-button">
|
<div class="option-button trigger-button">
|
||||||
__MSG_copyDebugInformation__
|
__MSG_copyDebugInformation__
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ interface SBConfig {
|
|||||||
fullVideoSegments: boolean,
|
fullVideoSegments: boolean,
|
||||||
trackViewCount: boolean,
|
trackViewCount: boolean,
|
||||||
trackViewCountInPrivate: boolean,
|
trackViewCountInPrivate: boolean,
|
||||||
|
trackDownvotes: boolean,
|
||||||
dontShowNotice: boolean,
|
dontShowNotice: boolean,
|
||||||
noticeVisibilityMode: NoticeVisbilityMode,
|
noticeVisibilityMode: NoticeVisbilityMode,
|
||||||
hideVideoPlayerControls: boolean,
|
hideVideoPlayerControls: boolean,
|
||||||
@@ -138,6 +139,7 @@ const Config: SBObject = {
|
|||||||
fullVideoSegments: true,
|
fullVideoSegments: true,
|
||||||
trackViewCount: true,
|
trackViewCount: true,
|
||||||
trackViewCountInPrivate: true,
|
trackViewCountInPrivate: true,
|
||||||
|
trackDownvotes: true,
|
||||||
dontShowNotice: false,
|
dontShowNotice: false,
|
||||||
noticeVisibilityMode: NoticeVisbilityMode.FadedForAutoSkip,
|
noticeVisibilityMode: NoticeVisbilityMode.FadedForAutoSkip,
|
||||||
hideVideoPlayerControls: false,
|
hideVideoPlayerControls: false,
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ async function init() {
|
|||||||
const reverse = optionsElements[i].getAttribute("data-toggle-type") === "reverse";
|
const reverse = optionsElements[i].getAttribute("data-toggle-type") === "reverse";
|
||||||
|
|
||||||
const confirmMessage = optionsElements[i].getAttribute("data-confirm-message");
|
const confirmMessage = optionsElements[i].getAttribute("data-confirm-message");
|
||||||
|
const confirmOnTrue = optionsElements[i].getAttribute("data-confirm-on") !== "false";
|
||||||
|
|
||||||
if (optionResult != undefined)
|
if (optionResult != undefined)
|
||||||
checkbox.checked = reverse ? !optionResult : optionResult;
|
checkbox.checked = reverse ? !optionResult : optionResult;
|
||||||
@@ -101,8 +102,9 @@ async function init() {
|
|||||||
// Add click listener
|
// Add click listener
|
||||||
checkbox.addEventListener("click", async () => {
|
checkbox.addEventListener("click", async () => {
|
||||||
// Confirm if required
|
// Confirm if required
|
||||||
if (checkbox.checked && confirmMessage && !confirm(chrome.i18n.getMessage(confirmMessage))){
|
if (confirmMessage && ((confirmOnTrue && checkbox.checked) || (!confirmOnTrue && !checkbox.checked))
|
||||||
checkbox.checked = false;
|
&& !confirm(chrome.i18n.getMessage(confirmMessage))){
|
||||||
|
checkbox.checked = !checkbox.checked;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,6 +137,11 @@ async function init() {
|
|||||||
document.documentElement.setAttribute("data-theme", "light");
|
document.documentElement.setAttribute("data-theme", "light");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "trackDownvotes":
|
||||||
|
if (!checkbox.checked) {
|
||||||
|
Config.local.downvotedSegments = {};
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If other options depend on this, hide/show them
|
// If other options depend on this, hide/show them
|
||||||
|
|||||||
@@ -490,7 +490,7 @@ export default class Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async addHiddenSegment(videoID: VideoID, segmentUUID: string, hidden: SponsorHideType) {
|
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 hashedVideoID = (await this.getHash(videoID, 1)).slice(0, 4) as VideoID & HashedValue;
|
||||||
const UUIDHash = await this.getHash(segmentUUID, 1);
|
const UUIDHash = await this.getHash(segmentUUID, 1);
|
||||||
|
|||||||
Reference in New Issue
Block a user