Toggle distracting elements on and off
目前為
// ==UserScript==
// @name Jstris Toggle Clean Sprint
// @version 1.7
// @description Toggle distracting elements on and off
// @author Garbaz
// @match https://jstris.jezevec10.com/*
// @grant none
// @namespace https://greasyfork.org/users/683917
// ==/UserScript==
(function() {
const STATS_TAB_MENU = true;
var active = false;
var navbar = document.querySelector(".navbar");
var buttonsBox = document.querySelector("#buttonsBox");
var gstats = document.querySelector("#gstats");
var game = document.querySelector("#main");
var players = document.querySelector(".players");
var gameFrame = document.querySelector("#gameFrame");
window.addEventListener('keydown', function(e) {
if(e.code == "Backquote") {
if(!active) {
active = true;
navbar.style.display = "none";
players.style.display = "none";
buttonsBox.style.display = "none";
gstats.style.padding = "30px 0";
game.style.position = 'fixed';
game.style.left = '50%';
game.style.top = '50%';
game.style.transform = 'translate(-50%, -50%)';
game.style.margin = '0';
gameFrame.style.width = '0px';
if(STATS_TAB_MENU) {
gstats.style.display = 'none';
gstats.style.position = 'fixed';
gstats.style.left = '50%';
gstats.style.top = '50%';
gstats.style.transform = 'translate(-50%, -50%)';
gstats.style.margin = '0 0 0 -23px';
gstats.style["z-index"] = '100';
gstats.style.border = 'double white';
gstats.style.background = 'black';
}
} else {
active = false;
navbar.style.display = '';
players.style.display = '';
buttonsBox.style.display = '';
gstats.style.padding = '';
game.style.position = '';
game.style.left = '';
game.style.top = '';
game.style.transform = '';
gameFrame.style.width = '950px';
if(STATS_TAB_MENU) {
gstats.style.display = '';
gstats.style.position = '';
gstats.style.left = '';
gstats.style.top = '';
gstats.style.transform = '';
gstats.style.margin = '';
gstats.style["z-index"] = '';
gstats.style.border = '';
gstats.style.background = '';
}
}
e.preventDefault();
} else if (e.code == "Tab") {
if(active && STATS_TAB_MENU) {
gstats.style.display = '';
e.preventDefault();
}
}
},true);
window.addEventListener('keyup', function(e) {
if (e.code == "Tab") {
if(active && STATS_TAB_MENU) {
gstats.style.display = "none";
e.preventDefault();
}
}
}, true);
})();