mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-10 05:27:03 +03:00
Hide unmute buttons after segment is finished
This commit is contained in:
@@ -41,6 +41,7 @@ export interface SkipNoticeState {
|
|||||||
|
|
||||||
skipButtonText?: string;
|
skipButtonText?: string;
|
||||||
skipButtonCallback?: (index: number) => void;
|
skipButtonCallback?: (index: number) => void;
|
||||||
|
showSkipButton?: boolean;
|
||||||
|
|
||||||
downvoting?: boolean;
|
downvoting?: boolean;
|
||||||
choosingCategory?: boolean;
|
choosingCategory?: boolean;
|
||||||
@@ -112,6 +113,7 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta
|
|||||||
|
|
||||||
skipButtonText: this.getUnskipText(),
|
skipButtonText: this.getUnskipText(),
|
||||||
skipButtonCallback: (index) => this.unskip(index),
|
skipButtonCallback: (index) => this.unskip(index),
|
||||||
|
showSkipButton: true,
|
||||||
|
|
||||||
downvoting: false,
|
downvoting: false,
|
||||||
choosingCategory: false,
|
choosingCategory: false,
|
||||||
@@ -296,9 +298,9 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta
|
|||||||
}
|
}
|
||||||
|
|
||||||
getSkipButton(): JSX.Element {
|
getSkipButton(): JSX.Element {
|
||||||
if (this.segments.length > 1
|
if (this.state.showSkipButton && (this.segments.length > 1
|
||||||
|| getCategoryActionType(this.segments[0].category) !== CategoryActionType.POI
|
|| getCategoryActionType(this.segments[0].category) !== CategoryActionType.POI
|
||||||
|| this.props.unskipTime) {
|
|| this.props.unskipTime)) {
|
||||||
return (
|
return (
|
||||||
<span className="sponsorSkipNoticeUnskipSection">
|
<span className="sponsorSkipNoticeUnskipSection">
|
||||||
<button id={"sponsorSkipUnskipButton" + this.idSuffix}
|
<button id={"sponsorSkipUnskipButton" + this.idSuffix}
|
||||||
@@ -559,6 +561,16 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta
|
|||||||
this.props.closeListener();
|
this.props.closeListener();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unmutedListener(): void {
|
||||||
|
if (this.props.segments.length === 1
|
||||||
|
&& this.props.segments[0].actionType === ActionType.Mute
|
||||||
|
&& this.contentContainer().v.currentTime >= this.props.segments[0].segment[1]) {
|
||||||
|
this.setState({
|
||||||
|
showSkipButton: false
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private getUnskipText(): string {
|
private getUnskipText(): string {
|
||||||
switch (this.props.segments[0].actionType) {
|
switch (this.props.segments[0].actionType) {
|
||||||
case ActionType.Mute: {
|
case ActionType.Mute: {
|
||||||
|
|||||||
@@ -417,6 +417,11 @@ function startSponsorSchedule(includeIntersectingSegments = false, currentTime?:
|
|||||||
if (videoMuted && !inMuteSegment(currentTime)) {
|
if (videoMuted && !inMuteSegment(currentTime)) {
|
||||||
video.muted = false;
|
video.muted = false;
|
||||||
videoMuted = false;
|
videoMuted = false;
|
||||||
|
|
||||||
|
for (const notice of skipNotices) {
|
||||||
|
// So that the notice can hide buttons
|
||||||
|
notice.unmutedListener();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.config.disableSkipping || channelWhitelisted || (channelIDInfo.status === ChannelIDStatus.Fetching && Config.config.forceChannelCheck)){
|
if (Config.config.disableSkipping || channelWhitelisted || (channelIDInfo.status === ChannelIDStatus.Fetching && Config.config.forceChannelCheck)){
|
||||||
|
|||||||
@@ -71,6 +71,10 @@ class SkipNotice {
|
|||||||
toggleSkip(): void {
|
toggleSkip(): void {
|
||||||
this.skipNoticeRef?.current?.prepAction(SkipNoticeAction.Unskip);
|
this.skipNoticeRef?.current?.prepAction(SkipNoticeAction.Unskip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unmutedListener(): void {
|
||||||
|
this.skipNoticeRef?.current?.unmutedListener();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default SkipNotice;
|
export default SkipNotice;
|
||||||
Reference in New Issue
Block a user