mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2024-11-10 01:01:55 +01:00
Add option to disable tracking downvotes and clear when disabled
This commit is contained in:
parent
008079c74c
commit
cbb8d48820
5 changed files with 36 additions and 4 deletions
|
@ -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"
|
||||
},
|
||||
|
|
|
@ -440,6 +440,20 @@
|
|||
</label>
|
||||
</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 class="option-button trigger-button">
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue