mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-08 12:37:05 +03:00
Fixed skip notice references fixing manual skip notices.
This commit is contained in:
@@ -42,8 +42,8 @@ chrome.runtime.onMessage.addListener(function (request, sender, callback) {
|
|||||||
case "getSponsorTimes":
|
case "getSponsorTimes":
|
||||||
getSponsorTimes(request.videoID, function(sponsorTimes) {
|
getSponsorTimes(request.videoID, function(sponsorTimes) {
|
||||||
callback({
|
callback({
|
||||||
sponsorTimes: sponsorTimes
|
sponsorTimes
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
//this allows the callback to be called later
|
//this allows the callback to be called later
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ var sponsorTimesSubmitting = [];
|
|||||||
var popupInitialised = false;
|
var popupInitialised = false;
|
||||||
|
|
||||||
// Contains all of the functions and variables needed by the skip notice
|
// Contains all of the functions and variables needed by the skip notice
|
||||||
var skipNoticeContentContainer = {
|
var skipNoticeContentContainer = () => ({
|
||||||
vote,
|
vote,
|
||||||
dontShowNoticeAgain,
|
dontShowNoticeAgain,
|
||||||
unskipSponsorTime,
|
unskipSponsorTime,
|
||||||
@@ -86,7 +86,7 @@ var skipNoticeContentContainer = {
|
|||||||
reskipSponsorTime,
|
reskipSponsorTime,
|
||||||
hiddenSponsorTimes,
|
hiddenSponsorTimes,
|
||||||
updatePreviewBar
|
updatePreviewBar
|
||||||
};
|
});
|
||||||
|
|
||||||
//get messages from the background script and the popup
|
//get messages from the background script and the popup
|
||||||
chrome.runtime.onMessage.addListener(messageListener);
|
chrome.runtime.onMessage.addListener(messageListener);
|
||||||
@@ -573,12 +573,12 @@ function sponsorCheck() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//don't keep track until they are loaded in
|
//don't keep track until they are loaded in
|
||||||
if (sponsorTimes != null || sponsorTimesSubmitting.length > 0) {
|
if (sponsorTimes !== null || sponsorTimesSubmitting.length > 0) {
|
||||||
lastTime = v.currentTime;
|
lastTime = v.currentTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkSponsorTime(sponsorTimes, index, openNotice) {
|
function checkSponsorTime(sponsorTimes, index, openNotice): boolean {
|
||||||
//this means part of the video was just skipped
|
//this means part of the video was just skipped
|
||||||
if (Math.abs(v.currentTime - lastTime) > 1 && lastTime != -1) {
|
if (Math.abs(v.currentTime - lastTime) > 1 && lastTime != -1) {
|
||||||
//make lastTime as if the video was playing normally
|
//make lastTime as if the video was playing normally
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ class SkipNotice {
|
|||||||
UUID: string;
|
UUID: string;
|
||||||
manualSkip: boolean;
|
manualSkip: boolean;
|
||||||
// Contains functions and variables from the content script needed by the skip notice
|
// Contains functions and variables from the content script needed by the skip notice
|
||||||
contentContainer: any;
|
contentContainer: () => any;
|
||||||
|
|
||||||
maxCountdownTime: () => number;
|
maxCountdownTime: () => number;
|
||||||
countdownTime: any;
|
countdownTime: any;
|
||||||
@@ -128,7 +128,7 @@ class SkipNotice {
|
|||||||
downvoteButton.id = "sponsorTimesDownvoteButtonsContainer" + this.idSuffix;
|
downvoteButton.id = "sponsorTimesDownvoteButtonsContainer" + this.idSuffix;
|
||||||
downvoteButton.className = "sponsorSkipObject voteButton";
|
downvoteButton.className = "sponsorSkipObject voteButton";
|
||||||
downvoteButton.src = chrome.extension.getURL("icons/report.png");
|
downvoteButton.src = chrome.extension.getURL("icons/report.png");
|
||||||
downvoteButton.addEventListener("click", () => this.contentContainer.vote(0, this.UUID, this));
|
downvoteButton.addEventListener("click", () => this.contentContainer().vote(0, this.UUID, this));
|
||||||
downvoteButton.setAttribute("title", chrome.i18n.getMessage("reportButtonInfo"));
|
downvoteButton.setAttribute("title", chrome.i18n.getMessage("reportButtonInfo"));
|
||||||
|
|
||||||
//add downvote and report text to container
|
//add downvote and report text to container
|
||||||
@@ -156,7 +156,7 @@ class SkipNotice {
|
|||||||
let dontShowAgainButton = document.createElement("button");
|
let dontShowAgainButton = document.createElement("button");
|
||||||
dontShowAgainButton.innerText = chrome.i18n.getMessage("Hide");
|
dontShowAgainButton.innerText = chrome.i18n.getMessage("Hide");
|
||||||
dontShowAgainButton.className = "sponsorSkipObject sponsorSkipNoticeButton sponsorSkipNoticeRightButton";
|
dontShowAgainButton.className = "sponsorSkipObject sponsorSkipNoticeButton sponsorSkipNoticeRightButton";
|
||||||
dontShowAgainButton.addEventListener("click", this.contentContainer.dontShowNoticeAgain);
|
dontShowAgainButton.addEventListener("click", this.contentContainer().dontShowNoticeAgain);
|
||||||
|
|
||||||
// Don't let them hide it if manually skipping
|
// Don't let them hide it if manually skipping
|
||||||
if (!this.manualSkip) {
|
if (!this.manualSkip) {
|
||||||
@@ -255,7 +255,7 @@ class SkipNotice {
|
|||||||
}
|
}
|
||||||
|
|
||||||
unskip() {
|
unskip() {
|
||||||
this.contentContainer.unskipSponsorTime(this.UUID);
|
this.contentContainer().unskipSponsorTime(this.UUID);
|
||||||
|
|
||||||
this.unskippedMode(chrome.i18n.getMessage("reskip"));
|
this.unskippedMode(chrome.i18n.getMessage("reskip"));
|
||||||
}
|
}
|
||||||
@@ -271,8 +271,8 @@ class SkipNotice {
|
|||||||
|
|
||||||
//change max duration to however much of the sponsor is left
|
//change max duration to however much of the sponsor is left
|
||||||
this.maxCountdownTime = function() {
|
this.maxCountdownTime = function() {
|
||||||
let sponsorTime = this.contentContainer.sponsorTimes[this.contentContainer.UUIDs.indexOf(this.UUID)];
|
let sponsorTime = this.contentContainer().sponsorTimes[this.contentContainer().UUIDs.indexOf(this.UUID)];
|
||||||
let duration = Math.round(sponsorTime[1] - this.contentContainer.v.currentTime);
|
let duration = Math.round(sponsorTime[1] - this.contentContainer().v.currentTime);
|
||||||
|
|
||||||
return Math.max(duration, 4);
|
return Math.max(duration, 4);
|
||||||
};
|
};
|
||||||
@@ -282,7 +282,7 @@ class SkipNotice {
|
|||||||
}
|
}
|
||||||
|
|
||||||
reskip() {
|
reskip() {
|
||||||
this.contentContainer.reskipSponsorTime(this.UUID);
|
this.contentContainer().reskipSponsorTime(this.UUID);
|
||||||
|
|
||||||
//change reskip button to a unskip button
|
//change reskip button to a unskip button
|
||||||
let unskipButton = this.changeUnskipButton(chrome.i18n.getMessage("unskip"));
|
let unskipButton = this.changeUnskipButton(chrome.i18n.getMessage("unskip"));
|
||||||
@@ -300,7 +300,7 @@ class SkipNotice {
|
|||||||
if (this.manualSkip) {
|
if (this.manualSkip) {
|
||||||
this.changeNoticeTitle(chrome.i18n.getMessage("noticeTitle"));
|
this.changeNoticeTitle(chrome.i18n.getMessage("noticeTitle"));
|
||||||
|
|
||||||
this.contentContainer.vote(1, this.UUID, this);
|
this.contentContainer().vote(1, this.UUID, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -324,14 +324,14 @@ class SkipNotice {
|
|||||||
|
|
||||||
//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
|
||||||
for (let i = 0; i < this.contentContainer.sponsorTimes.length; i++) {
|
for (let i = 0; i < this.contentContainer().sponsorTimes.length; i++) {
|
||||||
if (this.contentContainer.UUIDs[i] == this.UUID) {
|
if (this.contentContainer().UUIDs[i] == this.UUID) {
|
||||||
//this one is the one to hide
|
//this one is the one to hide
|
||||||
|
|
||||||
//add this as a hidden sponsorTime
|
//add this as a hidden sponsorTime
|
||||||
this.contentContainer.hiddenSponsorTimes.push(i);
|
this.contentContainer().hiddenSponsorTimes.push(i);
|
||||||
|
|
||||||
this.contentContainer.updatePreviewBar();
|
this.contentContainer().updatePreviewBar();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user