YouTube: Revert Icon Dropdown

Replace 'Google Account' with 'Your channel' on the Icon Dropdown

Install this script?
Author's suggested script

You may also like YouTube Thumbnail Viewer.

Install this script
  1. // ==UserScript==
  2. // @name YouTube: Revert Icon Dropdown
  3. // @namespace https://greasyfork.org/en/users/1008366-trickyclock
  4. // @author TrickyClock
  5. // @version 1.4
  6. // @description Replace 'Google Account' with 'Your channel' on the Icon Dropdown
  7. // @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com
  8. // @license MIT
  9. // @match https://www.youtube.com/*
  10. // @grant none
  11. // @run-at document-body
  12. // @require https://cdn.jsdelivr.net/gh/rybak/userscript-libs@e86c722f2c9cc2a96298c8511028f15c45180185/waitForElement.js
  13. // ==/UserScript==
  14. "use strict";
  15.  
  16. function sleep(ms) {
  17. return new Promise(resolve => setTimeout(resolve, ms));
  18. }
  19.  
  20. function insertAfter(newNode, referenceNode) {
  21. referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
  22. }
  23.  
  24. (async () => {
  25. const channelIcon = `<div style="width: 100%; height: 100%; fill: currentcolor;"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" focusable="false" style="pointer-events: none; display: block; width: 100%; height: 100%;">
  26. <path d="M3,3v18h18V3H3z M4.99,20c0.39-2.62,2.38-5.1,7.01-5.1s6.62,2.48,7.01,5.1H4.99z M9,10c0-1.65,1.35-3,3-3s3,1.35,3,3 c0,1.65-1.35,3-3,3S9,11.65,9,10z M12.72,13.93C14.58,13.59,16,11.96,16,10c0-2.21-1.79-4-4-4c-2.21,0-4,1.79-4,4 c0,1.96,1.42,3.59,3.28,3.93c-4.42,0.25-6.84,2.8-7.28,6V4h16v15.93C19.56,16.73,17.14,14.18,12.72,13.93z"></path>
  27. </svg></div>`;
  28.  
  29. // Hide 'Your channel' button from the sidebar
  30. waitForElement('#contentContainer #endpoint[title="Your channel"]').then((yourChannelButton) => {
  31. yourChannelButton.parentNode.style.display = "none";
  32. });
  33.  
  34. // Observe when Icon Dropdown changes
  35. const observer = new MutationObserver((mutations) => {
  36. const intervalId = setInterval(async () => {
  37. // Find 'Google Account' Button
  38. var googleAccountButton = await waitForElement('tp-yt-iron-dropdown #sections yt-multi-page-menu-section-renderer:nth-child(1) #endpoint:nth-child(1)');
  39.  
  40. // Copy 'Google Account Button' to make sure it doesn't get too modified again
  41. if (!googleAccountButton.parentNode.hasAttribute('cloned')) {
  42. const newFullGoogleAccountButton = googleAccountButton.parentNode.cloneNode(true);
  43. const newGoogleAccountButton = newFullGoogleAccountButton.querySelector('#endpoint');
  44. newFullGoogleAccountButton.setAttribute('cloned', '');
  45. newFullGoogleAccountButton.setAttribute('prevHref', googleAccountButton.href);
  46. googleAccountButton.parentNode.parentNode.replaceChild(newFullGoogleAccountButton, googleAccountButton.parentNode);
  47. googleAccountButton = await waitForElement('tp-yt-iron-dropdown #sections yt-multi-page-menu-section-renderer:nth-child(1) #endpoint:nth-child(1)');
  48. }
  49.  
  50. // Find 'View your channel' Button, Get the Channel URL, and replace it with 'Manage your Google Account'
  51. var viewYourChannelButton = await waitForElement('#channel-container #manage-account a:nth-child(1)');
  52. const channelUrl = viewYourChannelButton.hasAttribute('prevHref') ? viewYourChannelButton.getAttribute('prevHref') : viewYourChannelButton.href;
  53. viewYourChannelButton.setAttribute('prevHref', channelUrl);
  54.  
  55. if (!viewYourChannelButton.parentNode.hasAttribute('cloned')) {
  56. const clonedViewYourChannelButton = viewYourChannelButton.cloneNode(true);
  57. clonedViewYourChannelButton.setAttribute('cloned', '');
  58. viewYourChannelButton.parentNode.replaceChild(clonedViewYourChannelButton, viewYourChannelButton);
  59. viewYourChannelButton = await waitForElement('#channel-container #manage-account a:nth-child(1)');
  60. }
  61.  
  62. viewYourChannelButton.innerHTML = "Manage your Google Account";
  63. viewYourChannelButton.href = googleAccountButton.parentNode.getAttribute('prevHref');
  64. viewYourChannelButton.target = "_blank";
  65.  
  66. // 'Google Account' Button Icons and Labels
  67. const googleAccountIcon = googleAccountButton.querySelector('#content-icon yt-icon');
  68. const googleAccountLabel = googleAccountButton.querySelector('#primary-text-container #label .yt-formatted-string');
  69.  
  70. // Put things onto the copied 'Google Account' Button
  71. googleAccountButton.href = channelUrl;
  72. googleAccountButton.tabIndex = -1;
  73. googleAccountButton.dir = "auto";
  74. googleAccountLabel.innerHTML = "Your channel";
  75. googleAccountIcon.innerHTML = channelIcon;
  76.  
  77. // Move 'YouTube Studio' Button below 'Your channel' Button
  78. const youTubeStudioButton = document.querySelector('tp-yt-iron-dropdown #endpoint[href^="https://studio.youtube.com"]');
  79. if (youTubeStudioButton) {
  80. insertAfter(youTubeStudioButton.parentNode, googleAccountButton.parentNode);
  81. }
  82.  
  83. // Clear Interval so it doesn't run forever!
  84. clearInterval(intervalId);
  85. }, 100);
  86. });
  87.  
  88. observer.observe((await waitForElement('#contentWrapper ytd-multi-page-menu-renderer #container')), {
  89. attributes: true,
  90. });
  91. })();