Greasemonkey script to display newer comments on YouTube – bypass censorship

Changes comments filter to “Newest first” from “Top comments”

YouTube has been raining on the parade of its content creators with demonetization, censorship and unexplained notifications disablement. Youtube comments are also being censored. The default filter is not “Newest first” or “Oldest first” but “Top comments”. Trolls will eventually game the system. I would rather see unfiltered comments. So, here it is:

// ==UserScript==
// @name        Show newer YouTube comments
// @namespace   com.vsubhash.js.show-youtube-comments-newer
// @description Automatically changes YouTube comments filter off
// @include     https://www.youtube.com/watch*
// @exclude     %exclude%
// @version     1
// @grant       none
// ==/UserScript==

 
document.addEventListener("DOMContentLoaded", startItDelayed, false);
  
function startItDelayed() {
  window.setTimeout(switchCommentsList, 10*1000);
}
 
function switchCommentsList() { 
  console.log("Showing newer comments");
  var arButtons = document.getElementsByTagName("button");
  console.log(arButtons.length);
  
  var bFound = false;
  for (var i = 0; i < arButtons.length; i++) {
    //console.log(arButtons[i].textContent);
    if (arButtons[i].textContent.trim() == "Top comments") {
      arButtons[i].click();
      bFound = true;
      break;
    }
  }
  if (bFound) {
    //console.log("Menu found--------------");
    var arButtons = document.getElementsByTagName("button");
    console.log(arButtons.length);
    for (var i = 0; i < arButtons.length; i++) {
      //console.log(arButtons[i].textContent);
      if (arButtons[i].textContent.trim() == "Newest first") {
        arButtons[i].click();
        bFound = true;
        break;
      }
    }
  }
}

Advertisements
This entry was posted in software and tagged , , . Bookmark the permalink.

Make a comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s