From 19773f1907882ba816d643b3be2dc96c76514f4b Mon Sep 17 00:00:00 2001 From: ThePesta Date: Tue, 13 Jun 2023 16:43:06 +0000 Subject: [PATCH] fix: skipintro plugin client freeze --- native/skipIntroPlugin.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/native/skipIntroPlugin.js b/native/skipIntroPlugin.js index c07481b8..2c2a89a4 100644 --- a/native/skipIntroPlugin.js +++ b/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) => {