Skip to content

Commit

Permalink
fix: skipintro plugin client freeze
Browse files Browse the repository at this point in the history
  • Loading branch information
ThePesta committed Jun 13, 2023
1 parent a138acb commit 19773f1
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions native/skipIntroPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,21 @@ 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
if (!document.querySelector('.skipIntro .btnSkipIntro')) {
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) => {
Expand Down

0 comments on commit 19773f1

Please sign in to comment.