Skip to content

Instantly share code, notes, and snippets.

@Bryan2333
Created January 18, 2026 13:41
Show Gist options
  • Select an option

  • Save Bryan2333/a0b6b4e31366875295194e03668925fd to your computer and use it in GitHub Desktop.

Select an option

Save Bryan2333/a0b6b4e31366875295194e03668925fd to your computer and use it in GitHub Desktop.
知乎表情包替换:[惊喜] → [可怜]
// ==UserScript==
// @name 知乎表情包替换:[惊喜] → [可怜]
// @namespace http://tampermonkey.net/
// @version 1.0
// @description 利用 CSS 瞬间替换知乎的 [惊喜] 表情
// @author BryanLiang
// @match *://www.zhihu.com/*
// @match *://zhuanlan.zhihu.com/*
// @grant GM_addStyle
// @run-at document-start
// ==/UserScript==
(function() {
'use strict';
// 原始图片的 Hash 值 (文件名核心部分)
const oldHash = '5c9b7521eb16507c9d2f747f3a32a813';
// 新图片链接
const newSrc = 'https://picx.zhimg.com/v2-efcc278139ad97608f4829fefaa3e068_xl.jpg';
// 注入 CSS
// 1. 匹配所有 src 包含该 hash 的 img 标签
// 2. 将 content 设置为新图片,直接覆盖原图渲染
// 3. 强制宽度 auto 避免变形
const css = `
img[src*="${oldHash}"] {
content: url("${newSrc}") !important;
opacity: 1 !important;
}
`;
if (typeof GM_addStyle !== 'undefined') {
GM_addStyle(css);
} else {
const style = document.createElement('style');
style.textContent = css;
document.head.appendChild(style);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment