From e2b7b6793754e5a536ad7cfc1ac7f4aea6d641f0 Mon Sep 17 00:00:00 2001 From: jean <84808582+jnptzl@users.noreply.github.com> Date: Fri, 23 Jan 2026 21:09:38 -0300 Subject: [PATCH] Fix video overlay click handling --- content.js | 55 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 21 deletions(-) diff --git a/content.js b/content.js index c031c12..f699280 100644 --- a/content.js +++ b/content.js @@ -402,33 +402,46 @@ container.style.position = 'relative'; - // Create blur overlay - const overlay = document.createElement('div'); - overlay.className = 'be-video-overlay'; - overlay.innerHTML = ` -
- click to play - `; - - overlay.addEventListener('click', (e) => { - e.preventDefault(); - e.stopPropagation(); - overlay.classList.add('be-video-revealed'); - video.play(); - }); - - container.appendChild(overlay); + let overlayRevealed = false; + + const attachOverlay = () => { + if (container.querySelector('.be-video-overlay')) return null; + const overlay = document.createElement('div'); + overlay.className = 'be-video-overlay'; + overlay.innerHTML = ` + + click to play + `; + + overlay.addEventListener('click', (e) => { + e.preventDefault(); + overlayRevealed = true; + video.play(); + overlay.remove(); + }); + + container.appendChild(overlay); + return overlay; + }; + + attachOverlay(); // Re-pause if video tries to autoplay video.addEventListener('play', () => { - if (!overlay.classList.contains('be-video-revealed')) { + if (!overlayRevealed) { video.pause(); } }); + + video.addEventListener('pause', () => { + if (video.ended) return; + overlayRevealed = false; + attachOverlay(); + }); }); }