a8212270 / 自動跳轉

// ==UserScript==
// @name         自動跳轉
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  GBF 自動跳轉選隊友
// @author       You
// @match        *://game.granbluefantasy.jp/*
// @match        *://gbf.game.mbga.jp/*
// @run-at       document-end
// @license MIT
// @copyright 2021, a8212270 (https://openuserjs.org/users/a8212270)
// @grant        GM_notification
// ==/UserScript==

(function () {
  'use strict';

  function getRandom(min, max) {
    return Math.floor(Math.random() * max) + min;
  };
  let eventOn = false
  window.addEventListener('hashchange', () => {
    let hash = location.hash
    let url = 'http://game.granbluefantasy.jp/#quest/supporter/776471/1/0/10386';
    if (/^#result(_multi)?\/\d/.test(hash)) {
      if (!eventOn) {
        eventOn = true
        $(document).ajaxSuccess(function (event, xhr, settings, data) {
          if (/\/result(multi)?\/data\/\d+/.test(settings.url)) {
            if (data.appearance) {
              //send('出HELL了')
            }
            else {
              setTimeout(function () {
                unsafeWindow.location.replace(url)
              }, getRandom(0, 300))
            }
          }
        })
      }
    }
  })
})();