mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2024-11-10 09:07:45 +01:00
Fix font issue, NaN issue and remove hide real time
This commit is contained in:
parent
77abc1d031
commit
bfafcd07cc
2 changed files with 12 additions and 17 deletions
|
@ -5,8 +5,6 @@ import Utils from "./utils";
|
|||
const utils = new Utils();
|
||||
|
||||
interface SBConfig {
|
||||
hideRealTime: boolean,
|
||||
timeWithSkips: boolean,
|
||||
userID: string,
|
||||
sponsorTimes: SBMap<string, any>,
|
||||
whitelistedChannels: string[],
|
||||
|
@ -17,6 +15,7 @@ interface SBConfig {
|
|||
skipCount: number,
|
||||
sponsorTimesContributed: number,
|
||||
submissionCountSinceCategories: number, // New count used to show the "Read The Guidelines!!" message
|
||||
showTimeWithSkips: boolean,
|
||||
unsubmittedWarning: boolean,
|
||||
disableSkipping: boolean,
|
||||
trackViewCount: boolean,
|
||||
|
@ -125,8 +124,6 @@ var Config: SBObject = {
|
|||
*/
|
||||
configListeners: [],
|
||||
defaults: {
|
||||
hideRealTime: false,
|
||||
timeWithSkips: true,
|
||||
userID: null,
|
||||
sponsorTimes: new SBMap("sponsorTimes"),
|
||||
whitelistedChannels: [],
|
||||
|
@ -137,6 +134,7 @@ var Config: SBObject = {
|
|||
skipCount: 0,
|
||||
sponsorTimesContributed: 0,
|
||||
submissionCountSinceCategories: 0,
|
||||
showTimeWithSkips: true,
|
||||
unsubmittedWarning: true,
|
||||
disableSkipping: false,
|
||||
trackViewCount: true,
|
||||
|
|
|
@ -801,7 +801,6 @@ function updatePreviewBar() {
|
|||
if (localSponsorTimes == null) localSponsorTimes = [];
|
||||
|
||||
let allSponsorTimes = localSponsorTimes.concat(sponsorTimesSubmitting);
|
||||
showTimeWithoutSkips(allSponsorTimes);
|
||||
|
||||
//create an array of the sponsor types
|
||||
let types = [];
|
||||
|
@ -819,6 +818,10 @@ function updatePreviewBar() {
|
|||
|
||||
previewBar.set(utils.getSegmentsFromSponsorTimes(allSponsorTimes), types, video.duration)
|
||||
|
||||
if (Config.config.showTimeWithSkips) {
|
||||
showTimeWithoutSkips(allSponsorTimes);
|
||||
}
|
||||
|
||||
//update last video id
|
||||
lastPreviewBarUpdate = sponsorVideoID;
|
||||
}
|
||||
|
@ -1608,8 +1611,6 @@ function formatTime(seconds) {
|
|||
}
|
||||
|
||||
function showTimeWithoutSkips(allSponsorTimes): void {
|
||||
if(!Config.config.timeWithSkips) return;
|
||||
|
||||
let skipDuration = 0;
|
||||
|
||||
// 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);
|
||||
|
||||
const durationID = "durationAfterSkips";
|
||||
const durationID = "sponsorBlockDurationAfterSkips";
|
||||
let duration = document.getElementById(durationID);
|
||||
|
||||
// Create span if needed
|
||||
if(duration === null) {
|
||||
duration = document.createElement('span');
|
||||
duration.id = durationID;
|
||||
duration.classList.add("ytp-time-duration");
|
||||
|
||||
display.appendChild(duration);
|
||||
}
|
||||
|
||||
if(Config.config.hideRealTime) {
|
||||
// Empty if not enabled
|
||||
duration.innerText = "";
|
||||
display.getElementsByTagName("span")[2].innerText = formatedTime;
|
||||
} else {
|
||||
duration.innerText = (skipDuration === 0) ? "" : " ("+formatedTime+")";
|
||||
}
|
||||
duration.innerText = (skipDuration <= 0 || isNaN(skipDuration)) ? "" : " ("+formatedTime+")";
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue