Friends Average Score - MAL

Show all your friends weighted score for an entry.

安装此脚本?
作者推荐脚本

您可能也喜欢White Background - MAL

安装此脚本
  1. // ==UserScript==
  2. // @name Friends Average Score - MAL
  3. // @namespace https://gf.qytechs.cn/en/users/670188-hacker09?sort=daily_installs
  4. // @version 10
  5. // @description Show all your friends weighted score for an entry.
  6. // @author hacker09
  7. // @include /^https:\/\/myanimelist\.net\/(anime|manga)(id=)?(\.php\?id=)?\/?\d+\/?(?!.*\/).*(\?q=.*&cat=anime|manga)?$/
  8. // @icon https://t3.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=http://myanimelist.net&size=64
  9. // @run-at document-end
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (async function() {
  14. 'use strict';
  15. document.querySelector("div.fl-l.score").style.cursor = 'pointer'; //Make the score look like it's clickable
  16. document.querySelector("div.fl-l.score").onclick = async function GetScores() { //Creates a new function to run when the mouse is hovering the page
  17. var Average; //Global Variable
  18. var array = []; //Create a new array
  19. var nextpagenum = 0; //Create a variable to hold the page number
  20. const increaseby = 75; //Create a variable to Increase the list page number
  21.  
  22. while (true) { //Fetch until there's no next page
  23. const response = await fetch(document.querySelector("a[href*='stats']").href.split('?')[0] + '?show=' + nextpagenum); //Fetch
  24. const html = await response.text(); //Gets the fetch response
  25. const newDocument = new DOMParser().parseFromString(html, 'text/html'); //Parses the fetch response
  26. nextpagenum += increaseby; //Increase the next page number
  27. newDocument.querySelectorAll("table.table-recently-updated > tbody > tr > td:nth-child(2)").forEach(async function(el) { //For each friend score
  28. if (el.innerText.match(/\d+/) !== null) //If the score is not = -
  29. { //Start the if condition
  30. array.push(parseInt(el.innerText.match(/\d+/)[0])); //Add each score to an array
  31. var ScoresTotal = array.filter(Boolean).map(i => Number(i)).reduce((a, b) => a + b); //Sum all scores
  32. Average = (ScoresTotal / array.length).toFixed(2); //Divide all scores by total amount of scores and convert the average to show numbers only up to 2 decimal places
  33. } //Finishes the if condition
  34. }); //Finishes the for each loop
  35. document.querySelector("div.fl-l.score").title = 'Average based on 0 Friend scores.'; //Show the amount of friends friends score
  36. if (response.status === 404) { //If the next page does not exist
  37. if (Average !== undefined) //If the Average is not = undefined
  38. { //Start the if condition
  39. document.querySelector("div.fl-l.score").dataset.title += '(' + Average + ')'; //Show the friends entry average
  40. document.querySelector("div.fl-l.score").title = 'Average based on ' + array.length + ' Friend scores.'; //Show the amount of friends friends score
  41. } //Finishes the if condition
  42. return; //End the fetching loop
  43. } //Finishes the if condition
  44. await new Promise(resolve => setTimeout(resolve, 600)); //Wait 600 ms to fetch the next page
  45. } //Finishes the while condition
  46. }; //Finishes the onmousemove event listener
  47. })();

QingJ © 2025

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