From 669ac6d3da202ee0d304e4b3f4fbb017b11be059 Mon Sep 17 00:00:00 2001 From: CodeDevMLH <145071728+CodeDevMLH@users.noreply.github.com> Date: Fri, 27 Feb 2026 03:58:34 +0100 Subject: [PATCH] Fix spider and mouse creation logic to ensure animations only continue if the container is present in the DOM --- Jellyfin.Plugin.Seasonals/Web/halloween.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Jellyfin.Plugin.Seasonals/Web/halloween.js b/Jellyfin.Plugin.Seasonals/Web/halloween.js index b3ab05a..766fbc1 100644 --- a/Jellyfin.Plugin.Seasonals/Web/halloween.js +++ b/Jellyfin.Plugin.Seasonals/Web/halloween.js @@ -182,14 +182,18 @@ function createSpider(container) { setTimeout(() => { wrapper.remove(); - setTimeout(() => createSpider(container), Math.random() * 5000 + 1000); + if (document.body.contains(container)) { + setTimeout(() => createSpider(container), Math.random() * 5000 + 1000); + } }, 500); }); wrapper.addEventListener('animationend', () => { if (isRetreating) return; wrapper.remove(); - setTimeout(() => createSpider(container), Math.random() * 5000 + 1000); + if (document.body.contains(container)) { + setTimeout(() => createSpider(container), Math.random() * 5000 + 1000); + } }); container.appendChild(wrapper); @@ -223,7 +227,9 @@ function createMouse(container) { mouse.addEventListener('animationend', () => { mouse.remove(); - setTimeout(() => createMouse(container), Math.random() * 4000 + 2000); + if (document.body.contains(container)) { + setTimeout(() => createMouse(container), Math.random() * 4000 + 2000); + } }); container.appendChild(mouse);