Last active
November 28, 2022 08:59
-
-
Save porglezomp/b69f1de646891941767950235b173672 to your computer and use it in GitHub Desktop.
Toggle the controls on a video player for easier screenshots.
This file contains hidden or 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 Toggle Video Controls (f1) | |
// @version 1 | |
// @include https://archive.org/* | |
// @include https://www.youtube.com/* | |
// @grant none | |
// ==/UserScript== | |
// LICENSE: CC0 1.0 | |
// Comments with support for more video players are encouraged, if you want to help out | |
if (window.location.host == "archive.org") { | |
document.addEventListener("keydown", e => { | |
if (e.key == "F1") { | |
document.querySelector('.jw-controls').classList.toggle('hidden'); | |
document.querySelector('.jw-controls-backdrop').classList.toggle('hidden') | |
} | |
}); | |
} else if (window.location.host == "www.youtube.com") { | |
const styles = document.createElement("style"); | |
const className = "porglezomp--hide-video-controls"; | |
styles.innerText = ` | |
.${className} > * { display: none; } | |
.${className} > .html5-video-container, | |
.${className} > #ytp-caption-window-container { display: block; } | |
`; | |
document.body.appendChild(styles); | |
document.addEventListener("keydown", e => { | |
if (e.key == "F1") { | |
document.querySelector("#movie_player").classList.toggle(className); | |
} | |
}); | |
} | |
console.log("UserScript: Installed video control toggle"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment