Greasy Fork

Greasy Fork is available in English.

Expand

Expand the width of the page

当前为 2024-05-20 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Expand
// @namespace    https://github.com/neokyuubi/expand-chatgpt
// @version      2024-04-30
// @description  Expand the width of the page
// @author       Neokyuubi
// @match        https://chat.openai.com/*
// @match        https://chatgpt.com/c/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=openai.com
// @grant        none
// @require      https://code.jquery.com/jquery-3.6.0.min.js
// ==/UserScript==

(function() {
    'use strict';
    $(document).ready(function() {
        // Function to update max-width of elements
        function updateMaxWidth() {
            $('[class*="xl:max-w-[48rem]"]').css('max-width', '100rem');
        }

        // Initial update
        updateMaxWidth();

        // Create a MutationObserver to watch for added nodes
        const observer = new MutationObserver(function(mutationsList) {
            for (const mutation of mutationsList) {
                if (mutation.type === 'childList') {
                    // Check added nodes for the target class
                    for (const node of mutation.addedNodes) {
                        if ($(node).is('[class*="xl:max-w-[48rem]"]') || $(node).find('[class*="xl:max-w-[48rem]"]').length > 0) {
                            updateMaxWidth();
                        }
                    }
                }
            }
        });

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