BitMEX Header Auto-hide

Auto hide BitMEX header for bigger view. Hover mouse to show back the header

当前为 2019-09-04 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name BitMEX Header Auto-hide
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Auto hide BitMEX header for bigger view. Hover mouse to show back the header
  6. // @author Nobakab
  7. // @match https://www.bitmex.com/*
  8. // @grant none
  9. // @require https://code.jquery.com/jquery-3.3.1.min.js
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. function addGlobalStyle(css) {
  16. var head, style;
  17. head = document.getElementsByTagName('head')[0];
  18. if (!head) { return; }
  19. style = document.createElement('style');
  20. style.type = 'text/css';
  21. style.innerHTML = css;
  22. head.appendChild(style);
  23. }
  24. function addExternalScript(js) {
  25. var head, script;
  26. head = document.getElementsByTagName('head')[0];
  27. if (!head) { return; }
  28. script = document.createElement('script');
  29. script.type = 'text/javascript';
  30. script.innerHTML = js;
  31. head.appendChild(script);
  32. }
  33.  
  34. addGlobalStyle('.popUpChat {display: none}');
  35. //addGlobalStyle('#header {display: none}');
  36.  
  37. var hideTimer;
  38. var showTimer = null;
  39. // Start after page loaded 3s
  40. setTimeout(function() {
  41. var header = $('#header');
  42. var tickerBar = $('.tickerBar');
  43. if (header && tickerBar) {
  44. // Hide it first time
  45. hideTimer = setTimeout(function() {
  46. $(header).hide();
  47. }, 2000);
  48. // Show it
  49. $(tickerBar).mouseover(function() {
  50. if (hideTimer) clearTimeout(hideTimer);
  51. if (!showTimer) {
  52. showTimer = setTimeout(function() {
  53. if (showTimer) {
  54. showTimer = null;
  55. $(header).show();
  56. }
  57. }, 500);
  58. }
  59. });
  60. // Hide after 1s moving out
  61. $(tickerBar).mouseout(function() {
  62. if (hideTimer) clearTimeout(hideTimer);
  63. if (showTimer) {
  64. clearTimeout(showTimer);
  65. showTimer = null;
  66. }
  67. hideTimer = setTimeout(function() {
  68. $(header).hide();
  69. }, 2000);
  70. });
  71. /*
  72. $(header).mouseenter(function() {
  73. if (hideTimer) clearTimeout(hideTimer);
  74. $(header).show();
  75. });
  76. // Hide after 1s moving out
  77. $(header).mouseout(function() {
  78. hideTimer = setTimeout(function() {
  79. $(header).hide();
  80. }, 1000);
  81. });
  82. */
  83. }
  84. }, 3000);
  85. })();