// ==UserScript== // @name DeepSeek Tokens Remaining y Caracteres // @version 1.1 // @description Real-time token and character counter for DeepSeek Chat // @author Steve Casanova // @namespace Steve Casanova // @match https://chat.deepseek.com/* // @grant none // @license MIT // @downloadURL none // ==/UserScript== (function() { 'use strict'; // Configuración const MAX_TOKENS_PER_MESSAGE = 4096; // Límite de tokens por mensaje en DeepSeek const TOKEN_RATIO = 4; // 1 token ≈ 4 caracteres (aproximación) // Esperar a que el textarea esté disponible const waitForTextarea = setInterval(() => { const textarea = document.getElementById('chat-input'); if (textarea) { clearInterval(waitForTextarea); setupCounter(textarea); } }, 500); function setupCounter(textarea) { // Crear el contador const counter = document.createElement('div'); counter.style.position = 'fixed'; counter.style.bottom = '60px'; counter.style.right = '20px'; counter.style.backgroundColor = 'rgba(0, 0, 0, 0.7)'; counter.style.color = 'white'; counter.style.padding = '8px 12px'; counter.style.borderRadius = '8px'; counter.style.fontFamily = 'Arial, sans-serif'; counter.style.fontSize = '14px'; counter.style.zIndex = '9999'; counter.style.boxShadow = '0 2px 5px rgba(0,0,0,0.3)'; // Función para actualizar el contador const updateCounter = () => { const text = textarea.value; const charCount = text.length; const tokenEstimate = Math.ceil(charCount / TOKEN_RATIO); // Calcular porcentaje usado const percentUsed = Math.min(100, Math.round((tokenEstimate / MAX_TOKENS_PER_MESSAGE) * 100)); // Determinar color basado en el porcentaje let color; if (percentUsed < 70) { color = '#4CAF50'; // Verde } else if (percentUsed < 90) { color = '#FFC107'; // Amarillo } else { color = '#F44336'; // Rojo } counter.innerHTML = `
DeepSeek Token Counter
Caracteres: ${charCount}
Tokens estimados: ${tokenEstimate}/${MAX_TOKENS_PER_MESSAGE}
`; // Mostrar advertencia si se excede el límite if (tokenEstimate >= MAX_TOKENS_PER_MESSAGE) { counter.innerHTML += `
¡Máximo de tokens alcanzado!
`; } }; // Event listeners textarea.addEventListener('input', updateCounter); textarea.addEventListener('keyup', updateCounter); textarea.addEventListener('change', updateCounter); // Inicializar updateCounter(); document.body.appendChild(counter); // Asegurarse de que el contador permanezca visible const observer = new MutationObserver(() => { if (!document.body.contains(counter)) { document.body.appendChild(counter); } }); observer.observe(document.body, { childList: true }); } })();