Skip to content

Instantly share code, notes, and snippets.

@porglezomp
Last active November 28, 2022 08:59
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 porglezomp/b69f1de646891941767950235b173672 to your computer and use it in GitHub Desktop.
Save porglezomp/b69f1de646891941767950235b173672 to your computer and use it in GitHub Desktop.
Toggle the controls on a video player for easier screenshots.
// ==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