A skip notice is now shown upon voting if one isn't already on screen

A skip notice is now shown upon voting if one isn't already on screen

minor fixes
This commit is contained in:
gosha305
2025-02-15 23:34:42 +01:00
parent 75dc6a1980
commit 66876283b4
4 changed files with 44 additions and 8 deletions

View File

@@ -81,6 +81,26 @@ class SkipNotice {
unmutedListener(time: number): void {
this.skipNoticeRef?.current?.unmutedListener(time);
}
async waitForSkipNoticeRef(): Promise<SkipNoticeComponent> {
const waitForRef = () => new Promise<SkipNoticeComponent>((resolve) => {
const observer = new MutationObserver(() => {
if (this.skipNoticeRef.current) {
observer.disconnect();
resolve(this.skipNoticeRef.current);
}
});
observer.observe(document.getElementsByClassName("sponsorSkipNoticeContainer")[0], { childList: true, subtree: true});
if (this.skipNoticeRef.current) {
observer.disconnect();
resolve(this.skipNoticeRef.current);
}
});
return this.skipNoticeRef?.current || await waitForRef();
}
}
export default SkipNotice;