Claude Content Max-Width

adjust Claude Content Max-Width

Verzia zo dňa 13.07.2023. Pozri najnovšiu verziu.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey, Greasemonkey alebo Violentmonkey.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie, ako napríklad Tampermonkey.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey, % alebo Violentmonkey.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey alebo Userscripts.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie, ako napríklad Tampermonkey.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie správcu používateľských skriptov.

(Už mám správcu používateľských skriptov, nechajte ma ho nainštalovať!)

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

(Už mám správcu používateľských štýlov, nechajte ma ho nainštalovať!)

// ==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 不符合预期");
    }
})();