aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/components
diff options
context:
space:
mode:
authorAjay <[email protected]>2024-06-22 17:06:29 +0530
committerAjay <[email protected]>2024-06-22 17:06:29 +0530
commitf177b95a5aeebc4e932a5984165144ca7ccab294 (patch)
tree9bc34c38c5ef7075a4e723e03518dd34eac78bbc /src/components
parentd86dd37ec074dca000d978bc83400a0feec4014a (diff)
downloadSponsorBlock-f177b95a5aeebc4e932a5984165144ca7ccab294.tar.gz
SponsorBlock-f177b95a5aeebc4e932a5984165144ca7ccab294.zip
Fix submission menu after video ends and unskip button after video ends
Diffstat (limited to 'src/components')
-rw-r--r--src/components/SkipNoticeComponent.tsx3
-rw-r--r--src/components/SponsorTimeEditComponent.tsx9
-rw-r--r--src/components/SubmissionNoticeComponent.tsx7
3 files changed, 11 insertions, 8 deletions
diff --git a/src/components/SkipNoticeComponent.tsx b/src/components/SkipNoticeComponent.tsx
index 0a351c6c..2a1292a3 100644
--- a/src/components/SkipNoticeComponent.tsx
+++ b/src/components/SkipNoticeComponent.tsx
@@ -15,6 +15,7 @@ import { downvoteButtonColor, SkipNoticeAction } from "../utils/noticeUtils";
import { generateUserID } from "../../maze-utils/src/setup";
import { keybindToString } from "../../maze-utils/src/config";
import { getFormattedTime } from "../../maze-utils/src/formating";
+import { getVideo } from "../../maze-utils/src/video";
enum SkipButtonState {
Undo, // Unskip
@@ -685,7 +686,7 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta
getFullDurationCountdown(index: number): () => number {
return () => {
const sponsorTime = this.segments[index];
- const duration = Math.round((sponsorTime.segment[1] - this.contentContainer().v.currentTime) * (1 / this.contentContainer().v.playbackRate));
+ const duration = Math.round((sponsorTime.segment[1] - getVideo().currentTime) * (1 / getVideo().playbackRate));
return Math.max(duration, Config.config.skipNoticeDuration);
};
diff --git a/src/components/SponsorTimeEditComponent.tsx b/src/components/SponsorTimeEditComponent.tsx
index 527dbbe2..f5ff47e7 100644
--- a/src/components/SponsorTimeEditComponent.tsx
+++ b/src/components/SponsorTimeEditComponent.tsx
@@ -9,6 +9,7 @@ import { DEFAULT_CATEGORY } from "../utils/categoryUtils";
import { getFormattedTime, getFormattedTimeToSeconds } from "../../maze-utils/src/formating";
import { asyncRequestToServer } from "../utils/requests";
import { defaultPreviewTime } from "../utils/constants";
+import { getVideo } from "../../maze-utils/src/video";
export interface SponsorTimeEditProps {
index: number;
@@ -401,7 +402,7 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
checkToShowFullVideoWarning(): void {
const sponsorTime = this.props.contentContainer().sponsorTimesSubmitting[this.props.index];
const segmentDuration = sponsorTime.segment[1] - sponsorTime.segment[0];
- const videoPercentage = segmentDuration / this.props.contentContainer().v.duration;
+ const videoPercentage = segmentDuration / getVideo().duration;
if (videoPercentage > 0.6 && !this.fullVideoWarningShown
&& (sponsorTime.category === "sponsor" || sponsorTime.category === "selfpromo" || sponsorTime.category === "chooseACategory")) {
@@ -553,7 +554,7 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
}
setTimeToEnd(): void {
- this.setTimeTo(1, this.props.contentContainer().v.duration);
+ this.setTimeTo(1, getVideo().duration);
}
/**
@@ -640,7 +641,7 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
sponsorTimesSubmitting[this.props.index].segment[0] = startTime;
}
} else if (this.state.sponsorTimeEdits[1] === null && category === "outro" && !sponsorTimesSubmitting[this.props.index].segment[1]) {
- sponsorTimesSubmitting[this.props.index].segment[1] = this.props.contentContainer().v.duration;
+ sponsorTimesSubmitting[this.props.index].segment[1] = getVideo().duration;
this.props.contentContainer().updateEditButtonsOnPlayer();
}
@@ -683,7 +684,7 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
const endTime = sponsorTimes[index].segment[1];
// If segment starts at 0:00, start playback at the end of the segment
- const skipTime = (startTime === 0 || skipToEndTime) ? endTime : (startTime - (seekTime * this.props.contentContainer().v.playbackRate));
+ const skipTime = (startTime === 0 || skipToEndTime) ? endTime : (startTime - (seekTime * getVideo().playbackRate));
this.props.contentContainer().previewTime(skipTime, !skipToEndTime);
}
diff --git a/src/components/SubmissionNoticeComponent.tsx b/src/components/SubmissionNoticeComponent.tsx
index 63bac370..6ecd0e84 100644
--- a/src/components/SubmissionNoticeComponent.tsx
+++ b/src/components/SubmissionNoticeComponent.tsx
@@ -9,6 +9,7 @@ import NoticeTextSelectionComponent from "./NoticeTextSectionComponent";
import SponsorTimeEditComponent from "./SponsorTimeEditComponent";
import { getGuidelineInfo } from "../utils/constants";
import { exportTimes } from "../utils/exporter";
+import { getVideo } from "../../maze-utils/src/video";
export interface SubmissionNoticeProps {
// Contains functions and variables from the content script needed by the skip notice
@@ -66,7 +67,7 @@ class SubmissionNoticeComponent extends React.Component<SubmissionNoticeProps, S
this.forceUpdate();
});
- this.videoObserver.observe(this.contentContainer().v, {
+ this.videoObserver.observe(getVideo(), {
attributes: true
});
@@ -131,7 +132,7 @@ class SubmissionNoticeComponent extends React.Component<SubmissionNoticeProps, S
{/* Sponsor Time List */}
<tr id={"sponsorSkipNoticeMiddleRow" + this.state.idSuffix}
className="sponsorTimeMessagesRow"
- style={{maxHeight: (this.contentContainer().v?.offsetHeight - 200) + "px"}}
+ style={{maxHeight: (getVideo()?.offsetHeight - 200) + "px"}}
onMouseDown={(e) => e.stopPropagation()}>
<td style={{width: "100%"}}>
{this.getSponsorTimeMessages()}
@@ -283,7 +284,7 @@ class SubmissionNoticeComponent extends React.Component<SubmissionNoticeProps, S
categoryChangeListener(index: number, category: Category): void {
const dialogWidth = this.noticeRef?.current?.getElement()?.current?.offsetWidth;
if (category !== "chooseACategory" && Config.config.showCategoryGuidelines
- && this.contentContainer().v.offsetWidth > dialogWidth * 2) {
+ && getVideo().offsetWidth > dialogWidth * 2) {
const options = {
title: chrome.i18n.getMessage(`category_${category}`),
textBoxes: getGuidelineInfo(category),