diff --git a/public/options/options.html b/public/options/options.html
index b2a7e079..a1867ab1 100644
--- a/public/options/options.html
+++ b/public/options/options.html
@@ -331,6 +331,17 @@
+
+
+
+
+
+
+
+
diff --git a/src/config.ts b/src/config.ts
index bbd5cf8c..12db4012 100644
--- a/src/config.ts
+++ b/src/config.ts
@@ -1,6 +1,6 @@
import * as CompileConfig from "../config.json";
import * as invidiousList from "../ci/invidiouslist.json";
-import { Category, CategorySelection, CategorySkipOption, NoticeVisibilityMode, PreviewBarOption, SponsorTime, VideoID, SponsorHideType } from "./types";
+import { Category, CategorySelection, CategorySkipOption, NoticeVisibilityMode, PreviewBarOption, SponsorTime, VideoID, SponsorHideType, SegmentListDefaultTab } from "./types";
import { Keybind, ProtoConfig, keybindEquals } from "../maze-utils/src/config";
import { HashedValue } from "../maze-utils/src/hash";
import { Permission, AdvancedSkipRuleSet } from "./utils/skipRule";
@@ -10,6 +10,7 @@ interface SBConfig {
isVip: boolean;
permissions: Record;
defaultCategory: Category;
+ segmentListDefaultTab: SegmentListDefaultTab;
renderSegmentsAsChapters: boolean;
forceChannelCheck: boolean;
minutesSaved: number;
@@ -338,6 +339,7 @@ const syncDefaults = {
isVip: false,
permissions: {},
defaultCategory: "chooseACategory" as Category,
+ segmentListDefaultTab: SegmentListDefaultTab.Segments,
renderSegmentsAsChapters: false,
forceChannelCheck: false,
minutesSaved: 0,
diff --git a/src/popup/SegmentListComponent.tsx b/src/popup/SegmentListComponent.tsx
index d56b7bae..1369475c 100644
--- a/src/popup/SegmentListComponent.tsx
+++ b/src/popup/SegmentListComponent.tsx
@@ -1,5 +1,5 @@
import * as React from "react";
-import { ActionType, SegmentUUID, SponsorHideType, SponsorTime, VideoID } from "../types";
+import { ActionType, SegmentListDefaultTab, SegmentUUID, SponsorHideType, SponsorTime, VideoID } from "../types";
import Config from "../config";
import { waitFor } from "../../maze-utils/src";
import { shortCategoryName } from "../utils/categoryUtils";
@@ -61,12 +61,21 @@ export const SegmentListComponent = (props: SegmentListComponentProps) => {
}, [props.segments]);
React.useEffect(() => {
- if (hasSegments){
- setTab(SegmentListTab.Segments);
+ const setTabBasedOnConfig = () => {
+ const preferChapters = Config.config.segmentListDefaultTab === SegmentListDefaultTab.Chapters;
+ if (preferChapters) {
+ setTab(hasChapters ? SegmentListTab.Chapter : SegmentListTab.Segments);
+ } else {
+ setTab(hasSegments ? SegmentListTab.Segments : SegmentListTab.Chapter);
+ }
+ };
+
+ if (Config.isReady()) {
+ setTabBasedOnConfig();
} else {
- setTab(SegmentListTab.Chapter);
+ waitFor(() => Config.isReady()).then(setTabBasedOnConfig);
}
- }, [props.videoID, hasSegments]);
+ }, [props.videoID, hasSegments, hasChapters]);
const segmentsWithNesting = React.useMemo(() => {
const result: SegmentWithNesting[] = [];
diff --git a/src/types.ts b/src/types.ts
index d8346f58..7438557d 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -227,4 +227,9 @@ export enum NoticeVisibilityMode {
MiniForAll = 2,
FadedForAutoSkip = 3,
FadedForAll = 4
+}
+
+export enum SegmentListDefaultTab {
+ Segments,
+ Chapters,
}
\ No newline at end of file