YouTube - automatically expand subscription list

Automatically click the "Show More" subscriptions button in the side bar

2021-11-04 기준 버전입니다. 최신 버전을 확인하세요.

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

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

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name         YouTube - automatically expand subscription list
// @description  Automatically click the "Show More" subscriptions button in the side bar
// @namespace    https://greasyfork.org/en/scripts/367774-youtube-automatically-expand-subscription-list
// @version      0.1.5
// @author       Valacar
// @include      https://www.youtube.com/*
// @noframes
// @grant        none
// ==/UserScript==

(function() {
  'use strict';

  const DEBUGGING = 0;
  const debugLog = DEBUGGING ? console.log : function(){};
  const debugAssert = DEBUGGING ? console.assert : function(){};

  window.addEventListener("loadstart", expandSubscriptions, true);

  function expandSubscriptions() {
    const expanderItems = document.querySelectorAll("#expander-item");
    debugLog("----------");
    debugLog("::: Found %d expander-items", expanderItems.length);
    for (let expander of expanderItems) {
      debugAssert(expander.parentNode);
      debugAssert(expander.parentNode.previousSibling);
      const lastSubscription = expander.parentNode.previousSibling;
      const feedItem = lastSubscription.querySelectorAll(
        'a[href^="/feed/subscriptions/"],a[href^="/channel/"],a[href^="/user/"],a[href^="/c/"]'
      );
      if (feedItem.length) {
        debugLog("::: Found a feed subscription link in section",
          expander.parentNode.closest("ytd-guide-section-renderer")
        );
        const displayProperty = window.getComputedStyle(expander).getPropertyValue("display");
        if (displayProperty === "block") {
          debugLog("::: Expander display property = ", displayProperty);
          debugLog("::: %cClicking expander",
            "background: green; color: white; font-weight: bold;"
          );
          expander.click();
          window.removeEventListener("loadstart", expandSubscriptions, true);
          return;
        } else {
          debugLog("::: Expander display property = ", displayProperty);
          debugLog("::: %cNot clicking since it appears to be expanded.",
            "background: yellow; color: #000; font-weight: bold;"
          );
        }
      } else {
        debugLog("::: No subscription feed link in section",
          expander.parentNode.closest("ytd-guide-section-renderer")
        );
      }
    }
  }

})();