Skip to content

Instantly share code, notes, and snippets.

@trapier
Created February 10, 2024 20:27
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 trapier/b0d04aa3fd04a19bb6f02890ab0eb95f to your computer and use it in GitHub Desktop.
Save trapier/b0d04aa3fd04a19bb6f02890ab0eb95f to your computer and use it in GitHub Desktop.
firefox mobile triple tap for fullscreen
// ==UserScript==
// @name triple touch to fullscreen
// @namespace http://tampermonkey.net/
// @version 0.1
// @description triple touch to fullscreen for for mobile
// @author trapier
// @run-at document-end
// @match http(s)?://*/*
// @include http://*
// @include https://*
// @icon https://www.google.com/s2/favicons?sz=64&domain=tampermonkey.net
// @grant none
// @license MIT
// ==/UserScript==
// copy-pasted from https://greasyfork.org/en/scripts/439695-long-touch-to-fullscreen
// notch support (viewport-fit=cover) from
// - https://github.com/mozilla-mobile/fenix/issues/4149#issuecomment-610432974
// - https://stackoverflow.com/questions/2568760/is-it-possible-to-use-javascript-to-change-the-meta-tags-of-the-page/66057831#66057831
(function() {
'use strict';
let time_list = []
function fullscreen() {
// console.log('touch end')
time_list = [...time_list.slice(-2) , +new Date()]
const [a, b, c] = time_list
if (a && c && c - a < 1500) {
let metaViewport = document.head.children.viewport
if (metaViewport == null) {
metaViewport = document.createElement('meta')
metaViewport.name = 'viewport'
document.head.append(metaViewport)
}
metaViewport.content = 'width=device-width, initial-scale=1.0, viewport-fit=cover'
document.documentElement.requestFullscreen()
}
}
document.body.addEventListener('touchend', fullscreen )
document.body.addEventListener('click', fullscreen )
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment