MZ - League Redirect

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

目前為 2024-12-22 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name          MZ - League Redirect
// @namespace     douglaskampl
// @version       1.5
// @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 updateLinks = () => {
    const leagueRows = document.querySelectorAll('.nice_table tbody tr');

    if (!leagueRows.length) {
      setTimeout(updateLinks, 100);
      return;
    }

    for (const row of leagueRows) {
      const leagueLink = row.querySelector('a[href^="/?p=league&type="]');
      if (leagueLink) {
        const teamIdMatch = leagueLink.href.match(/tid=(\d+)/);
        if (teamIdMatch) {
          const teamPageUrl = `https://www.managerzone.com/?p=team&tid=${teamIdMatch[1]}`;
          leagueLink.href = teamPageUrl;
        }
      }
    }
  };

  updateLinks();
})();