Skip to content

Instantly share code, notes, and snippets.

@LazyMammal
Created September 20, 2017 11:54
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LazyMammal/1c60c45e9df26602f688d025f3b20f0c to your computer and use it in GitHub Desktop.
Save LazyMammal/1c60c45e9df26602f688d025f3b20f0c to your computer and use it in GitHub Desktop.
Hide live chat by default on YouTube live streams
// ==UserScript==
// @name YouTube - Hide Live Chat
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Hide live chat by default on live streams
// @author LM
// @match https://www.youtube.com/watch*
// @run-at document-end
// @grant none
// ==/UserScript==
function AddClass() {
var el = document.getElementById("live-chat-iframe");
if(el) {
el.parentElement.classList.add("yt-uix-expander-collapsed");
console.log('Hide Live Chat');
return true;
}
return false;
}
function KeepTrying(func, attempts, delay) {
console.log('Keep Trying ' + attempts);
if( !func() && attempts-1 > 0 ) {
window.setTimeout( function() {
KeepTrying(func, attempts-1, delay);
});
}
}
(function() {
'use strict';
KeepTrying( AddClass, 5, 10 );
})();
@lbmaian
Copy link

lbmaian commented Feb 8, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment