YouTube Music New Releases Fixer

Fix some really bad UI/UX decisions.

// ==UserScript==
// @name         YouTube Music New Releases Fixer
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  Fix some really bad UI/UX decisions.
// @author       Vaughn Royko
// @match        https://music.youtube.com/*
// @icon         https://www.google.com/s2/favicons?domain=youtube.com
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    function addGlobalStyle(css) {
        var head = document.getElementsByTagName('head')[0];
        var style = document.createElement('style');
        style.type = 'text/css';
        style.innerHTML = css;
        head.appendChild(style);
    }

    addGlobalStyle('ytmusic-two-row-item-renderer[has-badges_] .subtitle.ytmusic-two-row-item-renderer { white-space: normal !important; }');
    addGlobalStyle('.title-group.ytmusic-two-row-item-renderer { max-height: none !important; }');
    addGlobalStyle('ytmusic-two-row-item-renderer:not([has-badges_]) .subtitle.ytmusic-two-row-item-renderer { display: block !important; overflow: visisble !important; max-height: none !important; }');

    function addAlbumStyles() {
        var albumTypes = document.getElementsByClassName('style-scope yt-formatted-string');
        for (var albumType of albumTypes) {
            var albumCover = albumType.parentNode.parentNode.parentNode.parentNode.getElementsByClassName('image')[0];
            albumCover.style.boxSizing = 'border-box';
            if (albumType.innerHTML === 'Single') {
                albumCover.style.border = '5px solid #ff0047';
                albumType.style.color = '#ff0047';
            } else if (albumType.innerHTML === 'EP') {
                albumCover.style.border = '5px solid #a9ff00';
                albumType.style.color = '#a9ff00';
            } else if (albumType.innerHTML === 'Album') {
                albumCover.style.border = '5px solid #00d0ff';
                albumType.style.color = '#00d0ff';
            }
        }
    }
    addAlbumStyles();

    var currentLocation = document.location.href;
    var observer = new MutationObserver((mutationList) => {
        if (currentLocation !== document.location.href) {
            currentLocation = document.location.href;
            addAlbumStyles();
        }
    });

    observer.observe(document.getElementById('contents'), {
        childList: true,
        subtree: true
    });
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址