替换Ubuntu字体

替换网页字体为Ubuntu,特殊处理等宽字体

目前为 2020-12-27 提交的版本。查看 最新版本

// ==UserScript==
// @name         替换Ubuntu字体
// @namespace    http://tampermonkey.net/
// @version      0.7
// @description  替换网页字体为Ubuntu,特殊处理等宽字体
// @include      http://*
// @include      https://*
// @run-at       document-end
// @grant        none
// ==/UserScript==

(function () {
    'use strict'

    const replace_font = node => {
        const eles = node.getElementsByTagName('*')
        for (let i = 0; i < eles.length; i++) {
            if (eles[i].innerText && !window.getComputedStyle(eles[i]).fontFamily.includes('monospace')) {
                eles[i].style.fontFamily = 'Ubuntu'
            }
        }
    }

    replace_font(document)
    document.addEventListener('DOMNodeInserted', e => replace_font(e.target));

})()

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址