Skip to content

Instantly share code, notes, and snippets.

@vsubhash
Created September 10, 2018 06:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vsubhash/673be40439fa9fd9ca51b1b096623ef1 to your computer and use it in GitHub Desktop.
Save vsubhash/673be40439fa9fd9ca51b1b096623ef1 to your computer and use it in GitHub Desktop.
Show newer YouTube comments (com.vsubhash.js.show-youtube-comments-newer) is a User Script for YouTube that will display newer comments first instead of the default moderated "Top Comments". This script can be installed in Firfox browsers using the Greasemonkey add-on.
// ==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 2018
// @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;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment