ChatGPT WideScreen

Make the ChatGPT conversation window wider.

目前为 2023-08-30 提交的版本。查看 最新版本

// ==UserScript==
// @name         ChatGPT WideScreen
// @namespace    http://tampermonkey.net/
// @version      0.4
// @description  Make the ChatGPT conversation window wider.
// @author       Xiong Yu
// @match        https://chat.openai.com/*
// @grant        none
// @home-url     https://gf.qytechs.cn/zh-CN/scripts/473238
// ==/UserScript==

(function() {
    'use strict';

    function updateStyle(element) {
        console.log('Node:', element);
        element.style.maxWidth = '95%';
    }

    var node1 = '#__next > div.overflow-hidden.w-full.h-full.relative.flex.z-0 > div.relative.flex.h-full.max-w-full.flex-1.overflow-hidden > div > main > div > div.flex-1.overflow-hidden > div > div > div > div > div';
    var node2 = '#__next > div.overflow-hidden.w-full.h-full.relative.flex.z-0 > div.relative.flex.h-full.max-w-full.flex-1.overflow-hidden > div > main > div > div.flex-1.overflow-hidden > div > div > div > div > div > div'

    const observer = new MutationObserver(mutationsList => {
        mutationsList.forEach(mutation => {
            if (mutation.addedNodes.length > 0) {
                // 循环处理每个新增的节点
                mutation.addedNodes.forEach(addedNode => {
                    if (addedNode.nodeType === Node.ELEMENT_NODE) {
                        // 检查新增节点是否匹配目标选择器
                        if (addedNode.matches(node1) || addedNode.matches(node2)) {
                            updateStyle(addedNode);
                        } else {
                            // 如果新增节点包含目标选择器的子节点,则更新子节点的样式
                            const matchingChildren1 = addedNode.querySelectorAll(node1);
                            matchingChildren1.forEach(updateStyle);
                            const matchingChildren2 = addedNode.querySelectorAll(node2);
                            matchingChildren2.forEach(updateStyle);
                        }
                    }
                });
            }
        });
    });

    observer.observe(document, { childList: true, subtree: true });
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址