Skip to content

Instantly share code, notes, and snippets.

@Shilo
Last active July 13, 2018 09:04
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 Shilo/3388cd9ea9e94eac7e1823364b39c87f to your computer and use it in GitHub Desktop.
Save Shilo/3388cd9ea9e94eac7e1823364b39c87f to your computer and use it in GitHub Desktop.
YouTube.com fullscreen injection to put the video in fullscreen. (Scrubber disabled due to issues with the fullscreen mode)
var sizeButton = document.getElementsByClassName("ytp-size-button")[0];
var sizeButtonTitle = sizeButton.getAttribute('title');
var shouldDefaultView = sizeButtonTitle != null && sizeButtonTitle.toLowerCase() == 'default view';
if (shouldDefaultView) {
sizeButton.click();
}
setTimeout(function() {
var playButton = document.getElementsByClassName("ytp-play-button")[0];
var playButtonLabel = playButton.getAttribute('aria-label');
var shouldPlay = playButtonLabel != null && playButtonLabel.toLowerCase() == 'pause';
var moviePlayer = document.getElementById('movie_player');
document.body.appendChild(moviePlayer);
var elements = document.body.children;
for (var i=elements.length-1; i>=0; i--)
{
var element = elements[i];
if (element != moviePlayer) {
element.parentNode.removeChild(element);
}
}
(function() {
var css = `
body, html {
height: 100% !important;
}
#movie_player, .html5-video-container, .video-stream {
width: 100% !important;
height: 100% !important;
}
.ytp-chrome-bottom {
width: 100% !important;
left: 0px !important;
}
.ytp-progress-bar-container {
pointer-events: none;
}
`;
var cssDiv = document.createElement('div'); cssDiv.innerHTML = '&shy;<style>' + css + '</style>'; document.body.appendChild(cssDiv.childNodes[1]);
})();
if (shouldPlay) {
setTimeout(function() { playButton.click(); }, 100);
}
}, 100);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment