kissarat / Hide Youtube header

// ==UserScript==
// @name         Hide Youtube header
// @namespace    http://inbisoft.com/
// @version      0.1
// @description  Hide youtube header
// @author       Taras Labiak <kissarat@gmail.com>
// @match        https://www.youtube.com/*
// @grant        none
// ==/UserScript==

let _timer_8238fe84b93e993619a68bd906fb2095 = setInterval(function () {
  const header = document.getElementById('masthead');
  if (header) {
    clearInterval(_timer_8238fe84b93e993619a68bd906fb2095);
    const div = document.createElement('div');
    div.id = 'masthead-control';
    div.addEventListener('click', function () {
      header.classList.toggle('hidden');
    });
    header.parentNode.appendChild(div);
    const style = document.createElement('style');
    style.innerHTML = `
    #masthead-control {
      position: fixed;
      top: 56px;
      right: 0;
      width: 40px;
      height: 20px;
      cursor: pointer;
    }

    #masthead-control:after {
      content: '\u2303';
      font-size: 28px;
      font-weight: 900;
      color: grey;
    }

    #masthead.hidden {
      display: none;
    }

    #masthead.hidden + #masthead-control {
      top: 0;
    }

    #masthead.hidden + #masthead-control:after {
      content: '\u2304';
    }
  `;
    document.head.appendChild(style);
  }
}, 300);