Add option to disable segment names beside timestamp in video player

This commit is contained in:
Ajay
2022-09-24 22:29:07 -04:00
parent bb8975e93a
commit da35e889f2
6 changed files with 24 additions and 7 deletions

View File

@@ -35,6 +35,9 @@
"message": "Render segments as chapters", "message": "Render segments as chapters",
"description": "Refers to drawing segments on the YouTube seek bar as split up chapters, similar to the existing chapter system" "description": "Refers to drawing segments on the YouTube seek bar as split up chapters, similar to the existing chapter system"
}, },
"showSegmentNameInChapterBar": {
"message": "Show Current Segment Beside Video Time"
},
"upvoteButtonInfo": { "upvoteButtonInfo": {
"message": "Upvote this submission" "message": "Upvote this submission"
}, },

View File

@@ -317,12 +317,12 @@ input[type='number'] {
color: grey; color: grey;
} }
.disabled .slider { .sb-toggle-option.disabled .slider {
cursor: default; cursor: default;
} }
/* To hide everything except upsell button */ /* To hide everything except upsell button */
.disabled td:not(.skipOption), .disabled td.skipOption > :not(.upsellButton) { .disabled td:not(.skipOption, .categoryExtraOptions), .disabled td.skipOption > :not(.upsellButton) {
opacity: 0.3; opacity: 0.3;
} }

View File

@@ -5,7 +5,7 @@ import * as CompileConfig from "../../../config.json";
import { Category, CategorySkipOption } from "../../types"; import { Category, CategorySkipOption } from "../../types";
import { getCategorySuffix } from "../../utils/categoryUtils"; import { getCategorySuffix } from "../../utils/categoryUtils";
import ToggleOptionComponent, { ToggleOptionProps } from "./ToggleOptionComponent"; import ToggleOptionComponent from "./ToggleOptionComponent";
import { fetchingChaptersAllowed } from "../../utils/licenseKey"; import { fetchingChaptersAllowed } from "../../utils/licenseKey";
import LockSvg from "../../svg-icons/lock_svg"; import LockSvg from "../../svg-icons/lock_svg";
@@ -21,6 +21,12 @@ export interface CategorySkipOptionsState {
hideChapter: boolean; hideChapter: boolean;
} }
export interface ToggleOption {
configKey: string;
label: string;
dontDisable?: boolean;
}
class CategorySkipOptionsComponent extends React.Component<CategorySkipOptionsProps, CategorySkipOptionsState> { class CategorySkipOptionsComponent extends React.Component<CategorySkipOptionsProps, CategorySkipOptionsState> {
setBarColorTimeout: NodeJS.Timeout; setBarColorTimeout: NodeJS.Timeout;
@@ -237,7 +243,7 @@ class CategorySkipOptionsComponent extends React.Component<CategorySkipOptionsPr
<ToggleOptionComponent <ToggleOptionComponent
configKey={option.configKey} configKey={option.configKey}
label={option.label} label={option.label}
disabled={disabled} disabled={!option.dontDisable && disabled}
style={{width: "inherit"}} style={{width: "inherit"}}
/> />
</td> </td>
@@ -248,12 +254,17 @@ class CategorySkipOptionsComponent extends React.Component<CategorySkipOptionsPr
return result; return result;
} }
getExtraOptions(category: string): ToggleOptionProps[] { getExtraOptions(category: string): ToggleOption[] {
switch (category) { switch (category) {
case "chapter": case "chapter":
return [{ return [{
configKey: "renderSegmentsAsChapters", configKey: "renderSegmentsAsChapters",
label: chrome.i18n.getMessage("renderAsChapters"), label: chrome.i18n.getMessage("renderAsChapters"),
dontDisable: true
}, {
configKey: "showSegmentNameInChapterBar",
label: chrome.i18n.getMessage("showSegmentNameInChapterBar"),
dontDisable: true
}]; }];
case "music_offtopic": case "music_offtopic":
return [{ return [{

View File

@@ -26,7 +26,7 @@ class ToggleOptionComponent extends React.Component<ToggleOptionProps, ToggleOpt
render(): React.ReactElement { render(): React.ReactElement {
return ( return (
<div> <div className={`sb-toggle-option ${this.props.disabled ? "disabled" : ""}`}>
<div className="switch-container" style={this.props.style}> <div className="switch-container" style={this.props.style}>
<label className="switch"> <label className="switch">
<input id={this.props.configKey} <input id={this.props.configKey}

View File

@@ -66,6 +66,7 @@ interface SBConfig {
darkMode: boolean, darkMode: boolean,
showCategoryGuidelines: boolean, showCategoryGuidelines: boolean,
showCategoryWithoutPermission: boolean, showCategoryWithoutPermission: boolean,
showSegmentNameInChapterBar: boolean,
// Used to cache calculated text color info // Used to cache calculated text color info
categoryPillColors: { categoryPillColors: {
@@ -197,6 +198,7 @@ const Config: SBObject = {
darkMode: true, darkMode: true,
showCategoryGuidelines: true, showCategoryGuidelines: true,
showCategoryWithoutPermission: false, showCategoryWithoutPermission: false,
showSegmentNameInChapterBar: true,
categoryPillColors: {}, categoryPillColors: {},

View File

@@ -717,7 +717,8 @@ class PreviewBar {
} }
updateChapterText(segments: SponsorTime[], submittingSegments: SponsorTime[], currentTime: number): void { updateChapterText(segments: SponsorTime[], submittingSegments: SponsorTime[], currentTime: number): void {
if ((!segments || segments.length <= 0) && submittingSegments?.length <= 0) { if (!Config.config.showSegmentNameInChapterBar
|| ((!segments || segments.length <= 0) && submittingSegments?.length <= 0)) {
const chaptersContainer = this.getChaptersContainer(); const chaptersContainer = this.getChaptersContainer();
const chapterButton = this.getChapterButton(chaptersContainer); const chapterButton = this.getChapterButton(chaptersContainer);
if (chapterButton.classList.contains("ytp-chapter-container-disabled")) { if (chapterButton.classList.contains("ytp-chapter-container-disabled")) {