치지직 Pretendard

nemony 제외 Pretendard 적용 + name_text 클래스는 굵게 처리

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

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

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         치지직 Pretendard
// @namespace    http://tampermonkey.net/
// @version      1.2
// @description  nemony 제외 Pretendard 적용 + name_text 클래스는 굵게 처리
// @author       ChatGPT
// @match        https://chzzk.naver.com/*
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    // 1. Pretendard 웹폰트 로드
    const link = document.createElement('link');
    link.href = 'https://cdn.jsdelivr.net/gh/orioncactus/pretendard/dist/web/static/pretendard.css';
    link.rel = 'stylesheet';
    document.head.appendChild(link);

    // 2. Pretendard 적용 + name_text 처리 함수
    function applyStyles() {
        const allElements = document.body.getElementsByTagName("*");

        for (let el of allElements) {
            const style = window.getComputedStyle(el);
            const font = style.fontFamily.toLowerCase();

            // 2-1. nemony 포함된 요소는 무시
            if (font.includes("nemony")) continue;

            // 2-2. Pretendard 폰트 강제 적용
            el.style.setProperty("font-family", "'Pretendard', sans-serif", "important");

            // 2-3. class에 name_text 포함되면 굵게
            const className = el.className || "";
            if (typeof className === 'string' && className.includes("name_text")) {
                el.style.setProperty("font-weight", "bold", "important");
            }
        }
    }

    // 3. 초기 적용 + DOM 변화 감지
    window.addEventListener('load', () => {
        applyStyles();

        const observer = new MutationObserver(() => {
            applyStyles();
        });

        observer.observe(document.body, {
            childList: true,
            subtree: true
        });
    });
})();