Skip to content

Instantly share code, notes, and snippets.

@shu8
Last active January 22, 2019 23:00
Show Gist options
  • Save shu8/2bac4ef1a92b47042715 to your computer and use it in GitHub Desktop.
Save shu8/2bac4ef1a92b47042715 to your computer and use it in GitHub Desktop.
Hide YouTube videos (only listen to the audio)
// ==UserScript==
// @name Youtube Video hider (to only listen to audio)
// @namespace http://stackexchange.com/users/4337810/
// @version 1.1
// @description A userscript that hides most of the video content on youtube, so you can listen rather than watch!
// @author ᔕᖺᘎᕊ (http://stackexchange.com/users/4337810/)
// @match *://*.youtube.com/*
// @run-at document-end
// @grant none
// ==/UserScript==
window.onload = function() {
document.getElementById('player-api').style.height = '50px';
};
@gadamo
Copy link

gadamo commented Jun 23, 2018

Perhaps modifying this as follows makes sense for clicks after window is loaded (or playlists):

// ==UserScript==
// @name         Youtube Video hider (to only listen to audio)
// @version      1.2
// @description  A userscript that hides most of the video content on youtube, so you can listen rather than watch!
// @match        *://*.youtube.com/*
// @run-at       document-end
// @grant        none
// ==/UserScript==

function hideVideo() {
  //console.log('hiding video..........');
  document.querySelector("div > video").style.opacity = '0';
}
setTimeout(hideVideo, 100);
// or
setInterval(hideVideo, 1000);

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