为主流AI平台优化对话窗口体验:支持ChatGPT、Claude、Kimi、通义千问、智谱GLM、天工、Deepseek、Gemini
当前为
// ==UserScript==
// @name AI Chat Window Enhancer Pro
// @name:zh-CN AI对话窗口增强专业版
// @namespace http://tampermonkey.net/
// @version 0.3.0
// @description Enhanced chat window for various AI platforms: ChatGPT, Claude, Kimi, Tongyi, ChatGLM, Tiangong, Deepseek, Gemini
// @description:zh-CN 为主流AI平台优化对话窗口体验:支持ChatGPT、Claude、Kimi、通义千问、智谱GLM、天工、Deepseek、Gemini
// @author Claude
// @match *://chatgpt.com/*
// @match *://new.oaifree.com/*
// @match *://shared.oaifree.com/*
// @match *://www.aicnn.cn/oaifree/*
// @match *://chat.aicnn.xyz/*
// @match *://plus.aivvm.com/*
// @match *://kimi.moonshot.cn/*
// @match *://tongyi.aliyun.com/qianwen*
// @match *://www.tiangong.cn/*
// @match *://chatglm.cn/*
// @match *://claude.ai/*
// @match *://chat.deepseek.com/*
// @include *://*claude*/*
// @match *://chat.kelaode.ai/*
// @match *://gemini.google.com/*
// @icon data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMjQgMjQiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CiAgPHJlY3Qgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0IiByeD0iNSIgcnk9IjUiIGZpbGw9IiM2YmIiLz4KICA8cGF0aCBkPSJtMTcgMTMuNyA0LTQtNC00bS0xMCA4LTQtNCA0LTRtMTMuOTk5IDMuODI1SDMuMjE1Ii8+CiAgPHBhdGggZD0iTTE5IDE2aC0yLjVhLjk5LjkgMCAwIDAtLjc3NS4zNzVsLTIuOSAzLjY1Yy0uNC41LTEuMTYyLjUtMS41NjMgMGwtMi45MjUtMy42NUEuOTkuOSAwIDAgMCA3LjUgMTZINWMtMS42NjMgMC0zLTEuMzM4LTMtM1Y2YzAtMS42NjIgMS4zNS0zIDMtM2gxNGEzIDMgMCAwIDEgMyAzdjdjMCAxLjY2Mi0xLjM1IDMtMyAzWiIgZmlsbC1vcGFjaXR5PSIuMTYiIHN0cm9rZT0iI0VFRSIgc3Ryb2tlLXdpZHRoPSIxLjUiIHN0cm9rZS1taXRlcmxpbWl0PSIxMCIvPgo8L3N2Zz4K
// @license AGPL-3.0
// @grant GM_addStyle
// @noframes
// ==/UserScript==
(function() {
'use strict';
// 统一的样式配置
const STYLE_CONFIG = {
maxWidth: '95%',
maxViewportWidth: '90vw',
maxHeight: '50vh',
scrollbarWidth: 'thin',
scrollbarThumbColor: '#aaaa',
scrollbarTrackColor: '#1111'
};
// 平台特定的样式定义
const PLATFORM_STYLES = {
kimi: `
div[data-testid] div[data-index] div.MuiBox-root {
max-width: 100% !important;
}
div[class^=mainContent] div.MuiBox-root > div[class^=chatBottom_] {
max-width: calc(100% - 100px);
}
div[class^=mainContent] div[class^=chatInput_] div[class^=inputInner_] div[class^=editor] {
max-height: 360px;
}
#scroll-list div[class^=chatItemBox_].MuiBox-root {
max-width: 100%;
}
div.MuiBox-root[class^=homepage] div[class^=mainContent] div[class^=chatInput_] div[class^=inputInner_] div[class^=editor] {
max-height: 600px;
}
#root > div > div[class*=mainContent] > div[class*=layoutContent] > div.MuiBox-root > div.MuiBox-root[class*=homepage] > div.MuiContainer-root.MuiContainer-maxWidthMd {
max-width: calc(100% - 100px);
}
`,
deepseek: `
div:has(> #latest-context-divider) {
width: ${STYLE_CONFIG.maxWidth} !important;
}
div:has(> div > #chat-input) {
width: ${STYLE_CONFIG.maxWidth} !important;
max-width: ${STYLE_CONFIG.maxViewportWidth};
}
`,
tongyi: `
div[class^=mainContent] div[class^=questionItem--],
div[class^=mainContent] div[class^=answerItem--] {
width: 90% !important;
max-width: ${STYLE_CONFIG.maxViewportWidth};
}
`,
tiangong: `
#app > div > div > main > div.overflow-y-scroll.w-full > div.search-content.relative.flex.w-full.flex-row.justify-center,
#app > div > div > main > div.overflow-y-scroll.w-full > div.search-content.relative.flex.w-full.flex-row.justify-center > label.w-full.cursor-default.select-auto,
label.w-full {
max-width: calc(100% - 100px);
--search-max-width: calc(100% - 100px);
}
:root {
--search-max-width: calc(100% - 100px);
}
`,
chatglm: `
div.conversation-inner.dialogue > div.conversation-list.detail > div.item.conversation-item,
.markdown-body.md-body {
max-width: ${STYLE_CONFIG.maxViewportWidth} !important;
}
`,
gemini: `
#chat-history > infinite-scroller > div,
#app-root > main > side-navigation-v2 > bard-sidenav-container > bard-sidenav-content > div > div > div.content-container > chat-window > div.chat-container.ng-star-inserted > div.bottom-container.response-optimization.ng-star-inserted,
#app-root > main > side-navigation-v2 > bard-sidenav-container > bard-sidenav-content > div > div > div.content-container > chat-window > div.chat-container.ng-star-inserted > div.bottom-container.response-optimization.ng-star-inserted > div.input-area-container.ng-star-inserted {
max-width: calc(100% - 20px);
}
`,
default: `
.xl\\:max-w-\\[48rem\\] {
width: ${STYLE_CONFIG.maxWidth} !important;
max-width: 96% !important;
}
div.mx-auto.md\\:max-w-3xl,
div.mx-auto.flex {
max-width: calc(100% - 10px);
}
pre > div.rounded-md > div.overflow-y-auto,
.code-block__code {
max-height: ${STYLE_CONFIG.maxHeight};
overflow: auto;
scrollbar-width: ${STYLE_CONFIG.scrollbarWidth};
scrollbar-color: ${STYLE_CONFIG.scrollbarThumbColor} ${STYLE_CONFIG.scrollbarTrackColor};
}
.ProseMirror.break-words.ProseMirror-focused {
max-width: 100%;
}
body > div.flex.min-h-screen.w-full div.flex.flex-col div.flex.gap-2 div.mt-1.max-h-96.w-full.overflow-y-auto.break-words > div.ProseMirror.break-words {
max-width: 90%;
}
main > div.composer-parent article > div.text-base > div.mx-auto,
main article > div.text-base > div.mx-auto {
max-width: ${STYLE_CONFIG.maxWidth};
}
body > div.flex.min-h-screen.w-full > div > main > div.top-5.z-10.mx-auto.w-full.max-w-2xl.md,
body > div.flex.min-h-screen.w-full > div > main > div.mx-auto.w-full.max-w-2xl.px-1.md {
max-width: 100%;
}
body > div.flex.min-h-screen.w-full > div > main.max-w-7xl {
max-width: 90rem;
}
`
};
// 检测当前平台并应用相应样式
function applyPlatformStyles() {
const host = window.location.hostname;
let styleToApply = '';
if (host.includes('kimi.moonshot.cn')) {
styleToApply = PLATFORM_STYLES.kimi;
} else if (host.includes('chat.deepseek.com')) {
styleToApply = PLATFORM_STYLES.deepseek;
} else if (host.includes('tongyi.aliyun.com')) {
styleToApply = PLATFORM_STYLES.tongyi;
} else if (host.includes('tiangong.cn')) {
styleToApply = PLATFORM_STYLES.tiangong;
} else if (host.includes('chatglm.cn')) {
styleToApply = PLATFORM_STYLES.chatglm;
} else if (host.includes('gemini.google.com')) {
styleToApply = PLATFORM_STYLES.gemini;
} else {
styleToApply = PLATFORM_STYLES.default;
}
GM_addStyle(styleToApply);
}
// 优化链接处理
function enhanceLinks(retryCount = 0) {
const maxRetries = 10;
const links = document.querySelectorAll('div[data-message-id] a[rel="noreferrer"]');
if (links.length === 0 && retryCount < maxRetries) {
setTimeout(() => enhanceLinks(retryCount + 1), 1000);
return;
}
links.forEach(link => {
if (!link.href) {
link.href = link.innerText.trim();
link.target = "_blank";
link.rel = "noopener noreferrer";
}
});
// 持续监听新增的链接
setTimeout(() => enhanceLinks(0), 2000);
}
// 初始化
function init() {
applyPlatformStyles();
enhanceLinks();
}
// 启动脚本
init();
})();