Skip to content

Instantly share code, notes, and snippets.

@kairusds
Created August 5, 2021 23:11
Show Gist options
  • Save kairusds/ead7375c9f488e26f76461cf418cd16e to your computer and use it in GitHub Desktop.
Save kairusds/ead7375c9f488e26f76461cf418cd16e to your computer and use it in GitHub Desktop.
Fix fullscreen orientation on Chrome mobile
// ==UserScript==
// @name Fullscreen Landscape
// @namespace https://kairusds.js.org/
// @version 0.1
// @description Fix Chrome mobile fullscreen orientation
// @author kairusds
// @match http://*/*
// @match https://*/*
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant none
// ==/UserScript==
(function() {
"use strict";
document.addEventListener('fullscreenchange', (event) => {
if(!document.fullscreenElement){
screen.orientation.unlock();
}
screen.orientation.lock("landscape-primary");
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment