Greasy Fork

MZ - League/World League Redirect

Updates links on league/world league pages to actually lead to team pages when clicking teams

目前为 2024-12-26 提交的版本。查看 最新版本

// ==UserScript==
// @name          MZ - League/World League Redirect
// @namespace     douglaskampl
// @version       1.6
// @description   Updates links on league/world league pages to actually lead to team pages when clicking teams
// @author        Douglas
// @match         https://www.managerzone.com/?p=league&type=*
// @icon          https://www.google.com/s2/favicons?sz=64&domain=managerzone.com
// @grant         none
// @license       MIT
// ==/UserScript==

(function () {
  'use strict';

  const observer = new MutationObserver(() => {
    const leagueRows = document.querySelectorAll('.nice_table tbody tr');
    if (leagueRows.length) {
      leagueRows.forEach(row => {
        const link = row.querySelector('a[href^="/?p=league&type="]');
        const teamId = link?.href?.match(/tid=(\d+)/)?.[1];
        if (teamId) {
          link.href = `https://www.managerzone.com/?p=team&tid=${teamId}`;
        }
      });
      observer.disconnect();
    }
  });

  observer.observe(document.body, {
    childList: true,
    subtree: true
  });
})();