QWFP6 / Youtube music tab

// ==UserScript==
// @name         Youtube music tab
// @namespace    https://openuserjs.org/scripts/QWFP6/Youtube_music_tab
// @version      1.1
// @description  Show youtube music tab
// @author       QWFP6
// @match        https://www.youtube.com/*
// @grant        none
// ==/UserScript==


ymt = {
    init: function(){
        ymt.addMusicTab();
        window.addEventListener("spfdone", ymt.addMusicTab);
    },
    addMusicTab: function(){
        if(document.querySelector('#__YTP_MUSIC_TAB__') !== null){
            return;
        }
        var music = document.createElement("li");
        music.id = "__YTP_MUSIC_TAB__";
        if(window.location.href.match(/\/feed\/music/ig)){
            ymt.selected(music);
        }else{
            ymt.unselected(music);
        }
        ymt.addGuideItem();
            document.querySelector(".appbar-nav-menu").appendChild(music);
    },
    addGuideItem: function(){
        var musicItem = '<li class="guide-channel guide-notification-item overflowable-list-item " id="music-guide-item" data-visibility-tracking="" role="menuitem"> <a class="guide-item yt-uix-sessionlink yt-valign spf-link " href="/feed/music" title="Musique" data-sessionlink="ei=glltVvLVAcyMcKXfreAN&amp;ved=CPABELUsGAMiEwjynqHY4NjJAhVMBhwKHaVvC9wo6R4&amp;feature=g-personal" data-visibility-tracking="" data-external-id="music" data-serialized-endpoint="0qDduQEREg9GRXN1YnNjcmlwdGlvbnM%3D"> <span class="yt-valign-container"> <span class="thumb guide-music-icon yt-sprite"></span> <span class="display-name no-count"> <span> Musique </span> </span> </span> </a> </li>';
        var div = document.createElement('div');
        div.innerHTML = musicItem;
        var musicNode  = div.childNodes[0];
        var child = document.querySelector('#subscriptions-guide-item');
        child.parentNode.insertBefore(musicNode, child.nextSibling);
    },
    unselected:function(music){
        var a = document.createElement("a");
        a.href="/feed/music";
        a.className="yt-uix-button   spf-link yt-uix-sessionlink yt-uix-button-epic-nav-item yt-uix-button-size-default";
        var span = document.createElement("span");
        span.className="yt-uix-button-content";
        span.innerText="Musique";
        music.appendChild(a);
        a.appendChild(span);
    },
    selected:function(music){
        var h2 = document.createElement("h2");
        h2.className="epic-nav-item-heading";
        h2.innerText="Musique";
        music.appendChild(h2);
    }
}

/*<li>    <a href="/feed/music" class="yt-uix-button   spf-link yt-uix-sessionlink yt-uix-button-epic-nav-item yt-uix-button-size-default" data-sessionlink="ved=CMEBEMMtGAEiEwjmwdqgpNHJAhVUCBwKHeLqAtEojh4&amp;ei=nW5pVqb_DdSQcOLVi4gN" id="gh-navitem-trending" aria-selected="false"><span class="yt-uix-button-content">Musique</span></a>
</li>*/
ymt.init();
/*
<li>    
    <a href="/" class="yt-uix-button   spf-link yt-uix-sessionlink yt-uix-button-epic-nav-item yt-uix-button-size-default" data-sessionlink="ei=4xDSVf7vL82mWIawmcgJ&amp;ved=CEgQwy0oAA" aria-selected="false">
        <span class="yt-uix-button-content">Accueil</span></a>
</li>*/