Sleazy Fork is available in English.

YouTube Avatars Fix

Fixes the display of avatars on YouTube

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램을 설치해야 합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

Advertisement:

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

Advertisement:

// ==UserScript==
// @name         YouTube Avatars Fix
// @namespace    http://tampermonkey.net/
// @version      0.5
// @description  Fixes the display of avatars on YouTube
// @author       frz
// @icon         https://www.google.com/s2/favicons?sz=64&domain=youtube.com
// @match        https://*.youtube.com/*
// @match        https://studio.youtube.com/*
// @match        https://yt3.googleusercontent.com/*
// @match        https://yt4.ggpht.com/*
// @match        https://yt4.googleusercontent.com/*
// @match        https://vidiq.com/*
// @grant        none
// @run-at       document-start
// ==/UserScript==

(function() {
    'use strict';

    function fixAvatarUrl(url) {
        if (!url) return url;

        return url.replace(/yt3\.ggpht\.com/g, 'yt4.ggpht.com');
    }


    function fixImage(img) {
        if (!img || !img.src) return;
        const originalSrc = img.src;

        if (originalSrc.includes('yt3.ggpht.com')) {
            const newSrc = fixAvatarUrl(originalSrc);
            if (newSrc !== originalSrc) {
                img.src = newSrc;

            }
        }
    }


    const observer = new MutationObserver(mutations => {
        mutations.forEach(mutation => {

            if (mutation.addedNodes.length) {
                mutation.addedNodes.forEach(node => {
                    if (node.nodeType === Node.ELEMENT_NODE) {

                        if (node.tagName === 'IMG') {
                            fixImage(node);
                        }

                        if (node.querySelectorAll) {
                            node.querySelectorAll('img[src*="yt3.ggpht.com"]').forEach(fixImage);
                        }
                    }
                });
            }

            if (mutation.type === 'attributes' && mutation.attributeName === 'src') {
                const target = mutation.target;
                if (target.tagName === 'IMG') {
                    fixImage(target);
                }
            }
        });
    });


    observer.observe(document.documentElement, {
        childList: true,
        subtree: true,
        attributes: true,
        attributeFilter: ['src']
    });


    document.querySelectorAll('img[src*="yt3.ggpht.com"]').forEach(fixImage);
})();