From b96966dbbf6239efeeafe2fcd4c3fe784ddc51cc Mon Sep 17 00:00:00 2001 From: TristanEDU Date: Mon, 2 Jun 2025 17:35:46 -0700 Subject: [PATCH] fix(overlayUnlock): resolve variable scope and panel reference for unlock toggle - Corrected undefined reference to 'panel' (should be 'controls') - Scoped overlayUnlocked as window property to avoid redeclaration errors - Verified toggle logic properly disables/enables overlay and background interaction - Finalizes implementation of Unlock Overlay button in control panel --- content.js | 48 +++++++++++++++++++++++------------------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/content.js b/content.js index c8bcddb..e448eb9 100644 --- a/content.js +++ b/content.js @@ -92,7 +92,7 @@ if (!document.getElementById("overlay-iframe")) { }; scrollLabel.appendChild(scrollCheckbox); - // Overlay Unlock + // Overlay Unlock toggle const unlockButton = document.createElement("button"); unlockButton.textContent = "🔓 Unlock Overlay"; unlockButton.style.marginTop = "8px"; @@ -104,7 +104,7 @@ if (!document.getElementById("overlay-iframe")) { unlockButton.style.borderRadius = "4px"; unlockButton.style.width = "100%"; unlockButton.id = "unlock-overlay-button"; - panel.appendChild(unlockButton); + controls.appendChild(unlockButton); // Assemble controls controls.appendChild(scrollLabel); @@ -146,27 +146,25 @@ if (!document.getElementById("overlay-iframe")) { document.addEventListener("mouseup", () => { isDragging = false; }); + + // Unlock toggle logic + window.overlayUnlocked = false; + + unlockButton.addEventListener("click", () => { + if (!iframe) return; + + window.overlayUnlocked = !window.overlayUnlocked; + + if (window.overlayUnlocked) { + iframe.style.pointerEvents = "auto"; + document.body.style.pointerEvents = "none"; + document.documentElement.style.pointerEvents = "none"; + unlockButton.textContent = "🔒 Lock Overlay"; + } else { + iframe.style.pointerEvents = "none"; + document.body.style.pointerEvents = "auto"; + document.documentElement.style.pointerEvents = "auto"; + unlockButton.textContent = "🔓 Unlock Overlay"; + } + }); } - -let overlayUnlocked = false; - -unlockButton.addEventListener("click", () => { - const iframe = document.getElementById("overlay-iframe"); - if (!iframe) return; - - overlayUnlocked = !overlayUnlocked; - - if (overlayUnlocked) { - // Unlock: enable interaction with overlay, disable site below - iframe.style.pointerEvents = "auto"; - document.body.style.pointerEvents = "none"; - document.documentElement.style.pointerEvents = "none"; - unlockButton.textContent = "🔒 Lock Overlay"; - } else { - // Lock again: disable interaction with overlay, re-enable site - iframe.style.pointerEvents = "none"; - document.body.style.pointerEvents = "auto"; - document.documentElement.style.pointerEvents = "auto"; - unlockButton.textContent = "🔓 Unlock Overlay"; - } -});