Anime/Manga Favorited Status %

See the % of people that have watched and favorited an anime/manga in the entry status page.

目前为 2021-11-19 提交的版本。查看 最新版本

// ==UserScript==
// @name         Anime/Manga Favorited Status %
// @namespace    FavoriteStatus%
// @version      0.9
// @description  See the % of people that have watched and favorited an anime/manga in the entry status page.
// @author       hacker09
// @include      /^https:\/\/myanimelist\.net\/((anime|manga)(id=)?(\.php\?id=)?)(\/)?([\d]+)(\/stats\/)?/
// @icon         https://www.google.com/s2/favicons?domain=myanimelist.net
// @run-at       document-end
// @grant        none
// ==/UserScript==

(async function() {
  'use strict';
  if (document.body.innerText.match('Status: Not yet aired') === null) //If the opened entry is airing or finished airing
  { //Starts the if condition
    const response1 = await (await fetch('https://api.jikan.moe/v3/' + location.href.split('/')[3] + '/' + location.href.match(/\d+/)[0] + '/stats')).json(); //Get Stats
    var TotalUsers = response1.total; //Save the TotalUsers to variable
    var PTWR = response1.plan_to_watch; //Save the PTW to variable

    if (location.href.split('/')[3] === 'manga') //If the opened entry is manga
    { //Starts the if condition
      PTWR = response1.plan_to_read; //Save the PTR to variable
    } //Finishes the if condition

    var Information = [...[...document.querySelectorAll("h2")].find(h2 => h2.textContent === "Information").parentNode.querySelectorAll("div")]; //Save the Information stats to variable
    var Favorites = parseFloat(Information.find(info => info.innerText.includes('Favorites: ')).innerText.match(/(\d+,)?(\d+,)?\d+/)[0].replaceAll(',', '')); //Save the Favs to variable
    Information.find(info => info.innerText.includes("Favorites:")).innerText = 'Favorites: ' + Favorites.toLocaleString() + ' (' + ((Favorites) / ((TotalUsers) - (PTWR))).toLocaleString("en", { //Do the math and show the result
      style: 'percent', //Show the result as %
      minimumFractionDigits: 2 //Show the % with 2 decimals
    }) + ')'; //Show the total number after the Favorites: number
    Information.find(info => info.innerText.includes("Favorites:")).title = `( ${Favorites} )/(( ${TotalUsers} ) - ( ${PTWR} ))`; //Show the math on mouse hover

    if (location.href.match(/^https:\/\/myanimelist\.net\/(anime|manga)\/[\d]+\/.*\/stats/) !== null) //If the user is on the stats page
    { //Starts the if condition
      var SummaryStats = [...[...document.querySelectorAll("h2")].find(h2 => h2.textContent === "Summary Stats").parentNode.querySelectorAll("span")]; //Save the summary stats to variable
      SummaryStats.find(info => info.innerText.includes("Total:")).innerText = Information.find(info => info.innerText.includes("Favorites:")).innerText + '\nTotal: '
      SummaryStats.find(info => info.innerText.includes("Total:")).title = `( ${Favorites} )/(( ${TotalUsers} ) - ( ${PTWR} ))`; //Show the math on mouse hover
    } //Finishes the if condition

    if (location.href.match('stats') === null) //If the user is not on the stats page
    { //Starts the if condition
      document.querySelector("div.detail-characters-list.clearfix").querySelectorAll('div.spaceit_pad').forEach(async function(el) { //For each character on the page
        const response2 = await fetch('https://api.allorigins.win/raw?url=https://api.jikan.moe/v3/character/' + el.parentNode.querySelector('a').href.match(/\d+/)[0]);
        const json = await response2.json(); //Gets the fetch response; //Gets the fetch response

        el.innerText += '\nFavorited: ' + ((json.member_favorites) / ((TotalUsers) - (PTWR))).toLocaleString("en", { //Do the math and show the result
          style: 'percent', //Show the result as %
          minimumFractionDigits: 2 //Show the % with 2 decimals
        }); //Add a break line and show the % below the text
        el.title += `( ${json.member_favorites} )/(( ${TotalUsers} ) - ( ${PTWR} ))`; //Show the math on mouse hover
      }); //Finishes the for each condition
    } //Finishes the if condition
  } //Finishes the if condition
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址