替换Ubuntu字体

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

目前為 2020-12-30 提交的版本,檢視 最新版本

// ==UserScript==
// @name         替换Ubuntu字体
// @namespace    http://tampermonkey.net/
// @version      1.2
// @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++) {
            try {
                if (eles[i].tagName != 'I' && !eles[i].className.includes('icon') && !window.getComputedStyle(eles[i]).fontFamily.includes('icon') && !window.getComputedStyle(eles[i]).fontFamily.includes('monospace')) {
                    eles[i].style.fontFamily = 'Ubuntu'
                }
            }
            catch (e) { }
        }
    }

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

})()

QingJ © 2025

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