ChatGPT WideScreen

Make the ChatGPT conversation window wider.

目前為 2023-08-18 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

(function() {
    'use strict';

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

    var node = '#__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';

    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(node)) {
                            updateStyle(addedNode);
                        } else {
                            // 如果新增节点包含目标选择器的子节点,则更新子节点的样式
                            const matchingChildren = addedNode.querySelectorAll(node);
                            matchingChildren.forEach(updateStyle);
                        }
                    }
                });
            }
        });
    });

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