Copilot Studio Layout Enhancer

Make Test your agent canvas take 80% width and hide Create button

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Copilot Studio Layout Enhancer
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Make Test your agent canvas take 80% width and hide Create button
// @author       You
// @match        https://copilotstudio.microsoft.com/environments/*/create/new
// @grant        none
// ==/UserScript==


(function() {
    'use strict';


    // Add custom styles
    const style = document.createElement('style');
    style.textContent = `
        /* Make the Test your agent canvas take up 80% of the window */
        div.___95z3l10.f22iagw.ff23yd3.f6dzj5z.fi4v0vl.fly5x3f.f61z0x5.fprs0cq {
            width: 80% !important;
            max-width: 80% !important;
            flex: 0 0 80% !important;
        }


        /* Hide the Create button */
        button[data-telemetry-id="GPTCreationPage-ActionMenu-Create"] {
            display: none !important;
        }


        /* Adjust the left panel to take remaining space */
        div.___95z3l10.f22iagw.ff23yd3.f6dzj5z.fi4v0vl.fly5x3f.f61z0x5.fprs0cq ~ * {
            flex: 1 !important;
        }
    `;
    document.head.appendChild(style);


    // Function to hide Create button (in case it loads after initial page load)
    function hideCreateButton() {
        const createButton = document.querySelector('button[data-telemetry-id="GPTCreationPage-ActionMenu-Create"]');
        if (createButton) {
            createButton.style.display = 'none';
        }
    }


    // Function to resize the Test your agent panel
    function resizeTestPanel() {
        const testPanel = document.querySelector('div.___95z3l10.f22iagw.ff23yd3.f6dzj5z.fi4v0vl.fly5x3f.f61z0x5.fprs0cq');
        if (testPanel) {
            testPanel.style.width = '80%';
            testPanel.style.maxWidth = '80%';
            testPanel.style.flex = '0 0 80%';
        }
    }


    // Run immediately
    hideCreateButton();
    resizeTestPanel();


    // Watch for DOM changes in case elements load dynamically
    const observer = new MutationObserver(function(mutations) {
        hideCreateButton();
        resizeTestPanel();
    });


    // Start observing
    observer.observe(document.body, {
        childList: true,
        subtree: true
    });


    // Also run after a short delay to catch any delayed loads
    setTimeout(() => {
        hideCreateButton();
        resizeTestPanel();
    }, 1000);


    setTimeout(() => {
        hideCreateButton();
        resizeTestPanel();
    }, 2000);
})();