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 http://code.jquery.com/jquery-3.4.1.min.js
  10. // ==/UserScript==
  11.  
  12. /* globals jQuery */
  13.  
  14. (function() {
  15. 'use strict';
  16. jQuery.noConflict();
  17.  
  18. function addGlobalStyle(css) {
  19. var head, style;
  20. head = document.getElementsByTagName('head')[0];
  21. if (!head) { return; }
  22. style = document.createElement('style');
  23. style.type = 'text/css';
  24. style.innerHTML = css;
  25. head.appendChild(style);
  26. }
  27. function addExternalScript(js) {
  28. var head, script;
  29. head = document.getElementsByTagName('head')[0];
  30. if (!head) { return; }
  31. script = document.createElement('script');
  32. script.type = 'text/javascript';
  33. script.innerHTML = js;
  34. head.appendChild(script);
  35. }
  36.  
  37. addGlobalStyle('.popUpChat {display: none}');
  38. //addGlobalStyle('#header {display: none}');
  39.  
  40. var hideTimer;
  41. var showTimer = null;
  42. // Start after page loaded 3s
  43. setTimeout(function() {
  44. var header = jQuery('#header');
  45. var tickerBar = jQuery('.tickerBar');
  46. if (header && tickerBar) {
  47. // Hide it first time
  48. hideTimer = setTimeout(function() {
  49. jQuery(header).hide();
  50. }, 2000);
  51. // Show it
  52. jQuery(tickerBar).mouseover(function() {
  53. if (hideTimer) clearTimeout(hideTimer);
  54. if (!showTimer) {
  55. showTimer = setTimeout(function() {
  56. if (showTimer) {
  57. showTimer = null;
  58. jQuery(header).show();
  59. }
  60. }, 500);
  61. }
  62. });
  63. // Hide after 1s moving out
  64. jQuery(tickerBar).mouseout(function() {
  65. if (hideTimer) clearTimeout(hideTimer);
  66. if (showTimer) {
  67. clearTimeout(showTimer);
  68. showTimer = null;
  69. }
  70. hideTimer = setTimeout(function() {
  71. jQuery(header).hide();
  72. }, 2000);
  73. });
  74. /*
  75. jQuery(header).mouseenter(function() {
  76. if (hideTimer) clearTimeout(hideTimer);
  77. jQuery(header).show();
  78. });
  79. // Hide after 1s moving out
  80. jQuery(header).mouseout(function() {
  81. hideTimer = setTimeout(function() {
  82. jQuery(header).hide();
  83. }, 1000);
  84. });
  85. */
  86. }
  87. }, 3000);
  88. })();