Last active
January 1, 2023 23:01
-
-
Save alexcmgit/4f62e3082f832c7e8f23ee7030578206 to your computer and use it in GitHub Desktop.
Tampermonkey filter to hide YT video buffer and keep only the player and the sound. Useful along with https://unhook.app/ and https://github.com/domdomegg/hideytthumbnails-extension and
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name YouTube Channel Video Buffer Hider | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author You | |
// @match https://www.youtube.com/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com | |
// @grant none | |
// ==/UserScript== | |
const allowedChannels = [ | |
"dreamscape","CanalNostalgia","kamaitachi","Astrophysics","Inutilismo","MathCaf","CircleToonsHD","iamLucid","PortadosFundos","JamesJani" | |
] | |
const niceCss = ` | |
#movie_player > div.ytp-storyboard-framepreview { | |
opacity: 0 !important; | |
transition: none !important; | |
} | |
#movie_player > div.html5-video-container > video { | |
opacity: 0 !important; | |
transition: none !important; | |
} | |
#movie_player > div.ytp-tooltip.ytp-bottom.ytp-preview { | |
opacity: 0 !important; | |
transition: none !important; | |
} | |
#movie_player > div.ytp-chrome-bottom > div.ytp-progress-bar-container.ytp-drag > div.ytp-fine-scrubbing-container { | |
opacity: 0 !important; | |
transition: none !important; | |
} | |
#movie_player > div.ytp-storyboard-framepreview > div { | |
opacity: 0 !important; | |
transition: none !important; | |
} | |
#movie_player > div.ytp-cued-thumbnail-overlay { | |
opacity: 0 !important; | |
transition: none !important; | |
display: none !important; | |
} | |
.ytp-autonav-endscreen-upnext-thumbnail .rounded-thumbnail { | |
opacity: 0 !important; | |
transition: none !important; | |
} | |
` | |
function applyStyles(css) { | |
const head = document.head || document.getElementsByTagName('head')[0], | |
style = document.createElement('style'); | |
head.appendChild(style); | |
style.type = 'text/css'; | |
if (style.styleSheet){ | |
// This is required for IE8 and below. | |
style.styleSheet.cssText = css; | |
} else { | |
style.appendChild(document.createTextNode(css)); | |
} | |
} | |
function hideVideo() { | |
const videoElements = [ | |
document.querySelector("#movie_player > div.ytp-storyboard-framepreview > div"), | |
document.querySelector("#movie_player > div.html5-video-container > video"), | |
document.querySelector("#movie_player > div.ytp-tooltip.ytp-bottom.ytp-preview"), | |
document.querySelector("#movie_player > div.ytp-chrome-bottom > div.ytp-progress-bar-container.ytp-drag > div.ytp-fine-scrubbing-container"), | |
] | |
try { | |
for(const e of videoElements) { | |
e.style.opacity = 0 | |
} | |
} catch(e) { | |
console.log("Error on hiding YouTube video buffer: " + e) | |
} | |
try { | |
applyStyles(niceCss) | |
} catch(e) { | |
console.log("Error on apply styles to hide YouTube video buffer: " + e) | |
} | |
} | |
(function() { | |
'use strict'; | |
const url = new URL(window.location.href) | |
const isAllowed = allowedChannels.some(channel => url.search.includes(channel)) | |
if (!isAllowed) { | |
hideVideo() | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment