导航栏在看顺序调整

恢复在看为原来的第三位,和收藏一致,而非现在的第一位

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         导航栏在看顺序调整
// @namespace    http://tampermonkey.net/
// @version      0.0.1
// @description  恢复在看为原来的第三位,和收藏一致,而非现在的第一位
// @author       默沨
// @match        https://bangumi.tv/*
// @match        https://bgm.tv/*
// @match        https://chii.in/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function () {
  "use strict";

  function reorganizeNavigationLinks() {
    const linkConfigs = [
      {
        type: 'anime',
        rootText: '我看',
        targetLink: '/list/.*/do',
        afterLink: '/list/.*/collect'
      },
      {
        type: 'book',
        rootText: '我读',
        targetLink: '/list/.*/do',
        afterLink: '/list/.*/collect'
      },
      {
        type: 'music',
        rootText: '我听',
        targetLink: '/list/.*/do',
        afterLink: '/list/.*/collect'
      },
      {
        type: 'game',
        rootText: '我玩',
        targetLink: '/list/.*/do',
        afterLink: '/list/.*/collect'
      },
      {
        type: 'real',
        rootText: '我看',
        targetLink: '/list/.*/do',
        afterLink: '/list/.*/collect'
      }
    ];

    const exploreUls = document.querySelectorAll('ul.explore.clearit');

    exploreUls.forEach(exploreUl => {
      linkConfigs.forEach(config => {
        const groupLi = Array.from(exploreUl.querySelectorAll('li.group')).find(li => {
          const rootSpan = li.querySelector('span.root');
          return rootSpan && rootSpan.textContent.trim() === config.rootText;
        });

        if (groupLi) {
          const allLinks = groupLi.querySelectorAll('a.nav');
          let targetLink, afterLink;

          allLinks.forEach(link => {
            const href = link.getAttribute('href');
            if (href && href.match(new RegExp(config.targetLink.replace('.*', '[^/]+')))) {
              targetLink = link;
            }
            if (href && href.match(new RegExp(config.afterLink.replace('.*', '[^/]+')))) {
              afterLink = link;
            }
          });

          if (targetLink && afterLink) {
            targetLink.remove();
            afterLink.after(targetLink);
          }
        }
      });
    });
  }

  reorganizeNavigationLinks();
})();