mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-08 20:47:11 +03:00
Show notice in first slot if available
This commit is contained in:
@@ -12,6 +12,7 @@ export interface NoticeProps {
|
|||||||
|
|
||||||
maxCountdownTime?: () => number,
|
maxCountdownTime?: () => number,
|
||||||
amountOfPreviousNotices?: number,
|
amountOfPreviousNotices?: number,
|
||||||
|
showInSecondSlot?: boolean,
|
||||||
timed?: boolean,
|
timed?: boolean,
|
||||||
idSuffix?: string,
|
idSuffix?: string,
|
||||||
|
|
||||||
@@ -97,7 +98,7 @@ class NoticeComponent extends React.Component<NoticeProps, NoticeState> {
|
|||||||
return (
|
return (
|
||||||
<div id={"sponsorSkipNotice" + this.idSuffix}
|
<div id={"sponsorSkipNotice" + this.idSuffix}
|
||||||
className={"sponsorSkipObject sponsorSkipNoticeParent"
|
className={"sponsorSkipObject sponsorSkipNoticeParent"
|
||||||
+ (this.amountOfPreviousNotices > 0 ? " secondSkipNotice" : "")}
|
+ (this.props.showInSecondSlot ? " secondSkipNotice" : "")}
|
||||||
onMouseEnter={(e) => this.onMouseEnter(e) }
|
onMouseEnter={(e) => this.onMouseEnter(e) }
|
||||||
onMouseLeave={() => this.timerMouseLeave()}
|
onMouseLeave={() => this.timerMouseLeave()}
|
||||||
style={noticeStyle} >
|
style={noticeStyle} >
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta
|
|||||||
contentContainer: ContentContainer;
|
contentContainer: ContentContainer;
|
||||||
|
|
||||||
amountOfPreviousNotices: number;
|
amountOfPreviousNotices: number;
|
||||||
|
showInSecondSlot: boolean;
|
||||||
audio: HTMLAudioElement;
|
audio: HTMLAudioElement;
|
||||||
|
|
||||||
idSuffix: string;
|
idSuffix: string;
|
||||||
@@ -88,8 +89,10 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta
|
|||||||
noticeTitle = chrome.i18n.getMessage(messageId).replace("{0}", categoryName);
|
noticeTitle = chrome.i18n.getMessage(messageId).replace("{0}", categoryName);
|
||||||
}
|
}
|
||||||
|
|
||||||
//add notice
|
const previousSkipNotices = document.getElementsByClassName("sponsorSkipNoticeParent");
|
||||||
this.amountOfPreviousNotices = document.getElementsByClassName("sponsorSkipNotice").length;
|
this.amountOfPreviousNotices = previousSkipNotices.length;
|
||||||
|
// If there is at least one already in the first slot
|
||||||
|
this.showInSecondSlot = previousSkipNotices.length > 0 && [...previousSkipNotices].some(notice => !notice.classList.contains("secondSkipNotice"));
|
||||||
|
|
||||||
// Sort segments
|
// Sort segments
|
||||||
if (this.segments.length > 1) {
|
if (this.segments.length > 1) {
|
||||||
@@ -156,6 +159,7 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta
|
|||||||
return (
|
return (
|
||||||
<NoticeComponent noticeTitle={this.state.noticeTitle}
|
<NoticeComponent noticeTitle={this.state.noticeTitle}
|
||||||
amountOfPreviousNotices={this.amountOfPreviousNotices}
|
amountOfPreviousNotices={this.amountOfPreviousNotices}
|
||||||
|
showInSecondSlot={this.showInSecondSlot}
|
||||||
idSuffix={this.idSuffix}
|
idSuffix={this.idSuffix}
|
||||||
fadeIn={true}
|
fadeIn={true}
|
||||||
startFaded={true}
|
startFaded={true}
|
||||||
|
|||||||
Reference in New Issue
Block a user