知乎图片缩小篡改猴脚本,让图片不会太大,看着更舒服
下面是代码:
// ==/UserScript==
// @name 知乎图片缩小 (Zhihu Image Resizer)
// @namespace http://tampermonkey.net/
// @version 0.1
// @description 将知乎内容中的图片宽度强制改为 40%,忽略随机类名
// @author You
// @match *://*.zhihu.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=zhihu.com
// @grant GM_addStyle
(function() {
'use strict';
const customCSS = `
img.content_image,
img.origin_image,
figure.ZVideoItem img,
.RichContent-inner img[data-caption],
img.content_image[data-size="normal"],
img.origin_image[data-size="normal"] {
width: 40% !important;
min-width: 200px !important; /* 防止图片变得太小 */
cursor: zoom-in !important;
}
`;
// 注入样式
if (typeof GM_addStyle !== "undefined") {
GM_addStyle(customCSS);
} else {
// 兼容不支持 GM_addStyle 的环境
const styleNode = document.createElement("style");
styleNode.type = "text/css";
styleNode.innerHTML = customCSS;
document.head.appendChild(styleNode);
}
})();
