Merge pull request #603 from ajayyy/youcap

YouCap
This commit is contained in:
Ajay Ramachandran 2020-12-29 22:53:54 -05:00 committed by GitHub
commit 1d83a4616d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 41 additions and 3 deletions

View file

@ -32,6 +32,8 @@ class SubmissionNoticeComponent extends React.Component<SubmissionNoticeProps, S
videoObserver: MutationObserver; videoObserver: MutationObserver;
showingYouCapNotice: boolean;
constructor(props: SubmissionNoticeProps) { constructor(props: SubmissionNoticeProps) {
super(props); super(props);
this.noticeRef = React.createRef(); this.noticeRef = React.createRef();
@ -45,7 +47,7 @@ class SubmissionNoticeComponent extends React.Component<SubmissionNoticeProps, S
this.state = { this.state = {
noticeTitle, noticeTitle,
messages: [], messages: [],
idSuffix: "SubmissionNotice" idSuffix: "SubmissionNotice",
} }
} }
@ -87,6 +89,8 @@ class SubmissionNoticeComponent extends React.Component<SubmissionNoticeProps, S
</td> </td>
</tr> </tr>
{this.getYouCapMessage()}
{/* Last Row */} {/* Last Row */}
<tr id={"sponsorSkipNoticeSecondRow" + this.state.idSuffix}> <tr id={"sponsorSkipNoticeSecondRow" + this.state.idSuffix}>
@ -113,6 +117,36 @@ class SubmissionNoticeComponent extends React.Component<SubmissionNoticeProps, S
); );
} }
/** TODO: Remove */
getYouCapMessage(): JSX.Element {
if (Config.config.sponsorTimesContributed < 20
|| (Config.config.hasShownYouCapNotice && !this.showingYouCapNotice)) {
return;
}
Config.config.hasShownYouCapNotice = true;
if (!this.showingYouCapNotice) {
this.showingYouCapNotice = true;
}
return (
<tr style={{textAlign: "center"}}>
<p style={{width: "300px", textAlign: "center", display: "inline-block"}}>
Like contributing to crowdsourced projects?
Consider checking out <a href="https://youcap.video/" style={{textDecoration: "underline"}}>YouCap</a>,
a new open-source replacement for YouTube{"'"}s now defunct community captions.
YouCap is NOT made by me, but I think it looks like a cool idea.
</p>
<img src={chrome.extension.getURL("icons/close.png")}
style={{padding: "0", margin: "auto"}}
className="sponsorSkipObject sponsorSkipNoticeButton sponsorSkipNoticeCloseButton"
onClick={() => { this.showingYouCapNotice = false; this.forceUpdate(); }}>
</img>
</tr>
);
}
getSponsorTimeMessages(): JSX.Element[] | JSX.Element { getSponsorTimeMessages(): JSX.Element[] | JSX.Element {
const elements: JSX.Element[] = []; const elements: JSX.Element[] = [];
this.timeEditRefs = []; this.timeEditRefs = [];

View file

@ -55,7 +55,9 @@ interface SBConfig {
"preview-selfpromo": PreviewBarOption, "preview-selfpromo": PreviewBarOption,
"music_offtopic": PreviewBarOption, "music_offtopic": PreviewBarOption,
"preview-music_offtopic": PreviewBarOption, "preview-music_offtopic": PreviewBarOption,
} },
hasShownYouCapNotice: boolean
} }
export interface SBObject { export interface SBObject {
@ -229,7 +231,9 @@ const Config: SBObject = {
color: "#a6634a", color: "#a6634a",
opacity: "0.7" opacity: "0.7"
} }
} },
hasShownYouCapNotice: false
}, },
localConfig: null, localConfig: null,
config: null, config: null,