mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-13 06:57:09 +03:00
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:
@@ -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;
|
||||
Reference in New Issue
Block a user