Skip to content

Instantly share code, notes, and snippets.

@Naouak
Created January 15, 2013 22:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Naouak/4542666 to your computer and use it in GitHub Desktop.
Save Naouak/4542666 to your computer and use it in GitHub Desktop.
A short script that will inject on any animelist on MyAnimeList scores that are scaled from 0 to 10. It means that if your lowest score is 5, it will become 0. It also calculate some values that you may find interesting and put it in variables. To use it, just paste this in your chrome console when you are on an anime list.
var n = document.querySelectorAll(".animetitle");
var arr = [];
var min = null;
var max = null;
var total = 0;
var count = 0;
var noteCount = {};
for (var i = n.length - 1; i >= 0; i--) {
(function(n){
var title = n.text;
var note = n.parentNode.parentNode.querySelector("td:nth-child(3)").innerHTML;
if(note == "-"){
note = null;
} else {
note = parseInt(note);
}
arr.push({
title: title,
note: note,
node: n.parentNode.parentNode.querySelector("td:nth-child(3)")
})
})(n[i])
};
arr.forEach(function(n){
if(n.note === null){
return;
}
if(min === null || n.note <= min){
min = n.note;
}
if(max === null || n.note >= max){
max = n.note;
}
total+=n.note;
count+=1;
if(noteCount[n.note] === undefined){
noteCount[n.note] = 0;
}
noteCount[n.note] += 1;
});
console.log("Average: "+total/count);
var center = min + (max-min)/2;
var scale = 10/(max-min);
total = 0;
count = 0;
arr.forEach(function(n){
if(n.note === null){
return;
}
n.realNote = (n.note-center)*scale + 5;
total+=n.realNote;
count+=1;
n.node.innerHTML+=" / "+(Math.round(n.realNote*100)/100);
});
console.log("Average: "+total/count);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment