Claude Content Max-Width

adjust Claude Content Max-Width

目前為 2023-07-13 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Claude Content Max-Width
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  adjust Claude Content Max-Width
// @author       Shawn-wxn
// @match        https://claude.ai/*
// @match        https://poe.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=claude.ai
// @grant        none
// @license           GPL-2.0-only
// ==/UserScript==

(function() {
    // 获取当前的 URL
    var currentURL = window.location.href;

    // 根据当前 URL 进行 if-else 逻辑判断
    if (currentURL.includes("poe.com")) {
        var mainSectionDiv = document.querySelector("div[class*='PageWithSidebarLayout_mainSection']");
        var classNames = mainSectionDiv.classList;
        var mainSectionDivClass = null;
        for (var i = 0; i < classNames.length; i++) {
            var className = classNames[i];
            if (className.indexOf('PageWithSidebarLayout_mainSection') !== -1) {
                mainSectionDivClass = className;
                break;
            }
        }
        if (!mainSectionDivClass) {
            throw new Error("not found mainSectionDivClass");
        }


        var botMessageBubble = document.querySelector("div[class*='Message_botMessageBubble']");
        var classNames1 = botMessageBubble.classList;
        var botMessageBubbleClass = null;
        for (var i = 0; i < classNames1.length; i++) {
            var className = classNames1[i];
            if (className.indexOf('Message_botMessageBubble') !== -1) {
                botMessageBubbleClass = className;
                break;
            }
        }
        if (!botMessageBubbleClass) {
            throw new Error("not found botMessageBubbleClass");
        }


        var humanMessageBubble = document.querySelector("div[class*='Message_humanMessageBubble']");
        var classNames2 = humanMessageBubble.classList;
        var humanMessageBubbleClass = null;
        for (var i = 0; i < classNames2.length; i++) {
            var className = classNames2[i];
            if (className.indexOf('Message_humanMessageBubble') !== -1) {
                humanMessageBubbleClass = className;
                break;
            }
        }
        if (!humanMessageBubbleClass) {
            throw new Error("not found humanMessageBubbleClass");
        }


        var styleTag = document.createElement('style');

        // 将 CSS 样式添加到<style>标签中
        var cssStyles = `
            /* 在这里添加您的 CSS 样式 */
            .${mainSectionDivClass} {
              max-width: ${Math.floor(window.innerWidth * 0.75)}px;
            }
            .${botMessageBubbleClass},.${humanMessageBubbleClass} {
              max-width: ${Math.floor(window.innerWidth * 0.66)}ch;
            }
            `;

        // 设置<style>标签的内容为 CSS 样式
        styleTag.innerHTML = cssStyles;

        // 将<style>标签添加到<head>标签中
        document.head.appendChild(styleTag);
    } else if (currentURL.includes("claude.ai")) {
        // 创建一个<style>标签
        var styleTag = document.createElement('style');

        // 将 CSS 样式添加到<style>标签中
        var cssStyles = `
            /* 在这里添加您的 CSS 样式 */
            .max-w-3xl {
              max-width: ${Math.floor(window.innerWidth * 0.05)}rem;
            }
            .max-w-\\[75ch\\] {
              max-width: ${Math.floor(window.innerWidth * 0.1)}ch;
            }
        `;

        // 设置<style>标签的内容为 CSS 样式
        styleTag.innerHTML = cssStyles;

        // 将<style>标签添加到<head>标签中
        document.head.appendChild(styleTag);
    } else {
        // 如果以上条件都不满足
        console.log("当前 URL 不符合预期");
    }
})();

QingJ © 2025

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