Skip to content

Commit e89dfed

Browse files
committed
Add hide segment button to submission menu
1 parent 435b215 commit e89dfed

File tree

4 files changed

+34
-5
lines changed

4 files changed

+34
-5
lines changed

public/content.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,14 @@ input::-webkit-inner-spin-button {
683683
color: white;
684684
}
685685

686+
.hideSegmentSubmitButton {
687+
cursor: pointer;
688+
margin: auto;
689+
top: 0;
690+
bottom: 0;
691+
position: absolute;
692+
}
693+
686694
/* Start SelectorComponent */
687695

688696
.sbSelector {

src/components/SponsorTimeEditComponent.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from "react";
22
import * as CompileConfig from "../../config.json";
33
import Config from "../config";
4-
import { ActionType, Category, ChannelIDStatus, ContentContainer, SponsorTime } from "../types";
4+
import { ActionType, Category, ChannelIDStatus, ContentContainer, SponsorHideType, SponsorTime } from "../types";
55
import SubmissionNoticeComponent from "./SubmissionNoticeComponent";
66
import { RectangleTooltip } from "../render/RectangleTooltip";
77
import SelectorComponent, { SelectorOption } from "./SelectorComponent";
@@ -10,6 +10,7 @@ import { getFormattedTime, getFormattedTimeToSeconds } from "../../maze-utils/sr
1010
import { asyncRequestToServer } from "../utils/requests";
1111
import { defaultPreviewTime } from "../utils/constants";
1212
import { getVideo, getVideoDuration } from "../../maze-utils/src/video";
13+
import { AnimationUtils } from "../../maze-utils/src/animationUtils";
1314

1415
export interface SponsorTimeEditProps {
1516
index: number;
@@ -242,6 +243,22 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
242243
onChange={(e) => this.actionTypeSelectionChange(e)}>
243244
{this.getActionTypeOptions(sponsorTime)}
244245
</select>
246+
<img
247+
className="voteButton hideSegmentSubmitButton"
248+
title={chrome.i18n.getMessage("hideSegment")}
249+
src={sponsorTime.hidden === SponsorHideType.Hidden ? chrome.runtime.getURL("icons/not_visible.svg") : chrome.runtime.getURL("icons/visible.svg")}
250+
onClick={(e) => {
251+
const stopAnimation = AnimationUtils.applyLoadingAnimation(e.currentTarget, 0.4);
252+
stopAnimation();
253+
254+
if (sponsorTime.hidden === SponsorHideType.Hidden) {
255+
sponsorTime.hidden = SponsorHideType.Visible;
256+
} else {
257+
sponsorTime.hidden = SponsorHideType.Hidden;
258+
}
259+
260+
this.saveEditTimes();
261+
}}/>
245262
</div>
246263
): ""}
247264

src/content.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,9 @@ async function startSponsorSchedule(includeIntersectingSegments = false, current
713713
forceVideoTime ||= Math.max(getCurrentTime(), getVirtualTime());
714714

715715
if ((shouldSkip(currentSkip)
716-
|| sponsorTimesSubmitting?.some((segment) => segment.segment === currentSkip.segment && segment.actionType !== ActionType.Chapter))) {
716+
|| sponsorTimesSubmitting?.some((segment) => segment.segment === currentSkip.segment
717+
&& segment.actionType !== ActionType.Chapter
718+
&& segment.hidden === SponsorHideType.Visible))) {
717719
if (forceVideoTime >= skipTime[0] - skipBuffer && (forceVideoTime < skipTime[1] || skipTime[1] < skipTime[0])) {
718720
skipToTime({
719721
v: getVideo(),
@@ -1427,7 +1429,8 @@ function updatePreviewBar(): void {
14271429
}
14281430

14291431
sponsorTimesSubmitting.forEach((segment) => {
1430-
if (segment.actionType !== ActionType.Chapter || segment.segment.length > 1) {
1432+
if (segment.hidden === SponsorHideType.Visible
1433+
&& (segment.actionType !== ActionType.Chapter || segment.segment.length > 1)) {
14311434
previewBarSegments.push({
14321435
segment: segment.segment as [number, number],
14331436
category: segment.category,
@@ -1940,7 +1943,7 @@ function shouldAutoSkip(segment: SponsorTime): boolean {
19401943
}
19411944

19421945
function shouldSkip(segment: SponsorTime): boolean {
1943-
return (segment.actionType !== ActionType.Full
1946+
return segment.hidden === SponsorHideType.Visible && (segment.actionType !== ActionType.Full
19441947
&& getCategorySelection(segment)?.option > CategorySkipOption.ShowOverlay)
19451948
|| (Config.config.autoSkipOnMusicVideos && sponsorTimes?.some((s) => s.category === "music_offtopic")
19461949
&& segment.actionType === ActionType.Skip)
@@ -2135,6 +2138,7 @@ function updateSponsorTimesSubmitting(getFromConfig = true) {
21352138
category: segmentTime.category,
21362139
actionType: segmentTime.actionType,
21372140
description: segmentTime.description,
2141+
hidden: segmentTime.hidden,
21382142
source: segmentTime.source
21392143
});
21402144
}

src/popup/SegmentListComponent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ function SegmentListItem({ segment, videoID, currentTime, isVip, startingLooped,
237237
&& [SponsorHideType.Visible, SponsorHideType.Hidden].includes(segment.hidden)) &&
238238
<img
239239
className="voteButton"
240-
title="Hide Segment"
240+
title={chrome.i18n.getMessage("hideSegment")}
241241
src={hidden === SponsorHideType.Hidden ? chrome.runtime.getURL("icons/not_visible.svg") : chrome.runtime.getURL("icons/visible.svg")}
242242
onClick={(e) => {
243243
const stopAnimation = AnimationUtils.applyLoadingAnimation(e.currentTarget, 0.4);

0 commit comments

Comments
 (0)