Skip to content

Instantly share code, notes, and snippets.

@katopz
Last active August 7, 2022 01:37
Show Gist options
  • Save katopz/06a2958ad7591de0ed3044038009a32c to your computer and use it in GitHub Desktop.
Save katopz/06a2958ad7591de0ed3044038009a32c to your computer and use it in GitHub Desktop.
keep youtube at hi resolution
// https://gist.github.com/adisib/1e6b429b9bb630fceb170f3fa77c57a3
let ytPlayer = document.getElementById("movie_player") || document.getElementsByClassName("html5-video-player")[0];
let quality = ytPlayer.getAvailableQualityLevels()[0];
ytPlayer.stopVideo();
ytPlayer.setPlaybackQualityRange && ytPlayer.setPlaybackQualityRange(quality)
ytPlayer.setPlaybackQuality(quality);
let storedQuality = localStorage.getItem('yt-player-quality')
if (!storedQuality || storedQuality.indexOf(quality) === -1) {
let tc = Date.now(),
te = tc + 2592000000
localStorage.setItem('yt-player-quality', '{"data":"' + targetRes + '","expiration":' + te + ',"creation":' + tc + '}')
}
ytPlayer.playVideo();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment