BitMEX Header Auto-hide

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

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         BitMEX Header Auto-hide
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Auto hide BitMEX header for bigger view. Hover mouse to show back the header
// @author       Nobakab
// @match        https://www.bitmex.com/*
// @grant        none
// @require      http://code.jquery.com/jquery-3.4.1.min.js
// ==/UserScript==

/* globals jQuery */

(function() {
    'use strict';
    jQuery.noConflict();

    function addGlobalStyle(css) {
        var head, style;
        head = document.getElementsByTagName('head')[0];
        if (!head) { return; }
        style = document.createElement('style');
        style.type = 'text/css';
        style.innerHTML = css;
        head.appendChild(style);
    }
    function addExternalScript(js) {
        var head, script;
        head = document.getElementsByTagName('head')[0];
        if (!head) { return; }
        script = document.createElement('script');
        script.type = 'text/javascript';
        script.innerHTML = js;
        head.appendChild(script);
    }

    addGlobalStyle('.popUpChat {display: none}');
    //addGlobalStyle('#header {display: none}');

    var hideTimer;
    var showTimer = null;
    // Start after page loaded 3s
    setTimeout(function() {
        var header = jQuery('#header');
        var tickerBar = jQuery('.tickerBar');
        if (header && tickerBar) {
            // Hide it first time
            hideTimer = setTimeout(function() {
                jQuery(header).hide();
            }, 2000);
            // Show it
            jQuery(tickerBar).mouseover(function() {
                if (hideTimer) clearTimeout(hideTimer);
                if (!showTimer) {
                    showTimer = setTimeout(function() {
                        if (showTimer) {
                            showTimer = null;
                            jQuery(header).show();
                        }
                    }, 500);
                }
            });
            // Hide after 1s moving out
            jQuery(tickerBar).mouseout(function() {
                if (hideTimer) clearTimeout(hideTimer);
                if (showTimer) {
                    clearTimeout(showTimer);
                    showTimer = null;
                }
                hideTimer = setTimeout(function() {
                    jQuery(header).hide();
                }, 2000);
            });
            /*
            jQuery(header).mouseenter(function() {
              if (hideTimer) clearTimeout(hideTimer);
              jQuery(header).show();
            });
            // Hide after 1s moving out
            jQuery(header).mouseout(function() {
                hideTimer = setTimeout(function() {
                    jQuery(header).hide();
                }, 1000);
            });
            */
        }
    }, 3000);
})();