Greasy Fork

Greasy Fork is available in English.

浏览器字体渲染

解决Windows平台浏览器默认情况下字体渲染偏细的问题。适用于Edge、Chrome、Firefox等。

当前为 2026-01-16 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         浏览器字体渲染
// @namespace    fontrenderning.script.cmos4k
// @version      1.3.1
// @description  解决Windows平台浏览器默认情况下字体渲染偏细的问题。适用于Edge、Chrome、Firefox等。
// @author       太极
// @match        *://*/*
// @grant        GM_addStyle
// @run-at       document-start
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    // --- 配置区域 ---
    const config = {
        shadowSize: '0.75px',
        shadowColor: '#7C7C7CDD',
        strokeSize: '0px',
        strokeColor: 'transparent'
    };

    // --- 排除列表 ---
    const excludeSelectors = [
        'i', '[class*="glyph"]', '[class*="icon"]', '[class*="fa-"]', '[class*="vjs-"]',
        '[class*="watermark"]', '.textLayer *', 'pre', 'pre *', 'code', 'code *',
        '.mjx-container *', '.katex *'
    ].join(',');

    // --- 生成 CSS ---
    const css = `
        /* 1. 全局抗锯齿 */
        html {
            -webkit-font-smoothing: antialiased !important;
            -moz-osx-font-smoothing: grayscale !important;
            text-rendering: optimizeLegibility !important;
            -webkit-text-size-adjust: 100% !important;
        }

        /* 2. 核心渲染 */
        body, * {
            text-shadow: 0 0 ${config.shadowSize} ${config.shadowColor};
            -webkit-text-stroke: ${config.strokeSize} ${config.strokeColor};
        }

        /* 3. 排除项 */
        ${excludeSelectors} {
            text-shadow: none !important;
            -webkit-text-stroke: 0px transparent !important;
        }

        /* 4. 选中样式修复 */
        ::selection {
            background: Highlight !important;
            color: HighlightText !important;
            text-shadow: none !important;
            -webkit-text-stroke: 0px transparent !important;
        }
    `;

    // --- 注入样式 ---
    if (typeof GM_addStyle !== "undefined") {
        GM_addStyle(css);
    } else {
        const style = document.createElement('style');
        style.textContent = css;
        (document.head || document.documentElement).appendChild(style);
    }

})();