<!DOCTYPE html><html lang="zh" data-theme="dark"><head><meta charset="utf-8"><meta name="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1"><title>吃免费的饭,骂做饭的厨子 · Cytrogen 的个人博客</title><meta name="description" content="我喜欢阅读漫画,尤其是日本漫画。不过近期我关注的一个作品的粉丝群因为一件极为离谱的事情解散了:毫无用途的群管理无端辱骂「烤肉 man」,并表示不缺你一个汉化的。 如果把未翻译的内容视作「生肉」,那么被翻译的自然就是「烤肉」、进行「烤肉」行为的就是「烤肉 man」。免费为大家汉化内容的「烤肉 man」们被读者赶跑的事情,仿佛并不罕见。但是,为什么人们那么乐意攻击主动贡献者?"><link rel="icon" href="../favicon.png"><link rel="canonical" href="https://cytrogen.icu/posts/a2a2.html"><link rel="webmention" href="https://webmention.io/cytrogen.icu/webmention"><link rel="me" href="https://m.otter.homes/@Cytrogen"><link rel="me" href="https://github.com/cytrogen"><meta name="fediverse:creator" content="@Cytrogen@m.otter.homes"><link rel="preload" href="../fonts/opensans-regular-latin.woff2" as="font" type="font/woff2" crossorigin="anonymous"><style>@font-face {
font-family: 'Open Sans';
src: url('../fonts/opensans-regular-latin.woff2') format('woff2');
font-weight: 400;
font-style: normal;
font-display: swap;
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
size-adjust: 107%;
ascent-override: 97%;
descent-override: 25%;
line-gap-override: 0%;
}
</style><script>(function() {
try {
// 优先级:用户选择 > 系统偏好 > 默认浅色
const saved = localStorage.getItem('theme');
const theme = saved ||
(window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light');
document.documentElement.setAttribute('data-theme', theme);
document.documentElement.style.colorScheme = theme;
} catch (error) {
// 失败时使用默认主题,不阻塞渲染
document.documentElement.setAttribute('data-theme', 'light');
}
})();
</script><link rel="stylesheet" href="../css/ares.css"><script data-netlify-skip-bundle="true">(function() {
document.addEventListener('DOMContentLoaded', function() {
const theme = document.documentElement.getAttribute('data-theme');
const pageWrapper = document.getElementById('page-wrapper');
if (pageWrapper && theme) {
pageWrapper.setAttribute('data-theme', theme);
}
});
})();
</script><!-- hexo injector head_end start -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/hexo-math@4.0.0/dist/style.css">
<!-- hexo injector head_end end --><meta name="generator" content="Hexo 8.1.1"><link rel="alternate" href="atom.xml" title="Cytrogen 的个人博客" type="application/atom+xml">
</head><body><div id="page-wrapper"><a class="skip-link" href="#main-content">跳到主要内容</a><div class="wrap"><header><a class="logo-link" href="../index.html"><img src="../favicon.png" alt="logo"></a><div class="h-card visually-hidden"><img class="u-photo" src="https://cytrogen.icu/favicon.png" alt="Cytrogen"><a class="p-name u-url u-uid" href="https://cytrogen.icu">Cytrogen</a><p class="p-note">Cytrogen 的个人博客,Cytrogen's Blog</p><a class="u-url" rel="me noopener" target="_blank" href="https://m.otter.homes/@Cytrogen">Mastodon</a><a class="u-url" rel="me noopener" target="_blank" href="https://github.com/cytrogen">GitHub</a></div><nav class="site-nav"><div class="nav-main"><div class="nav-primary"><ul class="nav-list hidden-mobile"><li class="nav-item"><a class="nav-link" href="../index.html">首页</a></li></ul><div class="nav-tools"><div class="language-menu"><button class="language-toggle" type="button"><svg class="icon icon-globe" width="16" height="16" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true" focusable="false"><path d="M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8zm7.5-6.923c-.67.204-1.335.82-1.887 1.855A7.97 7.97 0 0 0 5.145 4H7.5V1.077zM4.09 4a9.267 9.267 0 0 1 .64-1.539 6.7 6.7 0 0 1 .597-.933A7.025 7.025 0 0 0 2.255 4H4.09zm-.582 3.5c.03-.877.138-1.718.312-2.5H1.674a6.958 6.958 0 0 0-.656 2.5h2.49zM4.847 5a12.5 12.5 0 0 0-.338 2.5H7.5V5H4.847zM8.5 5v2.5h2.99a12.495 12.495 0 0 0-.337-2.5H8.5zM4.51 8.5a12.5 12.5 0 0 0 .337 2.5H7.5V8.5H4.51zm3.99 0V11h2.653c.187-.765.306-1.608.338-2.5H8.5zM5.145 12c.138.386.295.744.468 1.068.552 1.035 1.218 1.65 1.887 1.855V12H5.145zm.182 2.472a6.696 6.696 0 0 1-.597-.933A9.268 9.268 0 0 1 4.09 12H2.255a7.024 7.024 0 0 0 3.072 2.472zM3.82 11a13.652 13.652 0 0 1-.312-2.5h-2.49c.062.89.291 1.733.656 2.5H3.82zm6.853 3.472A7.024 7.024 0 0 0 13.745 12H11.91a9.27 9.27 0 0 1-.64 1.539 6.688 6.688 0 0 1-.597.933zM8.5 12v2.923c.67-.204 1.335-.82 1.887-1.855A7.97 7.97 0 0 0 10.855 12H8.5zm3.68-1h2.146c.365-.767.594-1.61.656-2.5h-2.49a13.65 13.65 0 0 1-.312 2.5zm2.802-3.5a6.959 6.959 0 0 0-.656-2.5H12.18c.174.782.282 1.623.312 2.5h2.49zM11.27 2.461c.247.464.462.98.64 1.539h1.835a7.024 7.024 0 0 0-3.072-2.472c.218.284.418.598.597.933zM10.855 4a7.966 7.966 0 0 0-.468-1.068C9.835 1.897 9.17 1.282 8.5 1.077V4h2.355z"></path></svg><span>中文</span></button><div class="language-dropdown"></div></div></div><div class="nav-controls"><div class="more-menu hidden-mobile"><button class="more-toggle" type="button"><span>更多</span><svg class="icon icon-chevron-down" width="12" height="12" viewBox="0 0 12 12" fill="currentColor" aria-hidden="true" focusable="false"><path d="M6 8.825c-.2 0-.4-.1-.5-.2l-3.3-3.3c-.3-.3-.3-.8 0-1.1s.8-.3 1.1 0l2.7 2.7 2.7-2.7c.3-.3.8-.3 1.1 0s.3.8 0 1.1l-3.3 3.3c-.1.1-.3.2-.5.2z"></path></svg></button><div class="more-dropdown"><ul class="dropdown-list"><li class="dropdown-item"><a class="nav-link" href="../archives/index.html">归档</a></li><li class="dropdown-item"><a class="nav-link" href="../categories/index.html">分类</a></li><li class="dropdown-item"><a class="nav-link" href="../tags/index.html">标签</a></li><li class="dropdown-item"><a class="nav-link" href="../about/index.html">关于</a></li><li class="dropdown-item"><a class="nav-link" href="../sitemap/index.html">领地地图</a></li></ul></div></div><div class="theme-switcher"><button class="theme-toggle" type="button" role="switch" aria-pressed="false" aria-label="切换主题"><div class="theme-icon moon-icon"><svg class="icon icon-moon" width="16" height="16" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true" focusable="false"><path d="M6 .278a.768.768 0 0 1 .08.858 7.208 7.208 0 0 0-.878 3.46c0 4.021 3.278 7.277 7.318 7.277.527 0 1.04-.055 1.533-.16a.787.787 0 0 1 .81.316.733.733 0 0 1-.031.893A8.349 8.349 0 0 1 8.344 16C3.734 16 0 12.286 0 7.71 0 4.266 2.114 1.312 5.124.06A.752.752 0 0 1 6 .278z"></path></svg></div><div class="theme-icon sun-icon"><svg class="icon icon-sun" width="16" height="16" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true" focusable="false"><path d="M8 11a3 3 0 1 1 0-6 3 3 0 0 1 0 6zm0 1a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM8 0a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 0zm0 13a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 13zm8-5a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1 0-1h2a.5.5 0 0 1 .5.5zM3 8a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1 0-1h2A.5.5 0 0 1 3 8zm10.657-5.657a.5.5 0 0 1 0 .707l-1.414 1.415a.5.5 0 1 1-.707-.708l1.414-1.414a.5.5 0 0 1 .707 0zm-9.193 9.193a.5.5 0 0 1 0 .707L3.05 13.657a.5.5 0 0 1-.707-.707l1.414-1.414a.5.5 0 0 1 .707 0zm9.193 2.121a.5.5 0 0 1-.707 0l-1.414-1.414a.5.5 0 0 1 .707-.707l1.414 1.414a.5.5 0 0 1 0 .707zM4.464 4.465a.5.5 0 0 1-.707 0L2.343 3.05a.5.5 0 1 1 .707-.707l1.414 1.414a.5.5 0 0 1 0 .708z"></path></svg></div></button></div><details class="mobile-menu-details hidden-desktop"><summary class="hamburger-menu" aria-label="nav.menu"><svg class="icon icon-bars" width="16" height="16" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true" focusable="false"><path d="M2.5 12a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5z"></path></svg><span class="menu-text">nav.menu</span></summary><div class="mobile-menu-dropdown"><ul class="mobile-nav-list"><li class="mobile-nav-item"><a class="mobile-nav-link" href="../index.html">首页</a></li><li class="mobile-nav-item"><a class="mobile-nav-link" href="../archives/index.html">归档</a></li><li class="mobile-nav-item"><a class="mobile-nav-link" href="../categories/index.html">分类</a></li><li class="mobile-nav-item"><a class="mobile-nav-link" href="../tags/index.html">标签</a></li><li class="mobile-nav-item"><a class="mobile-nav-link" href="../about/index.html">关于</a></li><li class="mobile-nav-item"><a class="mobile-nav-link" href="../sitemap/index.html">领地地图</a></li></ul></div></details></div></div></div></nav></header><main class="container" id="main-content" tabindex="-1"><div class="post"><article class="post-block h-entry"><div class="post-meta p-author h-card visually-hidden"><img class="author-avatar u-photo" src="../favicon.png" alt="Cytrogen"><span class="p-name">Cytrogen</span><a class="u-url" href="https://cytrogen.icu">https://cytrogen.icu</a></div><a class="post-permalink u-url u-uid visually-hidden" href="https://cytrogen.icu/posts/a2a2.html">永久链接</a><div class="p-summary visually-hidden"><p>我喜欢阅读漫画,尤其是日本漫画。不过近期我关注的一个作品的粉丝群因为一件极为离谱的事情解散了:毫无用途的群管理无端辱骂「烤肉 man」,并表示不缺你一个汉化的。</p>
<p>如果把未翻译的内容视作「生肉」,那么被翻译的自然就是「烤肉」、进行「烤肉」行为的就是「烤肉 man」。免费为大家汉化内容的「烤肉 man」们被读者赶跑的事情,仿佛并不罕见。但是,<strong>为什么人们那么乐意攻击主动贡献者?</strong></p></div><div class="visually-hidden"><a class="p-category" href="../categories/%E4%B8%AA%E4%BA%BA%E9%9A%8F%E6%83%B3/">个人随想</a><a class="p-category" href="../tags/%E4%BA%92%E8%81%94%E7%BD%91/">互联网</a><a class="p-category" href="../tags/%E5%BF%83%E7%90%86%E5%AD%A6/">心理学</a><a class="p-category" href="../tags/%E7%A4%BE%E4%BC%9A%E5%AD%A6/">社会学</a></div><h1 class="post-title p-name">吃免费的饭,骂做饭的厨子</h1><div class="post-info"><time class="post-date dt-published" datetime="2025-10-22T14:10:00.000Z">10/22/2025</time><time class="dt-updated visually-hidden" datetime="2026-02-09T17:16:55.213Z"></time></div><div class="post-content e-content"><html><head></head><body><p>我喜欢阅读漫画,尤其是日本漫画。不过近期我关注的一个作品的粉丝群因为一件极为离谱的事情解散了:毫无用途的群管理无端辱骂「烤肉 man」,并表示不缺你一个汉化的。</p>
<p>如果把未翻译的内容视作「生肉」,那么被翻译的自然就是「烤肉」、进行「烤肉」行为的就是「烤肉 man」。免费为大家汉化内容的「烤肉 man」们被读者赶跑的事情,仿佛并不罕见。但是,<strong>为什么人们那么乐意攻击主动贡献者?</strong></p>
<span id="more"></span>
<h2 id="搭便车问题"><a class="markdownIt-Anchor" href="#搭便车问题"></a> 搭便车问题</h2>
<p>经济学和心理学中有一个经典概念叫做「搭便车问题」:当有人免费提供公共物品时,其他人会倾向于享受成果而不付出。这本身无可厚非,但问题在于,搭便车者内心深处往往对自己的不劳而获感到不安。这种不安来自两个层面:</p>
<ol>
<li>
<p>对「成为冤大头」的恐惧。</p>
<p>社会心理学中有一个概念叫做「社会性懈怠」,指的是人们担心自己付出太多而被其他成员占便宜,因而减少努力的现象。当我们接受别人的免费付出时,内心会产生一种微妙的自我质疑:<em>我是不是那个被利用的二傻子?对方是不是在用恩惠控制我?</em></p>
<p>这种对「被当傻子」的厌恶会严重影响人们的决策。研究表明,即使在没有任何社会后果的实验环境中,人们也会因为害怕「被占便宜」而拒绝合作,哪怕合作明显对双方都有利。</p>
</li>
<li>
<p>不平等关系带来的心理负担。</p>
<p>当一个人持续接受他人的帮助而无法回报时,会产生一种权力失衡。贡献者拥有「给予」的权力,而接受者则处于「被施恩」的被动位置。这种不对等会让接受者感到:</p>
<ul>
<li>自尊受损:<em>我为什么需要依赖别人?</em></li>
<li>自我贬低:<em>我是不是不如对方有能力?</em></li>
<li>失去控制感:<em>我欠了人情,是否意味着我要听从对方?</em></li>
</ul>
<p>当人们无法回报恩惠时,最容易产生的情绪其实不是感激,而是 <strong>怨恨</strong>。</p>
</li>
</ol>
<p>当接受者内心产生「我是搭便车者」的羞耻感时,人类的防御机制会启动一个危险的转换:将内在的羞耻投射为对外的愤怒。这个转换过程遵循一个典型的心理链条:</p>
<ol>
<li><em>我不得不接受他的汉化。</em></li>
<li><em>他让我觉得自己无能。</em></li>
<li><em>我有权利要求他做得更好。</em></li>
</ol>
<p>一旦进入第三阶段,搭便车者会开始合理化自己的攻击行为。这种转变涉及多个心理机制:</p>
<ul>
<li>通过批评别人、要求更高的标准,将原本的不道德行为(不出力却享受)重新定义为道德的行为(虽然我没出力,但我是在监督质量、要求进步)。</li>
<li>将自己的不贡献归因于外部环境,却将贡献者的成果不足归因于内在能力不足。</li>
<li>将「互惠」理解为「既然我享受了你提供的好处,我应该给你『反馈』」。但这个反馈不是正面的回报,而是「建设性的批评」和「更高的要求」。通过批评来「贡献」,巧妙地将自己的不出力转变为一种「参与」形式。</li>
<li>内心深处清楚自己没有付出却享受了利益,这造成了认知失调。为了消除这种不适感,他们采取最简单的策略:通过批评别人来缓解自己的内疚感。</li>
</ul>
<p>那位群管理能说出「想走就走,又不缺你一个烤肉的」这种很离谱的话时,本质上是在试图夺回被贡献者「威胁」的权力。而要重新确立「我也有价值」的自我认知,最简单且粗暴的方式便是贬低和攻击那些威胁其社会地位的人。</p>
<h2 id="网络环境"><a class="markdownIt-Anchor" href="#网络环境"></a> 网络环境</h2>
<p>这些攻击往往发生在网络空间。人们在网络中感觉解放,变得更加肆无忌惮,并且更倾向于无视各种社会约束或社交禁忌。具体来说,网络环境造成了心理学家约翰・苏勒所提出的六个关键的心理转变:</p>
<ul>
<li><strong>你不知道我是谁</strong>:匿名性给了用户一种心理安全感。当真实身份无法被识别时,人们感到可以自由地说出平时会让自己尴尬的话,甚至做出被视为反社会或有害的行为。</li>
<li><strong>你看不到我</strong>:缺乏对方的真实反馈。用户无法观察到对方的表情变化、眼神反应或语气变化,这削弱了人们对他人感受的同理心。</li>
<li><strong>待会儿见</strong>:网络交流的非实时性让人可以说完就走。用户可以发布情绪化的言论,然后简单地退出或删除,无需为此承担实时的社会后果。</li>
<li><strong>这是我脑中的世界</strong>:在缺乏现实交互要素的情况下,人们根据接收到的消息自行想象对方的样貌、声音和性格。这种想象的自由度高,容易投射个人的欲望和需求,甚至可能将对方想象成自己讨厌的人。</li>
<li><strong>这只是场游戏</strong>:将网络空间视为一个游戏场所,在这里日常生活中的道德规范「不适用」。用户能够清晰地区分网络角色与现实角色,迅速切换于各种身份之间。</li>
<li><strong>你的规则在这儿不管用</strong>:现实中的社会地位、职业身份、年龄都在网络上无效。匿名性使得权力结构扁平化,这给了那些在现实中处于低权力地位的人一种 "翻身" 的幻觉。</li>
</ul>
<p>除了这些去抑制效应,去个性化理论也进一步解释了为何攻击在群体中更加激烈。去个性化指的是在群体中,个体失去了对自己行为的责任感,使自身自我控制系统的作用减弱甚至丧失。这包含两个核心要素:</p>
<ul>
<li>当个体隐匿在群体中、无法被辨认时,会觉得自己是匿名者而放纵。他们认为即使做了坏事也不会被识别出来,因此可以毫无顾忌地违反社会规范。</li>
<li>在群体中,个人觉得自己对集体行为不负责任。群体活动的责任被分散在每个成员身上,没有任何一个具体成员需要承担谴责。群体规模越大,这种效应越明显。</li>
</ul>
<p>在线社群会随着时间推移变得越来越有毒。我认为无论是谁只要有加入过 QQ 群或者类似社群的,都能发觉到这个事实。这里的「有毒」指代的是三种暴力模式:</p>
<ol>
<li>施虐式娱乐:以攻击他人为乐。</li>
<li>派系战争:不同小团体争夺主导权。</li>
<li>私刑正义:成员自发「惩罚」违规者。</li>
</ol>
<p>这是因为网络社群中存在着群体极化现象。当搭便车者集聚在一起时,他们对贡献者的批评不会减弱,而是通过群体动力学被不断放大。社群成员会为了获得身份认同感和心理安全感,去迎合群体的主流意见。而为了获得更多支持,个体会有意地将自己的立场表现得比其他人更加坚定。这会导致群体内的平均立场不断向极端方向移动。当个体采取更为激烈的言论或行为攻击异见者,对贡献者的攻击就不再是个人的心理补偿,而是成为了群体的集体行为,获得了群体的强化和鼓励。</p>
<p>旁观者效应在网络中也适用,但有所不同。在现实中,当有多个旁观者时,人们帮助他人的可能性反而降低。然而在网络上,这个效应表现为管理的缺失 —— 没有人对群体暴力进行干预。在网络群体中,管理员可能是缺席的或被搭便车者控制的,理性的声音往往被淹没在情绪化的声音中,干预者也有可能变成被攻击的对象。如果说话的人都是指责贡献者的搭便车者,对贡献者的攻击就会看起来像是「群体的共识」,尽管实际上只是少数人在制造噪音。</p>
<h2 id="预防"><a class="markdownIt-Anchor" href="#预防"></a> 预防</h2>
<p>如何预防、如何面对这种事情呢?</p>
<p>如果你是贡献者,请明确自己的贡献范围,不要让免费变成无限索取的接口;攻击往往不是因为你做得不好,而是因为你的存在让某些人感到威胁。这不是你的问题;如果一个社群持续不尊重贡献者,离开是最健康的选择。</p>
<p>如果你是接受者,请时刻提醒自己这是他人的善意,不是你应得的;哪怕是小小的回馈,都能平衡关系中的权力失衡,例如感谢、力所能及的帮助;当你开始觉得「他应该为我做更多」时,停下来想一想:<em>到底是谁欠谁</em>?</p>
<p>如果你是社群管理者,请制定清晰的社群规则,保护贡献者不受攻击;当看到对贡献者的攻击时,及时介入而不是沉默;公开肯定贡献者的价值,不要让「理所当然」成为常态。</p>
<p>一个健康、可持续的社群文化,是一个既感激贡献者,也欢迎搭便车者,但绝不容忍攻击的社群。</p>
</body></html></div></article></div></main><footer><div class="paginator"><a class="prev" href="e0dc.html">上一篇</a><a class="next" href="1de.html">下一篇</a></div><!-- Webmention 显示区域--><div class="webmention-section webmention-empty" data-page-url="posts/a2a2.html" data-full-url="https://cytrogen.icu/posts/a2a2.html" data-mode="static">
<h3 class="webmention-title">Webmentions (<span class="webmention-count">0</span>)</h3>
<div class="webmention-list"></div>
<span>暂无 Webmentions</span>
</div><div class="copyright"><p class="footer-links"><a href="../friends/index.html">友链</a><span class="footer-separator"> ·</span><a href="../links/index.html">邻邦</a><span class="footer-separator"> ·</span><a href="../contact/index.html">联络</a><span class="footer-separator"> ·</span><a href="../colophon/index.html">营造记</a><span class="footer-separator"> ·</span><a href="../atom.xml">RSS订阅</a></p><p>© 2025 - 2026 <a href="https://cytrogen.icu">Cytrogen</a>, powered by <a href="https://hexo.io/" target="_blank">Hexo</a> and <a href="https://github.com/cytrogen/hexo-theme-ares" target="_blank">hexo-theme-ares</a>.</p><p><a href="https://blogscn.fun" target="_blank" rel="noopener">BLOGS·CN</a></p></div></footer></div></div><a class="back-to-top" href="#top" aria-label="返回顶部"><svg width="20" height="20" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true"><path d="M3.293 9.707a1 1 0 010-1.414L9.586 2a2 2 0 012.828 0l6.293 6.293a1 1 0 01-1.414 1.414L11 3.414V17a1 1 0 11-2 0V3.414L2.707 9.707a1 1 0 01-1.414 0z"></path></svg></a><script>document.addEventListener('DOMContentLoaded', function() {
const codeBlocks = document.querySelectorAll('figure.highlight');
codeBlocks.forEach(block => {
let caption = block.querySelector('figcaption');
if (!caption) {
caption = document.createElement('figcaption');
block.insertBefore(caption, block.firstChild);
}
const info = document.createElement('div');
info.className = 'info';
const filename = caption.querySelector('span');
if (filename) {
filename.className = 'filename';
info.appendChild(filename);
}
const lang = block.className.split(' ')[1];
if (lang) {
const langSpan = document.createElement('span');
langSpan.className = 'lang-name';
langSpan.textContent = lang;
info.appendChild(langSpan);
}
const sourceLink = caption.querySelector('a');
if (sourceLink) {
sourceLink.className = 'source-link';
info.appendChild(sourceLink);
}
const actions = document.createElement('div');
actions.className = 'actions';
const codeHeight = block.scrollHeight;
const threshold = 300;
if (codeHeight > threshold) {
block.classList.add('folded');
const toggleBtn = document.createElement('button');
toggleBtn.textContent = '展开';
toggleBtn.addEventListener('click', () => {
block.classList.toggle('folded');
toggleBtn.textContent = block.classList.contains('folded') ? '展开' : '折叠';
});
actions.appendChild(toggleBtn);
}
const copyBtn = document.createElement('button');
copyBtn.textContent = '复制';
copyBtn.addEventListener('click', async () => {
const codeLines = block.querySelectorAll('.code .line');
const code = Array.from(codeLines)
.map(line => line.textContent)
.join('\n')
.replace(/\n\n/g, '\n');
try {
await navigator.clipboard.writeText(code);
copyBtn.textContent = '已复制';
copyBtn.classList.add('copied');
setTimeout(() => {
copyBtn.textContent = '复制';
copyBtn.classList.remove('copied');
}, 3000);
} catch (err) {
console.error('复制失败:', err);
copyBtn.textContent = '复制失败';
setTimeout(() => {
copyBtn.textContent = '复制';
}, 3000);
}
});
actions.appendChild(copyBtn);
caption.innerHTML = '';
caption.appendChild(info);
caption.appendChild(actions);
const markedLines = block.getAttribute('data-marked-lines');
if (markedLines) {
const lines = markedLines.split(',');
lines.forEach(range => {
if (range.includes('-')) {
const [start, end] = range.split('-').map(Number);
for (let i = start; i <= end; i++) {
const line = block.querySelector(`.line-${i}`);
if (line) line.classList.add('marked');
}
} else {
const line = block.querySelector(`.line-${range}`);
if (line) line.classList.add('marked');
}
});
}
});
});</script><script async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js" id="MathJax-script"></script><script>(function() {
document.addEventListener('DOMContentLoaded', function() {
const themeToggle = document.querySelector('.theme-toggle');
if (!themeToggle) return;
const getCurrentTheme = () => {
return document.documentElement.getAttribute('data-theme') || 'light';
};
const updateUI = (theme) => {
const isDark = theme === 'dark';
themeToggle.setAttribute('aria-pressed', isDark.toString());
};
const setTheme = (theme) => {
document.documentElement.setAttribute('data-theme', theme);
document.documentElement.style.colorScheme = theme;
const pageWrapper = document.getElementById('page-wrapper');
if (pageWrapper) {
pageWrapper.setAttribute('data-theme', theme);
}
// Find and remove the temporary anti-flicker style tag if it exists.
// This ensures the main stylesheet takes full control after the initial load.
const antiFlickerStyle = document.getElementById('anti-flicker-style');
if (antiFlickerStyle) {
antiFlickerStyle.remove();
}
localStorage.setItem('theme', theme);
updateUI(theme);
};
const toggleTheme = () => {
const current = getCurrentTheme();
const newTheme = current === 'light' ? 'dark' : 'light';
setTheme(newTheme);
};
updateUI(getCurrentTheme());
themeToggle.addEventListener('click', toggleTheme);
if (window.matchMedia) {
const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
mediaQuery.addEventListener('change', function(e) {
if (!localStorage.getItem('theme')) {
const theme = e.matches ? 'dark' : 'light';
setTheme(theme);
}
});
}
});
})();
</script><script src="../js/details-toggle.js" defer></script><script>(function() {
document.addEventListener('DOMContentLoaded', function() {
const backToTopBtn = document.querySelector('.back-to-top');
if (!backToTopBtn) return;
const toggleButtonVisibility = () => {
const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
const shouldShow = scrollTop > 200;
if (shouldShow) {
backToTopBtn.classList.add('is-visible');
} else {
backToTopBtn.classList.remove('is-visible');
}
};
let ticking = false;
const handleScroll = () => {
if (!ticking) {
requestAnimationFrame(() => {
toggleButtonVisibility();
ticking = false;
});
ticking = true;
}
};
const scrollToTop = (event) => {
event.preventDefault();
window.scrollTo({
top: 0,
behavior: 'smooth'
});
};
window.addEventListener('scroll', handleScroll);
backToTopBtn.addEventListener('click', scrollToTop);
toggleButtonVisibility();
});
})();</script></body></html>