Greasy Fork

MZ - WLeague Redirect

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

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

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

(function () {
  'use strict';

  const modifyLinks = () => {
    const rows = document.querySelectorAll('.nice_table tbody tr');

    if (!rows.length) {
      setTimeout(modifyLinks, 100);
      return;
    }

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

  modifyLinks();
})();