Affinity to You

Shows the "Affinity to You" that all users who have commented on any topic on MAL have with you!

目前為 2021-03-25 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Affinity to You
// @namespace    AffinityShow
// @version      0.3
// @description  Shows the "Affinity to You" that all users who have commented on any topic on MAL have with you!
// @author       hacker09
// @match        https://myanimelist.net/forum/?topicid=*
// @icon         https://www.google.com/s2/favicons?domain=myanimelist.net
// @run-at       document-end
// @grant        none
// ==/UserScript==

(function() {
  'use strict';
  var mUserParsedList = new Map(); //Creates a new map to later add all non-dup mal usernames on the page
  var sUsername = document.querySelector("a.header-profile-link").innerText; //Gets the script username

  mUserParsedList.set(sUsername, {}); //Add the script username to the map,so that the script won't fetch the script user profile
  mUserParsedList.set('removed-user', {}); //Add the 'removed-user' username to the map,so that the script won't fetch the non existent user profile
  document.querySelectorAll('td.forum_boardrow2 > div > div > a > strong').forEach(async function(UserName) { //Execute this function for each username on the topic page
    if (!mUserParsedList.has(UserName.innerText)) { //If the username isn't already on the map
      mUserParsedList.set(UserName.innerText, {}); //Add the username on the map

      const html = await (await fetch('https://myanimelist.net/profile/' + UserName.innerText)).text(); //Gets the fetch response
      var newDocument = new DOMParser().parseFromString(html, 'text/html'); //Parses the fetch response
      var AffinityPercentage = newDocument.querySelector("div.bar-outer.anime").innerText.replace('0%', '').trim().replace('--', '-').trim(); //Gets the affinity %
      window.jQuery('td.forum_boardrow2 > div > div > a > strong:contains("' + UserName.innerText + '")').parent().parent().parent().after('Affinity to You ' + AffinityPercentage); //Add the affinity % to every topic reply that matches the fetched profile username
    } //Finishes the if condition
  }) //Finishes the async function
})();

QingJ © 2025

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