Yeah, same infinite loop problem.
I think what you wanted with:
while(json.progresses.length > 3) {
var progress = json.progresses[0];
if (progress.gurued_total*100.0/progress.max >= 90) {
json.progresses = json.progresses.slice(1);
}
}
is instead something like…
json.progresses = json.progresses.filter(function(progress) {
return progress.gurued_total*100.0/progress.max < 90;
}
If you were trying to filter out the previous level (your code does not do this but maybe that’s what you were trying to do with the if
check?):
var currentLevel = json.progresses
.map(function (progress) { return progress.level; })
.sort(function (a, b) { return b - a; })[0];
json.progresses = json.progresses.filter(function(progress) {
return progress.level === currentLevel &&
progress.gurued_total*100.0/progress.max < 90;
}
This is an excellent script idea, just needs some more implementation work. I’m working on some alterations myself which I would be happy to share once they’re complete. (Particularly, compatibility with
WaniKani Dashboard Progress Plus.)