Azure AI Foundry

Makes the AI chat menu bigger

当前为 2025-11-21 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Azure AI Foundry
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Makes the AI chat menu bigger
// @match        https://ai.azure.com/nextgen/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    console.log('Azure AI Foundry Userscript: Starting...');

    // Add CSS to expand the ASK AI chat sidebar to 1800px
    const style = document.createElement('style');
    style.id = 'azure-ai-sidebar-expander';
    style.textContent = `
        /* Target the ASK AI sidebar specifically with high specificity */
        div.fui-InlineDrawer.fui-Drawer._rightPanel_1envo_1._rightPanel_1mu44_89,
        div.fui-InlineDrawer.fui-Drawer._rightPanel_1envo_1,
        div.fui-Drawer._rightPanel_1envo_1,
        div._rightPanel_1envo_1,
        [class*="_rightPanel_1envo"] {
            max-width: 1800px !important;
            width: 1800px !important;
            min-width: 1800px !important;
        }
    `;

    // Add the style to the page immediately
    if (!document.getElementById('azure-ai-sidebar-expander')) {
        (document.head || document.documentElement).appendChild(style);
        console.log('Azure AI Foundry: Chat sidebar CSS applied');
    }

    // Function to directly set the width on the element
    function expandSidebar() {
        const sidebar = document.querySelector('.fui-InlineDrawer.fui-Drawer._rightPanel_1envo_1');
        if (sidebar) {
            sidebar.style.setProperty('width', '1800px', 'important');
            sidebar.style.setProperty('max-width', '1800px', 'important');
            sidebar.style.setProperty('min-width', '1800px', 'important');
            console.log('Azure AI Foundry: ✓ Sidebar width set directly to 1800px!');
            return true;
        }
        return false;
    }

    // Function to toggle the Agent Helper sidebar on
    function toggleAgentHelper() {
        const button = document.querySelector('button[aria-label="Agent Helper"][aria-pressed="false"]');

        if (button) {
            console.log('Azure AI Foundry: Found Agent Helper button, clicking...');

            // Simulate a real user click with all events
            button.dispatchEvent(new MouseEvent('mousedown', { bubbles: true, cancelable: true }));
            button.dispatchEvent(new MouseEvent('mouseup', { bubbles: true, cancelable: true }));
            button.dispatchEvent(new MouseEvent('click', {
                view: window,
                bubbles: true,
                cancelable: true,
                buttons: 1
            }));

            console.log('Azure AI Foundry: ✓ Agent Helper button clicked!');
            return true;
        }

        return false;
    }

    // Check if sidebar is open
    function isSidebarOpen() {
        return document.querySelector('.fui-InlineDrawer.fui-Drawer[class*="_rightPanel"]') !== null;
    }

    // Try to open the sidebar with retries
    function init() {
        console.log('Azure AI Foundry: Waiting for page to load...');

        let attempts = 0;
        const maxAttempts = 5;

        function tryOpen() {
            attempts++;

            if (isSidebarOpen()) {
                console.log('Azure AI Foundry: ✓ Sidebar already open!');
                expandSidebar();
                return;
            }

            if (toggleAgentHelper()) {
                // Check if it opened after clicking
                setTimeout(() => {
                    if (isSidebarOpen()) {
                        console.log('Azure AI Foundry: ✓ Sidebar opened!');
                        // Directly set the width
                        setTimeout(() => {
                            expandSidebar();
                        }, 100);
                    } else if (attempts < maxAttempts) {
                        console.log(`Azure AI Foundry: Sidebar didn't open, retrying... (attempt ${attempts}/${maxAttempts})`);
                        setTimeout(tryOpen, 2000);
                    } else {
                        console.log('Azure AI Foundry: ⚠ Max attempts reached. CSS will still work when you manually open it.');
                    }
                }, 500);
            } else if (attempts < maxAttempts) {
                console.log(`Azure AI Foundry: Button not found, retrying... (attempt ${attempts}/${maxAttempts})`);
                setTimeout(tryOpen, 2000);
            } else {
                console.log('Azure AI Foundry: ⚠ Button not found after max attempts. CSS will work when you manually open the sidebar.');
            }
        }

        // Start trying after initial delay
        setTimeout(tryOpen, 2000);
    }

    // Run when DOM is ready
    if (document.readyState === 'loading') {
        document.addEventListener('DOMContentLoaded', init);
    } else {
        init();
    }
})();