<!DOCTYPE html>
<html>
<head>
    <title>Teste Proxy</title>
</head>
<body>
    <h1>Teste de Proxy</h1>
    <button onclick="testar()">Testar Proxy</button>
    <div id="log"></div>

    <script>
    // =============================================
    // PROXY - TESTE ISOLADO
    // =============================================
    console.log('🚀 INICIANDO TESTE ISOLADO');
    
    (function() {
        console.log('🚨 CONFIGURANDO PROXY');
        const OriginalWebSocket = window.WebSocket;
        const PROXY_URL = 'wss://son.tvitecnologia.com.br/wsproxy';
        
        window.WebSocket = function(url, protocols) {
            console.log('🔌 Tentativa:', url);
            if (url && url.includes('twilio.com')) {
                console.log('%c🎯 INTERCEPTADO!', 'color: green');
                return new OriginalWebSocket(PROXY_URL, protocols);
            }
            return new OriginalWebSocket(url, protocols);
        };
        
        console.log('✅ PROXY CONFIGURADO');
    })();

    function testar() {
        console.log('🧪 Testando...');
        const ws = new WebSocket('wss://signal.twilio.com/test');
    }

    function addLog(msg) {
        document.getElementById('log').innerHTML += msg + '<br>';
    }
    </script>
</body>
</html>