YouTube Revert Icon Dropdown

Remove the 'Google Account' Button from the Icon Dropdown

Tính đến 31-10-2023. Xem phiên bản mới nhất.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(Tôi đã có Trình quản lý tập lệnh người dùng, hãy cài đặt nó!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         YouTube Revert Icon Dropdown
// @namespace    https://greasyfork.org/en/users/1008366-trickyclock
// @author       TrickyClock
// @version      1.0
// @description  Remove the 'Google Account' Button from the Icon Dropdown
// @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
// ==/UserScript==

function insertAfter(newNode, referenceNode) {
  referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
}

(async () => {
  waitForElement('#contentContainer #endpoint[title="Your channel"]').then((yourChannelButton) => {
    yourChannelButton.parentNode.style.display = "none";
  });

  const observer = new MutationObserver(mutations => {
    const intervalId = setInterval(() => {
      waitForElement('tp-yt-iron-dropdown #sections yt-multi-page-menu-section-renderer:nth-child(1) #endpoint:nth-child(1)').then(async (googleAccountButton) => {
        const yourChannelButton = await waitForElement('#contentContainer #endpoint[title="Your channel"]');
        const yourDataInYoutubeButton = await waitForElement('tp-yt-iron-dropdown #sections yt-multi-page-menu-section-renderer:nth-child(3) #endpoint:nth-child(1)');

        const channelUrl = yourChannelButton.href;
        const channelIcon = yourChannelButton.querySelector('yt-icon yt-icon-shape')
        const googleAccountIcon = googleAccountButton.querySelector('yt-icon yt-icon-shape');
        const googleAccountLabel = googleAccountButton.querySelector('#primary-text-container span');

        googleAccountButton.href = channelUrl;
        googleAccountButton.tabindex = "0";

        googleAccountLabel.innerHTML = "Your channel";
        googleAccountIcon.innerHTML = channelIcon.innerHTML;


        const youtubeStudioButton = document.querySelector('tp-yt-iron-dropdown #endpoint[href^="https://studio.youtube.com"]');
        if (youtubeStudioButton) {
          insertAfter(youtubeStudioButton.parentNode, googleAccountButton.parentNode);
        }

        clearInterval(intervalId);
      });
    }, 100);
 });

  observer.observe((await waitForElement('#contentWrapper ytd-multi-page-menu-renderer')), {
    childList: true,
    subtree: true
  });
})();