Update content.js

This commit is contained in:
Official Noob
2019-12-31 22:04:40 +00:00
committed by GitHub
parent 2a1b60596b
commit 87098d1c3e

View File

@@ -70,17 +70,13 @@ var sponsorTimesSubmitting = [];
//this is used to close the popup on YouTube when the other popup opens //this is used to close the popup on YouTube when the other popup opens
var popupInitialised = false; var popupInitialised = false;
//should skips happen at all
var disableSkipping = (SB.config.disableSkipping !== undefined);
var disableAutoSkip = (SB.config.disableSkipping !== undefined);
//should view counts be tracked //should view counts be tracked
var trackViewCount = false; var SB.config.trackViewCount = false;
let trackViewCountStorage = SB.config.trackViewCount; let SB.config.trackViewCountStorage = SB.config.SB.config.trackViewCount;
if (trackViewCountStorage != undefined) { if (SB.config.trackViewCountStorage != undefined) {
trackViewCount = trackViewCountStorage; SB.config.trackViewCount = SB.config.trackViewCountStorage;
} else { } else {
trackViewCount = true; SB.config.trackViewCount = true;
} }
//if the notice should not be shown //if the notice should not be shown
@@ -200,8 +196,7 @@ function messageListener(request, sender, sendResponse) {
break; break;
case "trackViewCount": case "trackViewCount":
trackViewCount = request.value; SB.config.trackViewCount = request.value;
break; break;
} }
} }
@@ -434,7 +429,7 @@ function sponsorsLookup(id, channelIDPromise) {
}); });
//add the event to run on the videos "ontimeupdate" //add the event to run on the videos "ontimeupdate"
if (!disableSkipping) { if (!SB.config.disableSkipping) {
v.ontimeupdate = function () { v.ontimeupdate = function () {
sponsorCheck(); sponsorCheck();
}; };
@@ -524,7 +519,7 @@ function whitelistCheck() {
//video skipping //video skipping
function sponsorCheck() { function sponsorCheck() {
if (disableSkipping) { if (SB.config.disableSkipping) {
// Make sure this isn't called again // Make sure this isn't called again
v.ontimeupdate = null; v.ontimeupdate = null;
return; return;
@@ -590,7 +585,7 @@ function checkIfTimeToSkip(currentVideoTime, startTime, endTime) {
//skip fromt he start time to the end time for a certain index sponsor time //skip fromt he start time to the end time for a certain index sponsor time
function skipToTime(v, index, sponsorTimes, openNotice) { function skipToTime(v, index, sponsorTimes, openNotice) {
if (!disableAutoSkip) { if (!SB.config.disableAutoSkip) {
v.currentTime = sponsorTimes[index][1]; v.currentTime = sponsorTimes[index][1];
} }
@@ -602,7 +597,7 @@ function skipToTime(v, index, sponsorTimes, openNotice) {
if (openNotice) { if (openNotice) {
//send out the message saying that a sponsor message was skipped //send out the message saying that a sponsor message was skipped
if (!dontShowNotice) { if (!dontShowNotice) {
let skipNotice = new SkipNotice(this, currentUUID, disableAutoSkip); let skipNotice = new SkipNotice(this, currentUUID, SB.config.disableAutoSkip);
if (dontShowNoticeOld) { if (dontShowNoticeOld) {
//show why this notice is showing //show why this notice is showing
@@ -614,17 +609,17 @@ function skipToTime(v, index, sponsorTimes, openNotice) {
} }
//auto-upvote this sponsor //auto-upvote this sponsor
if (trackViewCount && !disableAutoSkip) { if (SB.config.trackViewCount && !SB.config.disableAutoSkip) {
vote(1, currentUUID, null); vote(1, currentUUID, null);
} }
} }
} }
//send telemetry that a this sponsor was skipped //send telemetry that a this sponsor was skipped
if (trackViewCount && !sponsorSkipped[index]) { if (SB.config.trackViewCount && !sponsorSkipped[index]) {
sendRequestToServer("POST", "/api/viewedVideoSponsorTime?UUID=" + currentUUID); sendRequestToServer("POST", "/api/viewedVideoSponsorTime?UUID=" + currentUUID);
if (!disableAutoSkip) { if (!SB.config.disableAutoSkip) {
// Count this as a skip // Count this as a skip
if (SB.config.minutesSaved === undefined) SB.config.minutesSaved = 0; if (SB.config.minutesSaved === undefined) SB.config.minutesSaved = 0;