Font Replacer

Replaces specified fonts with alternatives across all page elements

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

作者
pfzim
日安装量
0
总安装量
14
评分
0 0 0
版本
0.4
创建于
2025-03-28
更新于
2025-04-04
大小
12.9 KB
许可证
GPL-3.0-or-later
适用于
所有网站

Font Replacer Script Overview

This UserScript automatically replaces specified fonts with alternatives across all webpage elements. Its primary purpose is to improve text readability when font anti-aliasing is disabled, as some fonts (like Helvetica or GitLab Sans) may render poorly without smoothing.


Key Features

  1. Real-Time Font Replacement
    Scans for target fonts (e.g., Helvetica, GitLab Sans) and substitutes them with more legible alternatives (Verdana, Arial, etc.).

  2. Customizable Replacements
    Configure font mappings in the fontReplacements object:

    const fontReplacements = {
       "Helvetica": "Verdana",
       "Segoe UI": "Arial"
       // Add more as needed
    };
    
  3. Comprehensive Coverage

    • Recursively checks all DOM elements (including nested/dynamic content via MutationObserver).
    • Handles inline styles and CSS-computed fonts.
  4. Non-Intrusive Execution

    • No grant permissions required.
    • Only modifies fonts that match replacement rules.

How to Use

  1. Install the script in Tampermonkey/Greasemonkey.
  2. Edit fontReplacements to match your preferences.
  3. Fonts will update automatically upon page load.

Example Replacements

Original Font Replacement Reason
Helvetica Verdana Better readability without AA
GitLab Sans Verdana Fixes jagged edges
Roboto Mono Courier New Crisper monospace rendering

Technical Notes

  • Works on all sites (via @match *://*/*).
  • Optional @font-face override (commented out) for forced enforcement.
  • Processes dynamically added content without page reloads.

Ideal for GitLab, Jira, and other interfaces where fonts degrade without anti-aliasing.

Pro Tip: Uncomment the console.log lines to debug font changes in real time.

// Debug example:
// console.log('Replaced:', originalFont, '→', newFont);