Fix font issue, NaN issue and remove hide real time

This commit is contained in:
Ajay Ramachandran 2020-07-03 19:56:08 -04:00
parent 77abc1d031
commit bfafcd07cc
2 changed files with 12 additions and 17 deletions

View file

@ -5,8 +5,6 @@ import Utils from "./utils";
const utils = new Utils(); const utils = new Utils();
interface SBConfig { interface SBConfig {
hideRealTime: boolean,
timeWithSkips: boolean,
userID: string, userID: string,
sponsorTimes: SBMap<string, any>, sponsorTimes: SBMap<string, any>,
whitelistedChannels: string[], whitelistedChannels: string[],
@ -17,6 +15,7 @@ interface SBConfig {
skipCount: number, skipCount: number,
sponsorTimesContributed: number, sponsorTimesContributed: number,
submissionCountSinceCategories: number, // New count used to show the "Read The Guidelines!!" message submissionCountSinceCategories: number, // New count used to show the "Read The Guidelines!!" message
showTimeWithSkips: boolean,
unsubmittedWarning: boolean, unsubmittedWarning: boolean,
disableSkipping: boolean, disableSkipping: boolean,
trackViewCount: boolean, trackViewCount: boolean,
@ -125,8 +124,6 @@ var Config: SBObject = {
*/ */
configListeners: [], configListeners: [],
defaults: { defaults: {
hideRealTime: false,
timeWithSkips: true,
userID: null, userID: null,
sponsorTimes: new SBMap("sponsorTimes"), sponsorTimes: new SBMap("sponsorTimes"),
whitelistedChannels: [], whitelistedChannels: [],
@ -137,6 +134,7 @@ var Config: SBObject = {
skipCount: 0, skipCount: 0,
sponsorTimesContributed: 0, sponsorTimesContributed: 0,
submissionCountSinceCategories: 0, submissionCountSinceCategories: 0,
showTimeWithSkips: true,
unsubmittedWarning: true, unsubmittedWarning: true,
disableSkipping: false, disableSkipping: false,
trackViewCount: true, trackViewCount: true,

View file

@ -801,7 +801,6 @@ function updatePreviewBar() {
if (localSponsorTimes == null) localSponsorTimes = []; if (localSponsorTimes == null) localSponsorTimes = [];
let allSponsorTimes = localSponsorTimes.concat(sponsorTimesSubmitting); let allSponsorTimes = localSponsorTimes.concat(sponsorTimesSubmitting);
showTimeWithoutSkips(allSponsorTimes);
//create an array of the sponsor types //create an array of the sponsor types
let types = []; let types = [];
@ -819,6 +818,10 @@ function updatePreviewBar() {
previewBar.set(utils.getSegmentsFromSponsorTimes(allSponsorTimes), types, video.duration) previewBar.set(utils.getSegmentsFromSponsorTimes(allSponsorTimes), types, video.duration)
if (Config.config.showTimeWithSkips) {
showTimeWithoutSkips(allSponsorTimes);
}
//update last video id //update last video id
lastPreviewBarUpdate = sponsorVideoID; lastPreviewBarUpdate = sponsorVideoID;
} }
@ -1608,8 +1611,6 @@ function formatTime(seconds) {
} }
function showTimeWithoutSkips(allSponsorTimes): void { function showTimeWithoutSkips(allSponsorTimes): void {
if(!Config.config.timeWithSkips) return;
let skipDuration = 0; let skipDuration = 0;
// Calculate skipDuration based from the segments in the preview bar // Calculate skipDuration based from the segments in the preview bar
@ -1627,21 +1628,17 @@ function showTimeWithoutSkips(allSponsorTimes): void {
let formatedTime = utils.getFormattedTime(video.duration - skipDuration); let formatedTime = utils.getFormattedTime(video.duration - skipDuration);
const durationID = "durationAfterSkips"; const durationID = "sponsorBlockDurationAfterSkips";
let duration = document.getElementById(durationID); let duration = document.getElementById(durationID);
// Create span if needed // Create span if needed
if(duration === null) { if(duration === null) {
duration = document.createElement('span'); duration = document.createElement('span');
duration.id = durationID; duration.id = durationID;
duration.classList.add("ytp-time-duration");
display.appendChild(duration); display.appendChild(duration);
} }
if(Config.config.hideRealTime) { duration.innerText = (skipDuration <= 0 || isNaN(skipDuration)) ? "" : " ("+formatedTime+")";
// Empty if not enabled
duration.innerText = "";
display.getElementsByTagName("span")[2].innerText = formatedTime;
} else {
duration.innerText = (skipDuration === 0) ? "" : " ("+formatedTime+")";
}
} }