Created
July 3, 2015 02:42
-
-
Save tomhodgins/0f500ca635c8786f4764 to your computer and use it in GitHub Desktop.
Browser Script: Youtube Cinema Mode. Adds an invisible checkbox to the top-right corner of youtube.com that hides everything but the video. You can add this code to extstyler.js in Extstyler to use this script in Chrome https://github.com/tomhodgins/extstyler
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
// Run code on Youtube.com | |
/* Youtube Cinema Mode */ | |
if (document.getElementsByTagName('html')[0].classList.contains('youtube')) { | |
var input = document.createElement('input'), | |
inputCSS = document.createElement('style'), | |
inputJS = document.createElement('script'); | |
input.id = 'ytCM'; | |
input.setAttribute('type','checkbox'); | |
input.setAttribute('onclick','cinemaMode()'); | |
if (localStorage.ytCM == 'true') { | |
input.setAttribute('checked', 'yes'); | |
} | |
inputCSS.innerHTML = '#ytCM{position:fixed;top:0;right:0;z-index:20000000000;opacity:0;transition: all .1s ease-in-out}\ | |
#ytCM:hover{opacity:1}\ | |
#ytCM:checked ~ #body-container #yt-masthead-container,#ytCM:checked ~ #body-container #masthead-positioner-height-offset,#a11y-announcements-container,#ytCM:checked ~ #body-container #watch7-container,#ytCM:checked ~ #footer-container {display:none}\ | |
#ytCM:checked ~ #body-container {background: black}'; | |
inputJS.innerHTML = 'function cinemaMode() {\ | |
if (localStorage.ytCM == "true") {localStorage.ytCM = "false"}\ | |
else {localStorage.ytCM = "true"}\ | |
}'; | |
document.getElementsByTagName('body')[0].insertBefore(input, document.getElementById('body-container')); | |
document.getElementsByTagName('body')[0].insertBefore(inputCSS, document.getElementById('body-container')); | |
document.getElementsByTagName('body')[0].insertBefore(inputJS, document.getElementById('body-container')); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment