修改字体

懒得写

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         修改字体
// @namespace    https://normal-pcer.example.com/
// @license unlicense
// @version      1.0
// @description  懒得写
// @author       normal-pcer
// @match  https://*/*
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    // Your code here...
    let fun = () => {
        let targets = new Array("p", "span", "a");
        for (let index0 = 0; index0 < targets.length; index0++) {
            let t = document.getElementsByTagName(targets[index0]);
            for (let index = 0; index < t.length; index++) {
                let item = t[index];
                if (item.style !== undefined) {
                    item.style.fontFamily = "Times New Roman, 华文中宋";
                } else {
                    item.style = "font-family: Times New Roman, 华文中宋"
                }
            }
        }
        targets = new Array("h1", "h2", "h3", "h4", "h5", "h6", "header");
        for (let index0 = 0; index0 < targets.length; index0++) {
            let t = document.getElementsByTagName(targets[index0]);
            for (let index = 0; index < t.length; index++) {
                let item = t[index];
                if (item.style !== undefined) {
                    item.style.fontFamily = "Tahoma, 微软雅黑";
                } else {
                    item.style = "font-family: Tahoma, 微软雅黑"
                }
            }
        }
        targets = new Array("pre");
        for (let index0 = 0; index0 < targets.length; index0++) {
            let t = document.getElementsByTagName(targets[index0]);
            for (let index = 0; index < t.length; index++) {
                let item = t[index];
                if (item.style !== undefined) {
                    item.style.fontFamily = "Jetbrains Mono, 微软雅黑";
                } else {
                    item.style = "font-family: Jetbrains Mono, 微软雅黑"
                }
            }
        }
    }

    const observer = new MutationObserver(fun);
    const targetNode = document.body;
    const config = { attributes: true, childList: true, subtree: true, characterData: true, };
    observer.observe(targetNode, config);

})();