Add Link To Expand YouTube Community Comments

Add a link to expand YouTube Community comment contents and replies

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.

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

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           Add Link To Expand YouTube Community Comments
// @version        1.1
// @namespace      AddLinkToExpandYouTubeCommunityComments
// @description    Add a link to expand YouTube Community comment contents and replies
// @author         jcunews
// @include        https://www.youtube.com/comments*
// ==/UserScript==

function expandCommentsInPage() {
  var i, eles = document.querySelectorAll('#yt-comments-list .comment-entry'), ele;
  for (i = eles.length-1; i >= 0; i--) {
    ele = eles[i].querySelector(".expand");
    if (ele) {
      eles[i].click();
    }
    ele = eles[i].querySelector(".show-more");
    if (ele) {
      eles[i].click();
    }
  }
}

var btn = document.createElement("A");
btn.textContent = "Expand All Comments";
btn.style = "margin-left:2ex";
btn.href="javascript:void(0)";
btn.onclick = expandCommentsInPage;
document.querySelector("#ytch-root .tabs-container").appendChild(btn);