Font Replacer

Replaces specified fonts with alternatives across all page elements

目前為 2025-04-03 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

作者
pfzim
評價
0 0 0
版本
0.2
建立日期
2025-03-28
更新日期
2025-04-03
尺寸
7.8 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);