Browse Source

fix: skipintro plugin client freeze

ThePesta 10 months ago
parent
commit
19773f1907
1 changed files with 8 additions and 5 deletions
  1. 8 5
      native/skipIntroPlugin.js

+ 8 - 5
native/skipIntroPlugin.js

@@ -84,6 +84,13 @@ class skipIntroPlugin {
                 });
             }
 
+            function handleClick(e) {
+                e.preventDefault();
+                e.stopPropagation();
+                skipIntro();
+                document.querySelector('.skipIntro .btnSkipIntro').removeEventListener('click', handleClick, { useCapture: true });
+            }
+
             async function injectSkipIntroHtml() {
                 const playerContainer = await waitForElement('.upNextContainer', 5000);
                 // inject only if it doesn't exist
@@ -91,11 +98,7 @@ class skipIntroPlugin {
                     playerContainer.insertAdjacentHTML('afterend', skipIntroHtml);
                 }
 
-                document.querySelector('.skipIntro .btnSkipIntro').addEventListener('click', (e) => {
-                    e.preventDefault();
-                    e.stopPropagation();
-                    skipIntro();
-                }, { useCapture: true });
+                document.querySelector('.skipIntro .btnSkipIntro').addEventListener('click', handleClick, { useCapture: true });
 
                 if (window.PointerEvent) {
                     document.querySelector('.skipIntro .btnSkipIntro').addEventListener('pointerdown', (e) => {