Advertisement
Guest User

Zen Mode

a guest
Jan 16th, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 4.38 KB | None | 0 0
  1. // ==UserScript==
  2. // @name         Old zen
  3. // @namespace    http://tampermonkey.net/
  4. // @version      0.3
  5. // @description  Partially restore the old zen mode
  6. // @match        https://*.lichess.org/*
  7. // @require      https://code.jquery.com/jquery-3.2.1.min.js
  8. // ==/UserScript==
  9.  
  10. $(document).ready(function zenify() {
  11.     'use strict';
  12.     var zen = true;
  13.     if ($('.control.icons').length) {
  14.         if (zen) {
  15.             $('.board_left')[0].style.visibility = 'hidden';
  16.             $('.underboard > .center')[0].style.visibility = 'hidden';
  17.             $('.username')[0].style.display = 'none';
  18.             $('.username')[1].style.display = 'none';
  19.             $('.replay')[0].style.display = 'none';
  20.             $('#top').children().each(function() {this.style.visibility = 'hidden';});
  21.             $('#friend_box').children().each(function() {this.style.visibility = 'hidden';});
  22.             $('#friend_box')[0].style.opacity = 0;
  23.         }
  24.  
  25.         $(document).bind("keypress", function (e) {
  26.             console.log(e);
  27.             if (e.key == "x") {
  28.                 zen = !zen;
  29.                 if (zen) {
  30.                     $('.board_left')[0].style.visibility = 'hidden';
  31.                     $('.underboard > .center')[0].style.visibility = 'hidden';
  32.                     $('.username')[0].style.display = 'none';
  33.                     $('.username')[1].style.display = 'none';
  34.                     $('.replay')[0].style.display = 'none';
  35.                     $('#top').children().each(function() {this.style.visibility = 'hidden';});
  36.                     $('#friend_box').children().each(function() {this.style.visibility = 'hidden';});
  37.                     $('#friend_box')[0].style.opacity = 0;
  38.                 } else {
  39.                     $('.board_left')[0].style.visibility = 'visible';
  40.                     $('.underboard > .center')[0].style.visibility = 'visible';
  41.                     $('.username')[0].style.display = 'flex';
  42.                     $('.username')[1].style.display = 'flex';
  43.                     $('.replay')[0].style.display = 'block';
  44.                     $('#top').children().each(function() {this.style.visibility = 'visible';});
  45.                     $('#friend_box').children().each(function() {this.style.visibility = 'visible';});
  46.                     $('#friend_box')[0].style.opacity = 1;
  47.                 }
  48.             }
  49.         });
  50.  
  51.         //Left side bar
  52.         $('#site_header').bind('mouseenter', function(e) {
  53.             $('.board_left')[0].style.visibility = 'visible';
  54.         });
  55.         $('#site_header').bind('mouseleave', function(e) {
  56.             $('.board_left')[0].style.visibility = zen ? 'hidden' : 'visible';
  57.         });
  58.  
  59.         //Player names and move history
  60.         $('.lichess_ground').bind('mouseenter', function(e) {
  61.             $('.username')[0].style.display = 'flex';
  62.             $('.username')[1].style.display = 'flex';
  63.             $('.replay')[0].style.display = 'block';
  64.         });
  65.         $('.lichess_ground').bind('mouseleave', function(e) {
  66.             $('.username')[0].style.display = zen ? 'none' : 'flex';
  67.             $('.username')[1].style.display = zen ? 'none' : 'flex';
  68.             $('.replay')[0].style.display = zen ? 'none' : 'block';
  69.         });
  70.  
  71.         //Crosstable
  72.         $('.underboard').bind('mouseenter', function(e) {
  73.             $('.underboard > .center')[0].style.visibility = 'visible';
  74.         });
  75.         $('.underboard').bind('mouseleave', function(e) {
  76.             $('.underboard > .center')[0].style.visibility = zen ? 'hidden' : 'visible';
  77.         });
  78.  
  79.         //Nav bar
  80.         $('#top').bind('mouseenter', function(e) {
  81.             $('#top').children().each(function() {this.style.visibility = 'visible';});
  82.         });
  83.         $('#top').bind('mouseleave', function(e) {
  84.             $('#top').children().each(function() {this.style.visibility = zen ? 'hidden' : 'visible';});
  85.         });
  86.  
  87.         //Loneliness Indicator
  88.         $('#friend_box').bind('mouseenter', function(e) {
  89.             $('#friend_box').children().each(function() {this.style.visibility = 'visible';});
  90.             $('#friend_box')[0].style.opacity = 1;
  91.         });
  92.         $('#friend_box').bind('mouseleave', function(e) {
  93.             $('#friend_box').children().each(function() {this.style.visibility = zen ? 'hidden' : 'visible';});
  94.             $('#friend_box')[0].style.opacity = zen ? 0 : 1;
  95.         });
  96.     }
  97. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement