Last active
December 6, 2021 05:25
-
-
Save Tokenyet/e1389eb2620031dc0885b2857071d904 to your computer and use it in GitHub Desktop.
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
// ==UserScript== | |
// @name Youtube Control Visible Switch | |
// @namespace http://tampermonkey.net/ | |
// @version 0.2 | |
// @description Use ctrl to hide and show ui! Also shift works, but without subtitle! | |
// @author You | |
// @match https://*.youtube.com/* | |
// @icon https://www.gstatic.com/youtube/img/branding/youtubelogo/svg/youtubelogo.svg | |
// @license https://creativecommons.org/licenses/by-sa/4.0/ | |
// @homepage https://gist.github.com/Tokenyet/e1389eb2620031dc0885b2857071d904 | |
// @contributionURL https://gist.github.com/Tokenyet/e1389eb2620031dc0885b2857071d904 | |
// @updateURL https://gist.github.com/Tokenyet/e1389eb2620031dc0885b2857071d904 | |
// @downloadURL https://gist.github.com/Tokenyet/e1389eb2620031dc0885b2857071d904 | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
var keyMap = []; | |
var show = true; | |
const hides = ['ytp-gradient-top','ytp-chrome-top','ytp-caption-window-container','ytp-chrome-bottom','ytp-gradient-bottom']; | |
const subtitle = 'ytp-caption-window-container'; | |
window.addEventListener('keydown', (e)=>{ | |
const ctrlKey = 17, | |
shiftKey = 16; | |
// cmdKey = 91; | |
// uKey = 85; | |
// bKey = 66; | |
if(!keyMap.includes(e.keyCode)){ | |
keyMap.push(e.keyCode); | |
} | |
if(keyMap.includes(ctrlKey) || keyMap.includes(shiftKey)) { | |
show = !show; | |
const skipSubtitle = keyMap.includes(shiftKey); | |
for(let i = 0; i < hides.length; i++) { | |
if(skipSubtitle && hides[i] === subtitle) continue; | |
const elements = document.getElementsByClassName(hides[i]); | |
for(let j = 0; j < elements.length; j++) { | |
elements[j].style.opacity = show ? null : 0; | |
} | |
} | |
} | |
}) | |
window.addEventListener('keyup', (e)=>{ | |
if(keyMap.includes(e.keyCode)){ | |
keyMap.splice(keyMap.indexOf(e.keyCode), 1); | |
} | |
}) | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment