(function() { 'use strict'; // Prevent double loading if (window.AIVoiceWidget) return; var AIVoiceWidget = { config: window.AIVoiceConfig || {}, init: function() { this.injectStyles(); this.createWidget(); this.setupBrandRemoval(); }, injectStyles: function() { if (document.getElementById('ai-voice-widget-styles')) return; var style = document.createElement('style'); style.id = 'ai-voice-widget-styles'; style.textContent = ` /* CSS-based hiding as instant fallback */ p[class*="web-inspector-hide-shortcut"], p:has(span:contains("Powered by ElevenLabs")), a[href*="elevenlabs.io/conversational-ai"] { display: none !important; visibility: hidden !important; opacity: 0 !important; height: 0 !important; overflow: hidden !important; } /* Widget container styling */ .ai-voice-container { position: relative; width: 100%; height: auto; } `; document.head.appendChild(style); }, createWidget: function() { var containers = document.querySelectorAll('[data-ai-voice-widget]'); containers.forEach(function(container) { var agentId = container.getAttribute('data-agent-id') || this.config.agentId || 'MQhbua6AlCYnhLwFLH3A'; container.className += ' ai-voice-container'; // Create ElevenLabs widget with new embed var widget = document.createElement('elevenlabs-convai'); widget.setAttribute('agent-id', agentId); container.appendChild(widget); }.bind(this)); this.loadElevenLabsScript(); }, loadElevenLabsScript: function() { if (document.querySelector('script[src*="@elevenlabs/convai-widget-embed"]')) return; var script = document.createElement('script'); script.src = 'https://unpkg.com/@elevenlabs/convai-widget-embed'; script.async = true; script.onload = function() { this.startImmediateRemoval(); }.bind(this); document.body.appendChild(script); }, // Fast removal function targeting the widget directly fastRemoveFooter: function() { var widget = document.querySelector('elevenlabs-convai'); if (widget && widget.shadowRoot) { // Method 1: Direct class targeting var footer = widget.shadowRoot.querySelector( 'p.whitespace-nowrap[class*="web-inspector-hide-shortcut"]' ); if (footer) { footer.remove(); return true; } // Method 2: Text content search var paragraphs = widget.shadowRoot.querySelectorAll('p'); for (var i = 0; i < paragraphs.length; i++) { var p = paragraphs[i]; if (p.textContent.includes('Powered by ElevenLabs')) { p.remove(); return true; } } // Method 3: Link-based removal var link = widget.shadowRoot.querySelector('a[href*="elevenlabs.io"]'); if (link) { var parentP = link.closest('p'); if (parentP) { parentP.remove(); return true; } } } return false; }, // Ultra-fast monitoring with requestAnimationFrame ultraFastCheck: function() { var self = this; var checkCount = 0; var maxChecks = 200; // Stop after 200 checks (about 10 seconds at 60fps) function check() { if (self.fastRemoveFooter()) { console.log('ElevenLabs footer removed!'); return; // Stop checking once removed } checkCount++; if (checkCount < maxChecks) { requestAnimationFrame(check); } } check(); }, // High-frequency interval checking setupAggressiveMonitoring: function() { var self = this; // Start ultra-fast checking immediately this.ultraFastCheck(); // Also use high-frequency intervals as backup var intervals = [50, 100, 200, 500, 1000]; intervals.forEach(function(delay) { setTimeout(function() { var intervalId = setInterval(function() { if (self.fastRemoveFooter()) { clearInterval(intervalId); } }, delay); // Stop interval after 15 seconds setTimeout(function() { clearInterval(intervalId); }, 15000); }, delay); }); // MutationObserver for instant detection var observer = new MutationObserver(function() { self.fastRemoveFooter(); }); // Watch the widget specifically var widget = document.querySelector('elevenlabs-convai'); if (widget) { observer.observe(widget, { childList: true, subtree: true, attributes: true }); } // Also watch the whole document observer.observe(document.body, { childList: true, subtree: true }); // Stop observer after 30 seconds setTimeout(function() { observer.disconnect(); }, 30000); }, // Immediate execution strategies startImmediateRemoval: function() { var self = this; // Try immediately this.fastRemoveFooter(); // Try every 10ms for the first second for (var i = 1; i <= 100; i++) { setTimeout(function() { self.fastRemoveFooter(); }, i * 10); } // Try every 50ms for the next 4 seconds for (var i = 1; i <= 80; i++) { setTimeout(function() { self.fastRemoveFooter(); }, 1000 + i * 50); } // Setup aggressive monitoring this.setupAggressiveMonitoring(); }, setupBrandRemoval: function() { // Start immediately - don't wait for anything this.startImmediateRemoval(); // Also trigger on DOM ready and window load as backups if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', this.startImmediateRemoval.bind(this)); } window.addEventListener('load', this.startImmediateRemoval.bind(this)); } }; // Auto-initialize when DOM is ready function initialize() { AIVoiceWidget.init(); } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', initialize); } else { initialize(); } window.AIVoiceWidget = AIVoiceWidget; })();