全屏隐藏掘金头部

全屏隐藏掘金头部,方便文章阅读

// ==UserScript==
// @name         全屏隐藏掘金头部
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  全屏隐藏掘金头部,方便文章阅读
// @author       xnic
// @match        https://juejin.cn/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    let isFull = () => (window.outerWidth === screen.availWidth && window.outerHeight === screen.availHeight)

    let hideOrShow = () => { isFull() ? document.querySelector('.main-header').style.display = 'none' : document.querySelector('.main-header').style.display = 'block' }


    setTimeout(()=> hideOrShow(), 300)

    //监听退出全屏事件
    window.onresize = function() {
         setTimeout(()=> hideOrShow(), 1000)
    }


    // Your code here...
})();