Skip to content

Commit

Permalink
Merge pull request #456 from ThePesta/fix-skip-freeze
Browse files Browse the repository at this point in the history
fix: skipintro plugin client freeze
  • Loading branch information
iwalton3 authored Jun 14, 2023
2 parents a138acb + 19773f1 commit bc0ec5a
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 bc0ec5a

Please sign in to comment.