Google AI Studio - Performance & UI Optimization

Advanced performance optimizations for Google AI Studio. Features zero-latency UI, auto-expanding text areas, and reduced browser rendering overhead.

Tendrás que instalar una extensión para tu navegador como Tampermonkey, Greasemonkey o Violentmonkey si quieres utilizar este script.

You will need to install an extension such as Tampermonkey to install this script.

Tendrás que instalar una extensión como Tampermonkey o Violentmonkey para instalar este script.

Necesitarás instalar una extensión como Tampermonkey o Userscripts para instalar este script.

Tendrás que instalar una extensión como Tampermonkey antes de poder instalar este script.

Necesitarás instalar una extensión para administrar scripts de usuario si quieres instalar este script.

(Ya tengo un administrador de scripts de usuario, déjame instalarlo)

Tendrás que instalar una extensión como Stylus antes de poder instalar este script.

Tendrás que instalar una extensión como Stylus antes de poder instalar este script.

Tendrás que instalar una extensión como Stylus antes de poder instalar este script.

Para poder instalar esto tendrás que instalar primero una extensión de estilos de usuario.

Para poder instalar esto tendrás que instalar primero una extensión de estilos de usuario.

Para poder instalar esto tendrás que instalar primero una extensión de estilos de usuario.

(Ya tengo un administrador de estilos de usuario, déjame instalarlo)

// ==UserScript==
// @name         Google AI Studio - Performance & UI Optimization
// @namespace    https://aistudio.google.com/
// @version      1.0.2.1
// @description  Advanced performance optimizations for Google AI Studio. Features zero-latency UI, auto-expanding text areas, and reduced browser rendering overhead.
// @author       John
// @match        https://aistudio.google.com/*
// @grant        GM_addStyle
// @run-at       document-start
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    const css = `
        /* 1. RENDERING PIPELINE OPTIMIZATION */
        *, *::before, *::after {
            transition: none !important;
            animation: none !important;
            backdrop-filter: none !important;
            box-shadow: none !important;
            text-shadow: none !important;
        }

        /* 2. INTERFACE COLOR SCHEME (High-Contrast Dark) */
        body,
        mat-sidenav-container,
        mat-sidenav-content,
        .scroll-container,
        .monaco-editor,
        .monaco-editor-background {
            background-color: rgb(25, 25, 25) !important; /* This is #191919 */
            color: #e0e0e0 !important;
        }

        /* 3. GROUNDING TOOL SPACING & COLOR FIX */
        /* Forces the container background to #252525 while preserving button styles */
        .content-container:has(.enabled-tool),
        .enabled-tool {
            background-color: #252525 !important;
            border-radius: 4px !important;
            padding: 4px 8px !important;
        }

        /* 4. CONTENT LAYOUT & SPACING CONTEXT */
        ms-chat-turn,
        .turn-container,
        .history-item {
            background: rgb(25, 25, 25) !important;
            border: none !important;

            /* Spacing Logic: 5px Lateral, 25px Vertical Offset */
            padding-left: 5px !important;
            padding-right: 5px !important;
            padding-top: 25px !important;

            /* Margin Reset for Consistent Vertical Flow */
            margin: 5px !important;
            margin-top: 0px !important;

            /* Rendering Containment */
            contain: layout paint style !important;
            overflow: visible !important;
            display: block !important;
        }

        /* NESTED ELEMENT RESET */
        ms-chat-turn .message-content,
        ms-chat-turn mat-card,
        ms-chat-turn .model-message,
        ms-chat-turn .user-message,
        ms-chat-turn ms-message-content {
            padding: 0 !important;
            margin: 0 !important;
            background: transparent !important;
        }

        /* 5. DYNAMIC INPUT FIELD OPTIMIZATION */
        textarea {
            background-color: rgb(35, 35, 35) !important;
            color: #ffffff !important;
            border: 1px solid #555 !important;
            border-radius: 0px !important;
            padding: 15px !important;
            will-change: contents !important;

            /* Native Layout-based Resizing */
            field-sizing: content !important;
            max-height: 80vh !important;
            min-height: 60px !important;
            height: auto !important;
            resize: none !important;
        }

        /* 6. SYSTEM SCROLLBAR STYLING */
        ::-webkit-scrollbar {
            width: 12px !important;
            background: rgb(25, 25, 25) !important;
        }
        ::-webkit-scrollbar-thumb {
            background: #444 !important;
            border: 1px solid rgb(25, 25, 25) !important;
        }

        /* 7. UI DE-CLUTTERING */
        .sparkle-container, .magic-overlay, .thinking-shimmer {
            display: none !important;
        }

        /* 8. HARDWARE-ACCELERATED COMPOSITING */
        .overflow-y-auto, main {
            will-change: scroll-position !important;
            transform: translateZ(0) !important;
        }
    `;

    const style = document.createElement('style');
    style.textContent = css;
    document.head.append(style);

    // PERFORMANCE ENGINES (Decoupled Scroll & Input Prediction)
    const originalAddEventListener = EventTarget.prototype.addEventListener;
    EventTarget.prototype.addEventListener = function(type, listener, options) {
        if (type === 'wheel' || type === 'mousewheel' || type === 'touchstart' || type === 'touchmove') {
            if (typeof options === 'object') {
                options.passive = true;
            } else {
                options = { passive: true };
            }
        }
        return originalAddEventListener.call(this, type, listener, options);
    };

    const optimizeInput = () => {
        const inputs = document.querySelectorAll('textarea');
        inputs.forEach(el => {
            if (el.getAttribute('spellcheck') !== 'false') {
                el.setAttribute('spellcheck', 'false');
                el.setAttribute('autocomplete', 'off');
            }
        });
    };

    window.addEventListener('click', optimizeInput, { passive: true });
    window.addEventListener('focus', optimizeInput, { passive: true, capture: true });

    console.log("AI Studio Performance Suite: Initialized.");

})();