您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Adds MAL scores to animelist and sorts them if you click on the header.
// ==UserScript== // @name Tyrel_MAL_Sort_by_Score // @namespace https://greasyfork.org/de/scripts/30598-tyrel-mal-sort-by-score // @version 0.2 // @description Adds MAL scores to animelist and sorts them if you click on the header. // @author Ghost // @match https://myanimelist.net/animelist/* // @grant none // ==/UserScript== // Initialize the table header "Rank Score" $(".header-title.score").after('<th class="header-title ranking"><a href=# class="link sort">Rank Score</a></th>'); // Initialize the cells for "Rank Score" $(".data.score").each(function(index) { $(this).after('<td class="data rank"></td>'); }); $(".list-item .more-info").each(function(index) { var animeID = $(this).attr("id").replace("more-", ""); var tableRows = $(".list-item .data.rank"); var currentScoreCell = tableRows.eq(index); $.ajax({ method: "GET", url: "https://myanimelist.net/anime/"+animeID, dataType: "HTML", success: function(text) { var rankScore = text.match(/ratingValue\">\d+\.\d+/g)[0].replace('ratingValue">', ""); currentScoreCell.html(rankScore); } }); }); // Sorter $('th.header-title.ranking').click(function(){ var table = $('.list-table'); var rows = table.find('tbody tr.list-table-data').toArray().sort(comparer($(this).index())); this.asc = !this.asc; if (!this.asc){rows = rows.reverse();} for (var i = 0; i < rows.length; i++){ table.append(rows[i]); } }); function comparer(index) { return function(a, b) { var valA = getCellValue(a, index), valB = getCellValue(b, index); return $.isNumeric(valA) && $.isNumeric(valB) ? valA - valB : valA.localeCompare(valB); }; } function getCellValue(row, index){ return $(row).children('td').eq(index).html(); }