njw1204 / sw maestro mypage hotfix

// ==UserScript==
// @name         sw maestro mypage hotfix
// @version      0.1
// @license      MIT
// @homepageURL  https://github.com/njw1204/sw-maestro-mypage-hotfix
// @match        http://swmaestro.org/sw/mypage/*
// @match        https://swmaestro.org/sw/mypage/*
// @grant        unsafeWindow
// ==/UserScript==

function insertCss(code) {
  const style = document.createElement("style");
  style.type = "text/css";
  style.innerHTML = code;
  document.getElementsByTagName("head")[0].appendChild(style);
}

(function() {
  "use strict";

  const hotfixClass = "swMaestroMypageHotfix";

  insertCss(`
    .mypageCalendar .category > a:not(.${hotfixClass}) {
      display: none;
    }
  `);

  unsafeWindow.search = (pageNo) => {
    const listFrm = [...document.querySelectorAll(".bbs-sch")].map(e => e.closest("#listFrm"))[0];
    listFrm.pageIndex.value = pageNo;
    listFrm.submit();
  }

  unsafeWindow.searchStat = (stat) => {
    const listFrm = [...document.querySelectorAll(".bbs-sch")].map(e => e.closest("#listFrm"))[0];
    listFrm.searchStatMentolec.value = stat;
    listFrm.pageIndex.value = '1';
    listFrm.submit();
  };

  setInterval(() => {
    const schedules = [...document.querySelectorAll(`.mypageCalendar .category > a:not(.${hotfixClass})`)];
    schedules.forEach(schedule => {
      schedule.closest(".category").querySelector(".calendarPop").style.display = "none";
      schedule.classList.add(hotfixClass);
      schedule.style.fontSize = "14px";
      schedule.style.fontWeight = "400";
      schedule.innerText = schedule.title;
      schedule.href = schedule.closest(".category").querySelector(".apply").href;
      schedule.onclick = () => {
        unsafeWindow.location.href = schedule.href;
      };
    });
  }, 200);
})();