// ==UserScript== // @name YouTube: Revert Icon Dropdown // @namespace https://greasyfork.org/en/users/1008366-trickyclock // @author TrickyClock // @version 1.4 // @description Replace 'Google Account' with 'Your channel' on the Icon Dropdown // @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com // @license MIT // @match https://www.youtube.com/* // @grant none // @run-at document-body // @require https://cdn.jsdelivr.net/gh/rybak/userscript-libs@e86c722f2c9cc2a96298c8511028f15c45180185/waitForElement.js // @downloadURL none // ==/UserScript== "use strict"; function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } function insertAfter(newNode, referenceNode) { referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling); } (async () => { const channelIcon = `
`; // Hide 'Your channel' button from the sidebar waitForElement('#contentContainer #endpoint[title="Your channel"]').then((yourChannelButton) => { yourChannelButton.parentNode.style.display = "none"; }); // Observe when Icon Dropdown changes const observer = new MutationObserver((mutations) => { const intervalId = setInterval(async () => { // Find 'Google Account' Button var googleAccountButton = await waitForElement('tp-yt-iron-dropdown #sections yt-multi-page-menu-section-renderer:nth-child(1) #endpoint:nth-child(1)'); // Copy 'Google Account Button' to make sure it doesn't get too modified again if (!googleAccountButton.parentNode.hasAttribute('cloned')) { const newFullGoogleAccountButton = googleAccountButton.parentNode.cloneNode(true); const newGoogleAccountButton = newFullGoogleAccountButton.querySelector('#endpoint'); newFullGoogleAccountButton.setAttribute('cloned', ''); newFullGoogleAccountButton.setAttribute('prevHref', googleAccountButton.href); googleAccountButton.parentNode.parentNode.replaceChild(newFullGoogleAccountButton, googleAccountButton.parentNode); googleAccountButton = await waitForElement('tp-yt-iron-dropdown #sections yt-multi-page-menu-section-renderer:nth-child(1) #endpoint:nth-child(1)'); } // Find 'View your channel' Button, Get the Channel URL, and replace it with 'Manage your Google Account' var viewYourChannelButton = await waitForElement('#channel-container #manage-account a:nth-child(1)'); const channelUrl = viewYourChannelButton.hasAttribute('prevHref') ? viewYourChannelButton.getAttribute('prevHref') : viewYourChannelButton.href; viewYourChannelButton.setAttribute('prevHref', channelUrl); if (!viewYourChannelButton.parentNode.hasAttribute('cloned')) { const clonedViewYourChannelButton = viewYourChannelButton.cloneNode(true); clonedViewYourChannelButton.setAttribute('cloned', ''); viewYourChannelButton.parentNode.replaceChild(clonedViewYourChannelButton, viewYourChannelButton); viewYourChannelButton = await waitForElement('#channel-container #manage-account a:nth-child(1)'); } viewYourChannelButton.innerHTML = "Manage your Google Account"; viewYourChannelButton.href = googleAccountButton.parentNode.getAttribute('prevHref'); viewYourChannelButton.target = "_blank"; // 'Google Account' Button Icons and Labels const googleAccountIcon = googleAccountButton.querySelector('#content-icon yt-icon'); const googleAccountLabel = googleAccountButton.querySelector('#primary-text-container #label .yt-formatted-string'); // Put things onto the copied 'Google Account' Button googleAccountButton.href = channelUrl; googleAccountButton.tabIndex = -1; googleAccountButton.dir = "auto"; googleAccountLabel.innerHTML = "Your channel"; googleAccountIcon.innerHTML = channelIcon; // Move 'YouTube Studio' Button below 'Your channel' Button const youTubeStudioButton = document.querySelector('tp-yt-iron-dropdown #endpoint[href^="https://studio.youtube.com"]'); if (youTubeStudioButton) { insertAfter(youTubeStudioButton.parentNode, googleAccountButton.parentNode); } // Clear Interval so it doesn't run forever! clearInterval(intervalId); }, 100); }); observer.observe((await waitForElement('#contentWrapper ytd-multi-page-menu-renderer #container')), { attributes: true, }); })();