字体替换,默认为Ubuntu,可自行修改,略过等宽字体
目前為
// ==UserScript==
// @name 字体替换
// @namespace http://tampermonkey.net/
// @version 1.5
// @description 字体替换,默认为Ubuntu,可自行修改,略过等宽字体
// @include http://*
// @include https://*
// @grant none
// ==/UserScript==
(function () {
'use strict'
const replace_font = root => {
[...root.querySelectorAll('h1, h2, h3, h4, h5, h6, div, li, ol, p, ul, a, span, td, th, button, input, label, option, select')].map(ele => {
try {
if (!window.getComputedStyle(ele).fontFamily.toLowerCase().includes('mono') && window.getComputedStyle(ele, ':before').content === 'none') {
ele.style.fontFamily = 'Ubuntu'
}
}
catch (e) { }
})
}
replace_font(document)
document.addEventListener('DOMNodeInserted', e => replace_font(e.target));
})()