Skip to content

Instantly share code, notes, and snippets.

@xinatcg
Last active February 20, 2026 03:52
Show Gist options
  • Select an option

  • Save xinatcg/3f8dcd654605be6c88addd48b31ca26c to your computer and use it in GitHub Desktop.

Select an option

Save xinatcg/3f8dcd654605be6c88addd48b31ca26c to your computer and use it in GitHub Desktop.
Telegram Web K 真正全屏加宽 v6.4
// ==UserScript==
// @name Telegram Web K 全屏加宽 v6.4
// @namespace http://tampermonkey.net/
// @version 6.4
// @description 解决绿色气泡文字截断,强制内部内容居右显示
// @author Gemini
// @match https://web.telegram.org/k/*
// @grant GM_addStyle
// @run-at document-start
// ==/UserScript==
(function() {
'use strict';
const css = `
/* 1. 全局变量覆盖 */
:root, body, #page-chats, .chat {
--bubbles-inner-max-width: 95% !important;
--bubbles-max-width: 95% !important;
--chat-content-width: 100% !important;
}
/* 2. 轨道容器:增加 Padding 确保气泡不会撞墙 */
.bubbles-inner {
max-width: 95% !important;
width: 95% !important;
margin: 0 auto !important;
padding-left: 30px !important;
padding-right: 30px !important;
box-sizing: border-box !important;
}
/* 3. 气泡主体:锁定宽度并修复偏移导致的截断 */
.bubble {
max-width: 88% !important;
width: auto !important;
min-width: 200px;
box-sizing: border-box !important;
overflow: visible !important; /* 允许内部元素完整显示 */
transform: none !important; /* 禁用可能导致截断的位移 */
position: relative !important;
left: auto !important;
right: auto !important;
}
/* 4. 修复对齐逻辑 */
.bubble.is-out {
margin-left: auto !important;
margin-right: 0 !important;
display: block !important;
text-align: left !important; /* 文字本身保持左对齐,但容器在右边 */
}
.bubble.is-in {
margin-right: auto !important;
margin-left: 0 !important;
}
/* 5. 核心:修复内部内容容器的截断 */
/* K版绿色气泡内容有时会有 transform: translateX 或固定宽度 */
.bubble-content-wrapper,
.bubble-content,
.message {
max-width: 100% !important;
width: 100% !important;
transform: none !important; /* 彻底重置位移 */
padding: 8px 12px !important;
box-sizing: border-box !important;
}
/* 6. 修复代码块和 URL 预览溢出 */
pre.code, .webpage, .webpage-quote {
max-width: 100% !important;
width: 100% !important;
box-sizing: border-box !important;
margin-right: 0 !important;
margin-left: 0 !important;
}
.code-content, pre.code code {
white-space: pre-wrap !important;
word-break: break-all !important;
}
/* 7. 移除全局滚动条 */
html, body {
overflow-x: hidden !important;
}
`;
if (typeof GM_addStyle !== "undefined") {
GM_addStyle(css);
} else {
const style = document.createElement("style");
style.textContent = css;
document.documentElement.appendChild(style);
}
// 动态拦截修正
const fixElement = (el) => {
el.style.setProperty('transform', 'none', 'important');
el.style.setProperty('max-width', '100%', 'important');
el.style.setProperty('box-sizing', 'border-box', 'important');
};
const observer = new MutationObserver(() => {
// 修正所有气泡及其内部核心文字块
document.querySelectorAll('.bubble, .bubble-content-wrapper, .message').forEach(fixElement);
});
observer.observe(document.documentElement, { childList: true, subtree: true });
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment