Last active
July 13, 2018 09:04
-
-
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)
This file contains 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
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 = '­<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