修改字体

懒得写

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

You will need to install an extension such as Tampermonkey to install this script.

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 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);

})();