← 全部示例

JavaScript 阅读与专注 web.telegram.org

Telegram:折叠引用回复

将引用回复预览缩短为一行,点击后展开完整引用。

可复制的代码

// Shorten quoted reply previews so long quotes do not crowd messages
function trimQuotes() {
  const quotes = document.querySelectorAll('.bubbles .bubble .reply, .Message .EmbeddedMessage');
  quotes.forEach(function (q) {
    if (q.dataset.jzTrim) { return; }
    q.dataset.jzTrim = '1';
    q.style.maxHeight = '38px';
    q.style.overflow = 'hidden';
    q.style.cursor = 'pointer';
    q.title = 'Click to expand the quote';
    q.addEventListener('click', function () {
      q.style.maxHeight = q.style.maxHeight === 'none' ? '38px' : 'none';
    });
  });
}
trimQuotes();
const obs = new MutationObserver(trimQuotes);
obs.observe(document.documentElement, { childList: true, subtree: true });

如何使用此示例

  1. 用上方按钮复制代码。
  2. 安装 JustZix(2 分钟),在目标页面打开扩展。
  3. 添加一条匹配该页面的新规则。
  4. 将代码粘贴到规则的 JavaScript 面板并保存 — 每次访问页面时都会运行。

为此示例评分

暂无评分 — 成为第一个。

此示例有效吗?

没有可粘贴的地方,代码片段毫无用处。

JustZix 安装只需 2 分钟,并在每个匹配的页面上运行你的代码。无需账户、无需付费。

免费下载 查看应用场景