mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2024-11-10 01:01:55 +01:00
Fix submission menu after video ends and unskip button after video ends
This commit is contained in:
parent
d86dd37ec0
commit
f177b95a5a
7 changed files with 14 additions and 12 deletions
|
@ -1 +1 @@
|
||||||
Subproject commit 42888f800e38213f5e5d79dda953e790ada502eb
|
Subproject commit 4983281b05635362f587e030ae81ef4b60fe9de9
|
|
@ -15,6 +15,7 @@ import { downvoteButtonColor, SkipNoticeAction } from "../utils/noticeUtils";
|
||||||
import { generateUserID } from "../../maze-utils/src/setup";
|
import { generateUserID } from "../../maze-utils/src/setup";
|
||||||
import { keybindToString } from "../../maze-utils/src/config";
|
import { keybindToString } from "../../maze-utils/src/config";
|
||||||
import { getFormattedTime } from "../../maze-utils/src/formating";
|
import { getFormattedTime } from "../../maze-utils/src/formating";
|
||||||
|
import { getVideo } from "../../maze-utils/src/video";
|
||||||
|
|
||||||
enum SkipButtonState {
|
enum SkipButtonState {
|
||||||
Undo, // Unskip
|
Undo, // Unskip
|
||||||
|
@ -685,7 +686,7 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta
|
||||||
getFullDurationCountdown(index: number): () => number {
|
getFullDurationCountdown(index: number): () => number {
|
||||||
return () => {
|
return () => {
|
||||||
const sponsorTime = this.segments[index];
|
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);
|
return Math.max(duration, Config.config.skipNoticeDuration);
|
||||||
};
|
};
|
||||||
|
|
|
@ -9,6 +9,7 @@ import { DEFAULT_CATEGORY } from "../utils/categoryUtils";
|
||||||
import { getFormattedTime, getFormattedTimeToSeconds } from "../../maze-utils/src/formating";
|
import { getFormattedTime, getFormattedTimeToSeconds } from "../../maze-utils/src/formating";
|
||||||
import { asyncRequestToServer } from "../utils/requests";
|
import { asyncRequestToServer } from "../utils/requests";
|
||||||
import { defaultPreviewTime } from "../utils/constants";
|
import { defaultPreviewTime } from "../utils/constants";
|
||||||
|
import { getVideo } from "../../maze-utils/src/video";
|
||||||
|
|
||||||
export interface SponsorTimeEditProps {
|
export interface SponsorTimeEditProps {
|
||||||
index: number;
|
index: number;
|
||||||
|
@ -401,7 +402,7 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
|
||||||
checkToShowFullVideoWarning(): void {
|
checkToShowFullVideoWarning(): void {
|
||||||
const sponsorTime = this.props.contentContainer().sponsorTimesSubmitting[this.props.index];
|
const sponsorTime = this.props.contentContainer().sponsorTimesSubmitting[this.props.index];
|
||||||
const segmentDuration = sponsorTime.segment[1] - sponsorTime.segment[0];
|
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
|
if (videoPercentage > 0.6 && !this.fullVideoWarningShown
|
||||||
&& (sponsorTime.category === "sponsor" || sponsorTime.category === "selfpromo" || sponsorTime.category === "chooseACategory")) {
|
&& (sponsorTime.category === "sponsor" || sponsorTime.category === "selfpromo" || sponsorTime.category === "chooseACategory")) {
|
||||||
|
@ -553,7 +554,7 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimeToEnd(): void {
|
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;
|
sponsorTimesSubmitting[this.props.index].segment[0] = startTime;
|
||||||
}
|
}
|
||||||
} else if (this.state.sponsorTimeEdits[1] === null && category === "outro" && !sponsorTimesSubmitting[this.props.index].segment[1]) {
|
} 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();
|
this.props.contentContainer().updateEditButtonsOnPlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -683,7 +684,7 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
|
||||||
const endTime = sponsorTimes[index].segment[1];
|
const endTime = sponsorTimes[index].segment[1];
|
||||||
|
|
||||||
// If segment starts at 0:00, start playback at the end of the segment
|
// 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);
|
this.props.contentContainer().previewTime(skipTime, !skipToEndTime);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import NoticeTextSelectionComponent from "./NoticeTextSectionComponent";
|
||||||
import SponsorTimeEditComponent from "./SponsorTimeEditComponent";
|
import SponsorTimeEditComponent from "./SponsorTimeEditComponent";
|
||||||
import { getGuidelineInfo } from "../utils/constants";
|
import { getGuidelineInfo } from "../utils/constants";
|
||||||
import { exportTimes } from "../utils/exporter";
|
import { exportTimes } from "../utils/exporter";
|
||||||
|
import { getVideo } from "../../maze-utils/src/video";
|
||||||
|
|
||||||
export interface SubmissionNoticeProps {
|
export interface SubmissionNoticeProps {
|
||||||
// Contains functions and variables from the content script needed by the skip notice
|
// 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.forceUpdate();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.videoObserver.observe(this.contentContainer().v, {
|
this.videoObserver.observe(getVideo(), {
|
||||||
attributes: true
|
attributes: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -131,7 +132,7 @@ class SubmissionNoticeComponent extends React.Component<SubmissionNoticeProps, S
|
||||||
{/* Sponsor Time List */}
|
{/* Sponsor Time List */}
|
||||||
<tr id={"sponsorSkipNoticeMiddleRow" + this.state.idSuffix}
|
<tr id={"sponsorSkipNoticeMiddleRow" + this.state.idSuffix}
|
||||||
className="sponsorTimeMessagesRow"
|
className="sponsorTimeMessagesRow"
|
||||||
style={{maxHeight: (this.contentContainer().v?.offsetHeight - 200) + "px"}}
|
style={{maxHeight: (getVideo()?.offsetHeight - 200) + "px"}}
|
||||||
onMouseDown={(e) => e.stopPropagation()}>
|
onMouseDown={(e) => e.stopPropagation()}>
|
||||||
<td style={{width: "100%"}}>
|
<td style={{width: "100%"}}>
|
||||||
{this.getSponsorTimeMessages()}
|
{this.getSponsorTimeMessages()}
|
||||||
|
@ -283,7 +284,7 @@ class SubmissionNoticeComponent extends React.Component<SubmissionNoticeProps, S
|
||||||
categoryChangeListener(index: number, category: Category): void {
|
categoryChangeListener(index: number, category: Category): void {
|
||||||
const dialogWidth = this.noticeRef?.current?.getElement()?.current?.offsetWidth;
|
const dialogWidth = this.noticeRef?.current?.getElement()?.current?.offsetWidth;
|
||||||
if (category !== "chooseACategory" && Config.config.showCategoryGuidelines
|
if (category !== "chooseACategory" && Config.config.showCategoryGuidelines
|
||||||
&& this.contentContainer().v.offsetWidth > dialogWidth * 2) {
|
&& getVideo().offsetWidth > dialogWidth * 2) {
|
||||||
const options = {
|
const options = {
|
||||||
title: chrome.i18n.getMessage(`category_${category}`),
|
title: chrome.i18n.getMessage(`category_${category}`),
|
||||||
textBoxes: getGuidelineInfo(category),
|
textBoxes: getGuidelineInfo(category),
|
||||||
|
|
|
@ -177,7 +177,6 @@ const skipNoticeContentContainer: ContentContainer = () => ({
|
||||||
sponsorTimes,
|
sponsorTimes,
|
||||||
sponsorTimesSubmitting,
|
sponsorTimesSubmitting,
|
||||||
skipNotices,
|
skipNotices,
|
||||||
v: getVideo(),
|
|
||||||
sponsorVideoID: getVideoID(),
|
sponsorVideoID: getVideoID(),
|
||||||
reskipSponsorTime,
|
reskipSponsorTime,
|
||||||
updatePreviewBar,
|
updatePreviewBar,
|
||||||
|
|
|
@ -8,6 +8,7 @@ const utils = new Utils();
|
||||||
import { ContentContainer } from "../types";
|
import { ContentContainer } from "../types";
|
||||||
import NoticeTextSelectionComponent from "../components/NoticeTextSectionComponent";
|
import NoticeTextSelectionComponent from "../components/NoticeTextSectionComponent";
|
||||||
import { ButtonListener } from "../../maze-utils/src/components/component-types";
|
import { ButtonListener } from "../../maze-utils/src/components/component-types";
|
||||||
|
import { getVideo } from "../../maze-utils/src/video";
|
||||||
|
|
||||||
export interface TextBox {
|
export interface TextBox {
|
||||||
icon: string;
|
icon: string;
|
||||||
|
@ -75,7 +76,7 @@ export default class GenericNotice {
|
||||||
{options.textBoxes?.length > 0 ?
|
{options.textBoxes?.length > 0 ?
|
||||||
<tr id={"sponsorSkipNoticeMiddleRow" + this.idSuffix}
|
<tr id={"sponsorSkipNoticeMiddleRow" + this.idSuffix}
|
||||||
className="sponsorTimeMessagesRow"
|
className="sponsorTimeMessagesRow"
|
||||||
style={{maxHeight: this.contentContainer ? (this.contentContainer().v.offsetHeight - 200) + "px" : null}}>
|
style={{maxHeight: getVideo() ? (getVideo().offsetHeight - 200) + "px" : null}}>
|
||||||
<td style={{width: "100%"}}>
|
<td style={{width: "100%"}}>
|
||||||
{this.getMessageBoxes(this.idSuffix, options.textBoxes)}
|
{this.getMessageBoxes(this.idSuffix, options.textBoxes)}
|
||||||
</td>
|
</td>
|
||||||
|
|
|
@ -10,7 +10,6 @@ export interface ContentContainer {
|
||||||
sponsorTimes: SponsorTime[];
|
sponsorTimes: SponsorTime[];
|
||||||
sponsorTimesSubmitting: SponsorTime[];
|
sponsorTimesSubmitting: SponsorTime[];
|
||||||
skipNotices: SkipNotice[];
|
skipNotices: SkipNotice[];
|
||||||
v: HTMLVideoElement;
|
|
||||||
sponsorVideoID;
|
sponsorVideoID;
|
||||||
reskipSponsorTime: (segment: SponsorTime, forceSeek?: boolean) => void;
|
reskipSponsorTime: (segment: SponsorTime, forceSeek?: boolean) => void;
|
||||||
updatePreviewBar: () => void;
|
updatePreviewBar: () => void;
|
||||||
|
|
Loading…
Reference in a new issue