Skip to content

Instantly share code, notes, and snippets.

@koteq
Last active September 23, 2021 19:40
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save koteq/43dda9478b449a02a8ff to your computer and use it in GitHub Desktop.
Save koteq/43dda9478b449a02a8ff to your computer and use it in GitHub Desktop.
myanimelist.net sort plan to wach by rank #mal
// 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);
});
});
@yarushi
Copy link

yarushi commented Aug 28, 2017

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.

@d-s-x
Copy link

d-s-x commented Apr 22, 2018

add this on Tampermonkey

@yarushi,
hey, check this one!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment