/** * Clipboard Monitoring Consent Dialog * * Displays a modal dialog requesting user consent before enabling clipboard monitoring. * Complies with privacy best practices by providing clear disclosure. */ class ClipboardConsentDialog { constructor() { this.dialog = null; this.overlay = null; this.onAllow = null; this.onDeny = null; } /** * Show the consent dialog * @returns {Promise<{allowed: boolean, rememberChoice: boolean}>} */ show() { return new Promise((resolve) => { this.createDialog(); // Set up button handlers const allowBtn = this.dialog.querySelector('#clipboard-consent-allow'); const denyBtn = this.dialog.querySelector('#clipboard-consent-deny'); const rememberCheckbox = this.dialog.querySelector('#clipboard-consent-remember'); const handleResponse = (allowed) => { const rememberChoice = rememberCheckbox.checked; this.remove(); resolve({ allowed, rememberChoice }); }; allowBtn.addEventListener('click', () => handleResponse(true)); denyBtn.addEventListener('click', () => handleResponse(false)); // ESC key to deny const handleEscape = (e) => { if (e.key === 'Escape') { handleResponse(false); document.removeEventListener('keydown', handleEscape); } }; document.addEventListener('keydown', handleEscape); // Show dialog document.body.appendChild(this.overlay); document.body.appendChild(this.dialog); // Focus allow button setTimeout(() => allowBtn.focus(), 100); }); } /** * Create the dialog HTML */ createDialog() { // Create overlay this.overlay = document.createElement('div'); this.overlay.className = 'fixed inset-0 bg-black bg-opacity-50 z-50 flex items-center justify-center'; this.overlay.style.backdropFilter = 'blur(4px)'; // Create dialog this.dialog = document.createElement('div'); this.dialog.className = 'bg-[#1d293d] border border-[#45556c] rounded-lg shadow-xl max-w-md w-full mx-4 z-50'; this.dialog.setAttribute('role', 'dialog'); this.dialog.setAttribute('aria-labelledby', 'clipboard-consent-title'); this.dialog.setAttribute('aria-describedby', 'clipboard-consent-description'); this.dialog.innerHTML = `
GrabZilla can automatically detect video URLs when you copy them
Only checks for video URLs from YouTube and Vimeo
Never sent to external servers - stays on your device
Can be disabled anytime using the toggle switch