Show favorited count - MAL (for mobile ver)

Shows favorited anime,manga,characters,people,company count like "Favorite - Anime (10)" on mobile version

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Show favorited count - MAL (for mobile ver)
// @namespace    https://myanimelist.net/profile/kyoyatempest
// @version      1.2
// @description  Shows favorited anime,manga,characters,people,company count like "Favorite - Anime (10)" on mobile version
// @author       kyoyacchi
// @match        https://myanimelist.net/profile/*
// @grant        none
// @icon         https://t3.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=https://myanimelist.net&size=64
// @run-at       document-end
// @license      gpl-3.0
// ==/UserScript==

(function() {
    'use strict';


  const headerMappings = {
        "Favorites - Anime": "anime",
        "Favorites - Manga": "manga",
        "Favorites - Characters": "character",
        "Favorites - People": "person",
        "Favorites - Companies": "company"
    };

    const headers = document.querySelectorAll(".header3");
    const sliders = document.querySelectorAll(".slider");

    const counts = {
        anime: 0,
        manga: 0,
        character: 0,
        person: 0,
        company: 0
    };

    sliders.forEach((slider) => {
        for (const key in headerMappings) {
            if (slider.classList.contains(`favorites-${headerMappings[key]}`)) {
                counts[headerMappings[key]]++;
                break;
            }
        }
    });

    headers.forEach((header) => {
        const textContent = header.textContent.trim();
        if (headerMappings.hasOwnProperty(textContent)) {
            header.textContent += ` (${counts[headerMappings[textContent]]})`;
        }
    });

})();