Loader

mec-itutorの誤作動防止のためにローディングを表示します

目前為 2025-11-12 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Loader
// @namespace    http://tampermonkey.net/
// @version      1.0.1
// @author       Nozom.u
// @description  mec-itutorの誤作動防止のためにローディングを表示します
// @match        *://mec-itutor.jp/*
// @grant        none
// ==/UserScript==

/* global Sys */

(function() {
  'use strict';

  function showOverlay() {
    if (document.getElementById('loadingOverlay')) return;
    const overlay = document.createElement('div');
    overlay.id = 'loadingOverlay';
    overlay.style = `
      position: fixed;
      top: 0; left: 0;
      width: 100%; height: 100%;
      background: rgba(255,255,255,0.7);
      z-index: 99999;
      display: flex;
      justify-content: center;
      align-items: center;
    `;
    // スピナー
    overlay.innerHTML = `
      <div style="
        position: relative;
        display: flex;
        flex-direction: column;
        align-items: center;
        color: #333;
        font-size: 18px;
        font-weight: bold;
      ">
        <div class="loading-spinner" style="
          width: 30px; height: 30px;
          border: 4px solid rgba(0,0,0,0.1);
          border-top: 4px solid #555;
          border-radius: 50%;
          margin-bottom: 12px;
          animation: spin 0.5s linear infinite;
        "></div>
      </div>
      <style>
        @keyframes spin {
          from { transform: rotate(0deg); }
          to { transform: rotate(360deg); }
        }
      </style>
    `;
    document.body.appendChild(overlay);
  }

  function hideOverlay() {
    const overlay = document.getElementById('loadingOverlay');
    if (overlay) overlay.remove();
  }

  // ページ読み込み完了時
  window.addEventListener('load', hideOverlay);

  // __doPostBack フック
  const originalPostBack = window.__doPostBack;
  if (typeof originalPostBack === 'function') {
    window.__doPostBack = function(eventTarget, eventArgument) {
      showOverlay();
      return originalPostBack(eventTarget, eventArgument);
    };
  }

  // ASP.NET AJAX UpdatePanel の完了イベントにも対応
  const checkManager = setInterval(() => {
    const mgr = window.Sys && Sys.WebForms && Sys.WebForms.PageRequestManager && Sys.WebForms.PageRequestManager.getInstance();
    if (mgr) {
      clearInterval(checkManager);
      mgr.add_endRequest(() => {
        hideOverlay();
      });
    }
  }, 500);
})();