YouTube Revert Icon Dropdown

Remove the 'Google Account' Button from the Icon Dropdown

Versione datata 31/10/2023. Vedi la nuova versione l'ultima versione.

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==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
  });
})();