Skip to content

Instantly share code, notes, and snippets.

@piousdeer
Last active August 24, 2020 17:49
Show Gist options
  • Save piousdeer/6161edfae0e6c34fb8b0b76f35b5807c to your computer and use it in GitHub Desktop.
Save piousdeer/6161edfae0e6c34fb8b0b76f35b5807c to your computer and use it in GitHub Desktop.
Force fullscreen UI on sites like YouTube without actually making your browser window fullscreen
let fullscreenElement;
Object.defineProperty(document, "fullscreenElement", {
get() {
return fullscreenElement;
},
set(value) {
fullscreenElement = value;
},
});
Element.prototype.requestFullscreen = async function () {
document.fullscreenElement = this;
document.dispatchEvent(new Event("fullscreenchange"));
};
document.exitFullscreen = () => {
document.fullscreenElement = null;
document.dispatchEvent(new Event("fullscreenchange"));
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment