YouTube Revert Icon Dropdown

Remove the 'Google Account' Button from the Icon Dropdown

Από την 31/10/2023. Δείτε την τελευταία έκδοση.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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