mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-12 06:27:14 +03:00
Fix category pill disappearing on mobile
This commit is contained in:
@@ -27,39 +27,40 @@ export class CategoryPill {
|
|||||||
await waitFor(() => getYouTubeTitleNode());
|
await waitFor(() => getYouTubeTitleNode());
|
||||||
|
|
||||||
if (referenceNode && !referenceNode.contains(this.container)) {
|
if (referenceNode && !referenceNode.contains(this.container)) {
|
||||||
this.container = document.createElement('span');
|
if (!this.container) {
|
||||||
this.container.id = "categoryPill";
|
this.container = document.createElement('span');
|
||||||
this.container.style.display = "relative";
|
this.container.id = "categoryPill";
|
||||||
|
this.container.style.display = "relative";
|
||||||
|
|
||||||
referenceNode.prepend(this.container);
|
this.root = createRoot(this.container);
|
||||||
referenceNode.style.display = "flex";
|
this.root.render(<CategoryPillComponent ref={this.ref} vote={vote} />);
|
||||||
|
|
||||||
if (this.ref.current) {
|
if (onMobileYouTube) {
|
||||||
this.unsavedState = this.ref.current.state;
|
if (this.mutationObserver) {
|
||||||
|
this.mutationObserver.disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.mutationObserver = new MutationObserver((changes) => {
|
||||||
|
if (changes.some((change) => change.removedNodes.length > 0)) {
|
||||||
|
this.attachToPage(onMobileYouTube, onInvidious, vote);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.mutationObserver.observe(referenceNode, {
|
||||||
|
childList: true,
|
||||||
|
subtree: true
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.root = createRoot(this.container);
|
|
||||||
this.root.render(<CategoryPillComponent ref={this.ref} vote={vote} />);
|
|
||||||
|
|
||||||
if (this.unsavedState) {
|
if (this.unsavedState) {
|
||||||
waitFor(() => this.ref.current).then(() => {
|
waitFor(() => this.ref.current).then(() => {
|
||||||
this.ref.current?.setState(this.unsavedState);
|
this.ref.current?.setState(this.unsavedState);
|
||||||
this.unsavedState = null;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (onMobileYouTube) {
|
|
||||||
if (this.mutationObserver) {
|
|
||||||
this.mutationObserver.disconnect();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.mutationObserver = new MutationObserver(() => this.attachToPage(onMobileYouTube, onInvidious, vote));
|
|
||||||
|
|
||||||
this.mutationObserver.observe(referenceNode, {
|
|
||||||
childList: true,
|
|
||||||
subtree: true
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
referenceNode.prepend(this.container);
|
||||||
|
referenceNode.style.display = "flex";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,6 +80,8 @@ export class CategoryPill {
|
|||||||
} else {
|
} else {
|
||||||
this.unsavedState = newState;
|
this.unsavedState = newState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(this.unsavedState, this.ref.current?.state, "visible");
|
||||||
}
|
}
|
||||||
|
|
||||||
async setSegment(segment: SponsorTime): Promise<void> {
|
async setSegment(segment: SponsorTime): Promise<void> {
|
||||||
|
|||||||
Reference in New Issue
Block a user