Made it still possible to vote on downvoted sponsors.

Added "(hidden)" to the button.

Resolves https://github.com/ajayyy/SponsorBlock/issues/28
This commit is contained in:
Ajay Ramachandran
2019-08-12 20:22:00 -04:00
parent 8f0a9d97f6
commit 13d0e4a33a
2 changed files with 26 additions and 13 deletions

View File

@@ -7,6 +7,9 @@ var UUIDs = null;
//what video id are these sponsors for //what video id are these sponsors for
var sponsorVideoID = null; var sponsorVideoID = null;
//these are sponsors that have been downvoted
var hiddenSponsorTimes = [];
//the time this video is starting at when first played, if not zero //the time this video is starting at when first played, if not zero
var youtubeVideoStartTime = null; var youtubeVideoStartTime = null;
@@ -106,6 +109,7 @@ function messageListener(request, sender, sendResponse) {
sendResponse({ sendResponse({
found: sponsorDataFound, found: sponsorDataFound,
sponsorTimes: sponsorTimes, sponsorTimes: sponsorTimes,
hiddenSponsorTimes: hiddenSponsorTimes,
UUIDs: UUIDs UUIDs: UUIDs
}); });
@@ -431,7 +435,7 @@ function checkSponsorTime(sponsorTimes, index, openNotice) {
lastTime = v.currentTime - 0.0001; lastTime = v.currentTime - 0.0001;
} }
if (checkIfTimeToSkip(v.currentTime, sponsorTimes[index][0])) { if (checkIfTimeToSkip(v.currentTime, sponsorTimes[index][0]) && !hiddenSponsorTimes.includes(index)) {
//skip it //skip it
skipToTime(v, index, sponsorTimes, openNotice); skipToTime(v, index, sponsorTimes, openNotice);
@@ -945,20 +949,22 @@ function afterDownvote(UUID) {
//remove this sponsor from the sponsors looked up //remove this sponsor from the sponsors looked up
//find which one it is //find which one it is
let removeIndex = -1;
for (let i = 0; i < sponsorTimes.length; i++) { for (let i = 0; i < sponsorTimes.length; i++) {
if (UUIDs[i] == UUID) { if (UUIDs[i] == UUID) {
//this one is the one to remove //this one is the one to hide
removeIndex = i;
}
}
if (removeIndex != -1) { //add this as a hidden sponsorTime
hiddenSponsorTimes.push(i);
let sponsorTimesLeft = sponsorTimes.slice();
for (let j = 0; j < hiddenSponsorTimes.length; j++) {
//remove this sponsor time //remove this sponsor time
sponsorTimes.splice(removeIndex, 1); sponsorTimesLeft.splice(hiddenSponsorTimes[j], 1);
}
//update the preview //update the preview
previewBar.set(sponsorTimes, [], v.duration); previewBar.set(sponsorTimesLeft, [], v.duration);
}
} }
} }

View File

@@ -384,7 +384,14 @@ function runThePopup() {
for (let i = 0; i < request.sponsorTimes.length; i++) { for (let i = 0; i < request.sponsorTimes.length; i++) {
let sponsorTimeButton = document.createElement("button"); let sponsorTimeButton = document.createElement("button");
sponsorTimeButton.className = "warningButton popupElement"; sponsorTimeButton.className = "warningButton popupElement";
sponsorTimeButton.innerText = getFormattedTime(request.sponsorTimes[i][0]) + " to " + getFormattedTime(request.sponsorTimes[i][1]);
let extraInfo = "";
if (request.hiddenSponsorTimes.includes(i)) {
//this one is hidden
extraInfo = " (hidden)";
}
sponsorTimeButton.innerText = getFormattedTime(request.sponsorTimes[i][0]) + " to " + getFormattedTime(request.sponsorTimes[i][1]) + extraInfo;
let votingButtons = document.createElement("div"); let votingButtons = document.createElement("div");