Last active
September 23, 2021 19:40
-
-
Save koteq/43dda9478b449a02a8ff to your computer and use it in GitHub Desktop.
myanimelist.net sort plan to wach by rank #mal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// go to your myanimelist.net | |
// click "Plan to Watch" | |
// scrooll all the way down | |
// exec this from console | |
const calc_weight = function (score, users) { | |
const mean = 7.0; | |
const minimum = 30000.0; | |
return (score * users + mean * minimum) / (users + minimum); // imdb top250 | |
}; | |
const requests = $('.list-item .title a[href^="/anime/"]:not(.icon-watch)').map(function () { | |
return $.get(this.href, (content) => { | |
const $dom = $(content); | |
const score = parseFloat($dom.find('[itemprop="ratingValue"]').text()); | |
const users = parseInt($dom.find('[itemprop="ratingCount"]').text().replace(',', '')); | |
const weight = calc_weight(score, users); | |
const $weight = $('<span>').text(' (' + weight.toFixed(3) + ')'); | |
$(this).closest('tbody').data('_weight', weight).find('td.score').append($weight); | |
}); | |
}).get(); | |
// wait untill everything is loaded | |
$.when.apply($, requests).always(function () { | |
// sorting | |
const container = $('.list-table'); | |
const rows = container.find('.list-item'); | |
rows.sort(function (a, b) { | |
const valA = parseFloat($(a).data('_weight')) || 0; | |
const valB = parseFloat($(b).data('_weight')) || 0; | |
return valB - valA; | |
}); | |
$.each(rows, function(index, row) { | |
container.append(row); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Any chance do add this on Tampermonkey and always when I go to my Plan to Watch list the script runs and show the score for each anime ?
Im newbie in those thing btw, sorry.