Skip to content

Commit f80ddc8

Browse files
committed
Merge branch 'master' into rules-parser
2 parents 479c31d + 1609995 commit f80ddc8

File tree

8 files changed

+44
-13
lines changed

8 files changed

+44
-13
lines changed

public/_locales

public/options/options.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,17 @@
329329
</label>
330330
</div>
331331
</div>
332+
333+
<br />
334+
335+
<div data-type="selector" data-sync="segmentListDefaultTab">
336+
<label class="optionLabel" for="segmentListDefaultTab">__MSG_segmentListDefaultTab__:</label>
337+
338+
<select id="segmentListDefaultTab" class="selector-element optionsSelector">
339+
<option value="0">__MSG_SegmentsCap__</option>
340+
<option value="1">__MSG_Chapters__</option>
341+
</select>
342+
</div>
332343
</div>
333344

334345
<div data-type="toggle" data-sync="darkMode">

public/popup.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,8 @@
591591
#sponsorTimesDonateContainer a {
592592
color: var(--sb-main-fg-color);
593593
text-decoration: none;
594+
595+
padding-left: 5px;
594596
}
595597

596598
/*

src/components/SponsorTimeEditComponent.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
123123
style.marginTop = "15px";
124124
}
125125

126+
const borderColor = this.state.selectedCategory ? Config.config.barTypes[this.state.selectedCategory]?.color : null;
127+
126128
// Create time display
127129
let timeDisplay: JSX.Element;
128130
const timeDisplayStyle: React.CSSProperties = {};
@@ -151,7 +153,7 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
151153
<input id={"submittingTime0" + this.idSuffix}
152154
className="sponsorTimeEdit sponsorTimeEditInput"
153155
type="text"
154-
style={{color: "inherit", backgroundColor: "inherit"}}
156+
style={{color: "inherit", backgroundColor: "inherit", borderColor}}
155157
value={this.state.sponsorTimeEdits[0] ?? ""}
156158
onKeyDown={(e) => e.stopPropagation()}
157159
onKeyUp={(e) => e.stopPropagation()}
@@ -168,7 +170,7 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
168170
<input id={"submittingTime1" + this.idSuffix}
169171
className="sponsorTimeEdit sponsorTimeEditInput"
170172
type="text"
171-
style={{color: "inherit", backgroundColor: "inherit"}}
173+
style={{color: "inherit", backgroundColor: "inherit", borderColor}}
172174
value={this.state.sponsorTimeEdits[1] ?? ""}
173175
onKeyDown={(e) => e.stopPropagation()}
174176
onKeyUp={(e) => e.stopPropagation()}
@@ -215,7 +217,7 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
215217
<select id={"sponsorTimeCategories" + this.idSuffix}
216218
className="sponsorTimeEditSelector sponsorTimeCategories"
217219
ref={this.categoryOptionRef}
218-
style={{color: "inherit", backgroundColor: "inherit"}}
220+
style={{color: "inherit", backgroundColor: "inherit", borderColor}}
219221
value={this.state.selectedCategory}
220222
onChange={(event) => this.categorySelectionChange(event)}>
221223
{this.getCategoryOptions()}
@@ -240,7 +242,7 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
240242
<select id={"sponsorTimeActionTypes" + this.idSuffix}
241243
className="sponsorTimeEditSelector sponsorTimeActionTypes"
242244
value={this.state.selectedActionType}
243-
style={{color: "inherit", backgroundColor: "inherit"}}
245+
style={{color: "inherit", backgroundColor: "inherit", borderColor}}
244246
ref={this.actionTypeOptionRef}
245247
onChange={(e) => this.actionTypeSelectionChange(e)}>
246248
{this.getActionTypeOptions(sponsorTime)}
@@ -269,7 +271,7 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
269271
<div onBlur={() => this.setState({chapterNameSelectorOpen: false})}>
270272
<input id={"chapterName" + this.idSuffix}
271273
className="sponsorTimeEdit sponsorTimeEditInput sponsorChapterNameInput"
272-
style={{color: "inherit", backgroundColor: "inherit"}}
274+
style={{color: "inherit", backgroundColor: "inherit", borderColor}}
273275
ref={this.descriptionOptionRef}
274276
type="text"
275277
value={this.state.description}

src/config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as CompileConfig from "../config.json";
22
import * as invidiousList from "../ci/invidiouslist.json";
3-
import { Category, CategorySelection, CategorySkipOption, NoticeVisibilityMode, PreviewBarOption, SponsorHideType, SponsorTime, VideoID } from "./types";
3+
import { Category, CategorySelection, CategorySkipOption, NoticeVisibilityMode, PreviewBarOption, SponsorHideType, SponsorTime, VideoID, SegmentListDefaultTab } from "./types";
44
import { Keybind, keybindEquals, ProtoConfig } from "../maze-utils/src/config";
55
import { HashedValue } from "../maze-utils/src/hash";
66
import { AdvancedSkipCheck, AdvancedSkipPredicate, AdvancedSkipRule, Permission, PredicateOperator } from "./utils/skipRule";
@@ -10,6 +10,7 @@ interface SBConfig {
1010
isVip: boolean;
1111
permissions: Record<Category, Permission>;
1212
defaultCategory: Category;
13+
segmentListDefaultTab: SegmentListDefaultTab;
1314
renderSegmentsAsChapters: boolean;
1415
forceChannelCheck: boolean;
1516
minutesSaved: number;
@@ -374,6 +375,7 @@ const syncDefaults = {
374375
isVip: false,
375376
permissions: {},
376377
defaultCategory: "chooseACategory" as Category,
378+
segmentListDefaultTab: SegmentListDefaultTab.Segments,
377379
renderSegmentsAsChapters: false,
378380
forceChannelCheck: false,
379381
minutesSaved: 0,

src/popup/SegmentListComponent.tsx

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from "react";
2-
import { ActionType, SegmentUUID, SponsorHideType, SponsorTime, VideoID } from "../types";
2+
import { ActionType, SegmentListDefaultTab, SegmentUUID, SponsorHideType, SponsorTime, VideoID } from "../types";
33
import Config from "../config";
44
import { waitFor } from "../../maze-utils/src";
55
import { shortCategoryName } from "../utils/categoryUtils";
@@ -61,12 +61,21 @@ export const SegmentListComponent = (props: SegmentListComponentProps) => {
6161
}, [props.segments]);
6262

6363
React.useEffect(() => {
64-
if (hasSegments){
65-
setTab(SegmentListTab.Segments);
64+
const setTabBasedOnConfig = () => {
65+
const preferChapters = Config.config.segmentListDefaultTab === SegmentListDefaultTab.Chapters;
66+
if (preferChapters) {
67+
setTab(hasChapters ? SegmentListTab.Chapter : SegmentListTab.Segments);
68+
} else {
69+
setTab(hasSegments ? SegmentListTab.Segments : SegmentListTab.Chapter);
70+
}
71+
};
72+
73+
if (Config.isReady()) {
74+
setTabBasedOnConfig();
6675
} else {
67-
setTab(SegmentListTab.Chapter);
76+
waitFor(() => Config.isReady()).then(setTabBasedOnConfig);
6877
}
69-
}, [props.videoID, hasSegments]);
78+
}, [props.videoID, hasSegments, hasChapters]);
7079

7180
const segmentsWithNesting = React.useMemo(() => {
7281
const result: SegmentWithNesting[] = [];

src/popup/YourWorkComponent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ function TimeSavedMessage({ viewCount, minutesSaved }: { viewCount: number; minu
191191

192192
function DonateMessage(props: { onClose: () => void }): JSX.Element {
193193
return (
194-
<div id="sponsorTimesDonateContainer" style={{ alignItems: "center", justifyContent: "center" }}>
194+
<div id="sponsorTimesDonateContainer" style={{ alignItems: "center", justifyContent: "center", display: "flex" }}>
195195
<img className="sbHeart" src="/icons/heart.svg" alt="Heart icon" />
196196
<a id="sbConsiderDonateLink" href="https://sponsor.ajay.app/donate" target="_blank" rel="noreferrer" onClick={() => {
197197
Config.config.donateClicked = Config.config.donateClicked + 1;

src/types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,4 +227,9 @@ export enum NoticeVisibilityMode {
227227
MiniForAll = 2,
228228
FadedForAutoSkip = 3,
229229
FadedForAll = 4
230+
}
231+
232+
export enum SegmentListDefaultTab {
233+
Segments,
234+
Chapters,
230235
}

0 commit comments

Comments
 (0)