macarole / hide the modal in git book

// ==UserScript==
// @name         hide the modal in git book
// @namespace    https://openuserjs.org/users/macarole
// @version      0.1
// @description  屏蔽掉该网页里面的modal(里面的广告啥的请使用ads killer等清除广告的处理)
// @copyright    2019, macarole (https://openuserjs.org/users/macarole)
// @license      MIT
// @author       You
// @include        https://webpack.wuhaolin.cn/*
// @grant        none
// ==/UserScript==

(function () {
  "use strict";

  function closeModal() {
    var $bookBody = window.document.getElementsByClassName("book-body")[0];
    var $modal = $bookBody.getElementsByClassName("gitbook-plugin-modal");
    if ($modal.length > 0) {
      $modal[0].style.visibility = "hidden";
    }
    else {
      setTimeout(() => {
        $modal[0].style.visibility = "hidden";
      });
    }
  }
  window.addEventListener("load", () => {
    closeModal();
    gitbook.events.bind("page.change", () => {
      closeModal();
    });
  });
})();