SergejVolkov / Shiki Scroll Menu

// ==UserScript==
// @name         Shiki Scroll Menu
// @namespace    http://shikimori.one/
// @version      1.1
// @description  Hides menu on shikimori.one based on page scroll
// @author       SergejVolkov
// @match        http://shikimori.one/*
// @match        https://shikimori.one/*
// @license      MIT
// @grant        none
// ==/UserScript==

var prevScrollpos = window.pageYOffset;
var menuOffset = "-" + getComputedStyle(document.querySelector(".l-top_menu-v2")).height;

window.onscroll = function () {
  var currentScrollPos = window.pageYOffset;
  if (prevScrollpos - currentScrollPos > 5) {
    document.querySelector(".l-top_menu-v2").style.top = "0";
  }
  else if (prevScrollpos - currentScrollPos < -5) {
    document.querySelector(".l-top_menu-v2").style.top = menuOffset;
  }
  prevScrollpos = currentScrollPos;
}