mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-07 12:07:11 +03:00
Fix preview bar not being recreated
This commit is contained in:
@@ -87,6 +87,7 @@ const playerButtons: Record<string, {button: HTMLButtonElement, image: HTMLImage
|
|||||||
|
|
||||||
// Direct Links after the config is loaded
|
// Direct Links after the config is loaded
|
||||||
utils.wait(() => Config.config !== null, 1000, 1).then(() => videoIDChange(getYouTubeVideoID(document)));
|
utils.wait(() => Config.config !== null, 1000, 1).then(() => videoIDChange(getYouTubeVideoID(document)));
|
||||||
|
addPageListeners();
|
||||||
addHotkeyListener();
|
addHotkeyListener();
|
||||||
|
|
||||||
//the amount of times the sponsor lookup has retried
|
//the amount of times the sponsor lookup has retried
|
||||||
@@ -377,7 +378,7 @@ function createPreviewBar(): void {
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const selector of progressElementSelectors) {
|
for (const selector of progressElementSelectors) {
|
||||||
const el = document.querySelector<HTMLElement>(selector);
|
const el = findValidElement(document.querySelectorAll(selector));
|
||||||
|
|
||||||
if (el) {
|
if (el) {
|
||||||
previewBar = new PreviewBar(el, onMobileYouTube, onInvidious);
|
previewBar = new PreviewBar(el, onMobileYouTube, onInvidious);
|
||||||
@@ -550,6 +551,14 @@ function refreshVideoAttachments() {
|
|||||||
setupVideoListeners();
|
setupVideoListeners();
|
||||||
setupSkipButtonControlBar();
|
setupSkipButtonControlBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create a new bar in the new video element
|
||||||
|
if (previewBar && !utils.findReferenceNode()?.contains(previewBar.container)) {
|
||||||
|
previewBar.remove();
|
||||||
|
previewBar = null;
|
||||||
|
|
||||||
|
createPreviewBar();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1843,6 +1852,16 @@ function getSegmentsMessage(sponsorTimes: SponsorTime[]): string {
|
|||||||
return sponsorTimesMessage;
|
return sponsorTimesMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addPageListeners(): void {
|
||||||
|
const refreshListners = () => {
|
||||||
|
if (!isVisible(video)) {
|
||||||
|
refreshVideoAttachments();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
document.addEventListener("yt-navigate-finish", refreshListners);
|
||||||
|
}
|
||||||
|
|
||||||
function addHotkeyListener(): void {
|
function addHotkeyListener(): void {
|
||||||
document.addEventListener("keydown", hotkeyListener);
|
document.addEventListener("keydown", hotkeyListener);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user