[Userscript] WaniKani Dashboard Level Progress Detail 1.0+

Not sure if this is intentional or just how the data is structured, but kana-only vocab gets it’s own bar. There’s a chance kana-only becomes opt-in/out which might complicate things, but would it be better to lump them with the rest of the vocab so there’s just radical, kanji and vocab bars again?

Good idea! I’ve released 1.2.3 which treats kana only vocab as vocab.

Edit: 1.2.4 adds a setting to hide kana-only vocab entirely if users so desire.

3 Likes

1.2.4 makes this tweak an official setting to keep the original progress bar

1.2.5 allows you to hide current level items with the setting on if you choose to now

3 Likes

Strangely my progress detail section is not showing up today. I’m not sure why but I will keep an eye of it.

4 Likes

Same for me

4 Likes

i thought it was not working because i switched from tampermonkey to violentmonkey, but yeah, not showing for me either

2 Likes

It seems the CSS class .dashboard-progress .progress-component simply doesn’t exist anymore, so the script doesn’t know where to put the html. I got it to work by simply replacing each occurence with .level-progress-dashboard, but this is just a lazy workaround.

5 Likes

Replaced as you suggested, now it works
本当にありがとう

1 Like

Thanks! This edit also worked on the WaniKani Dashboard Cockpit script!

1 Like

It mostly worked for me too, how ever I seems to have little issue with mine, as Dashboard level progress detail always doubles the last “box” that can be seen. For example currently I have two identical “Level 12 Vocabulary Progression” boxes. If allow level 13 to show, which I’m on, but haven’t studied any of the items, it would then double last box in that. I tried to look in to code, but I couldn’t figure out what’s causing this. It feels to me that it’s not this script as when I reload the page, it first shows only one box and then after a while it loads second box. So it feels it’s more of an issue somewhere else. But other than visual annoyance it really doesn’t matter for me that much.

2 Likes

I spend this morning tinkering with the script and got it working again without the duplicate lines, and with it also hiding the old progress bar again. I have next to no javascript experience, so this was a process of just trying things until it worked. I am fairly certain that at least some of the features are still broken, as the script is looking for several elements that no longer seem to exist, and I don’t know what it is even looking for in the first place.

For others that want to try to apply this fix, find the code between:

function totalAtLeast(progress, stage) {
            return progress.srs_level_totals.slice(stage).reduce((a, b) => a + b, 0);
        }

and

var progresses = [];

and replace it with this:

// Scoreboard does not seem to exist anymore wich defaults to the last element.
// This is the div with the old progress bar and kanji/radical progress.
// No idea what scoreboard used to be or do and if this is correct.
let scoreIndex = window.$(".level-progress-dashboard").children().get().findIndex(obj => obj.id === "scoreboard");
let score = window.$(".level-progress-dashboard").children().slice(scoreIndex).detach();

// This used to be done below, but the progress bar seems to have moved so I added an explicit removal here.
if (!keepProgressBar) {
    let progressBarIndex = score.children().get().findIndex(obj => obj.className === "level-progress-dashboard__progress");
    if (progressBarIndex > -1) {score.children()[progressBarIndex].remove();}
};

// This line caused the duplicate progress lines, presumably because the old progress bar used to be here but was moved?
// Just removing all children instead of only the first ones seems to solve the issue.
window.$(".level-progress-dashboard").children().remove();
if (settings.hide_current_level) { window.$(".level-progress-dashboard").empty(); }
score.appendTo(".level-progress-dashboard");

(In addition to the previously mentioned fix, which also requires changing

window.$('.dashboard-progress .progress-component').prepend(runningHTML);

to

window.$('.level-progress-dashboard').prepend(runningHTML);

later on in the document.)

This is definitely this script. It is attempting some sort of caching magic, by first rendering based on cached data, and then re-rendering when the actual fresh data is loaded from the wanikani servers. This second rendering failed, probably because of the names and ordering of the web-page elements it is interacting with having changed.

6 Likes

Thank you. That solved the dublicate issue.

2 Likes

@UInt2048 if you can at some point it would be amazing if you could update this script to work again (either with this or with your own code if you prefer of course), it’s so incredibly useful!

1 Like

I finally found a way to get it back looks like it wasn’t playing well with dashboard cockpit. Which is fine I prefer this one anyway. Maybe the settings of the cockpit hid something that made this new fix have to hide as well.

If anyone immediately know what is in conflict feel free to let me know.

THANK THANK THANK YOU for all this help!

Thanks a lot!

By trial and error figured out:
if you want to keep the tiles for the new radicals and kanji from the original view, on this line

 let score = window.$(".level-progress-dashboard").children().slice(scoreIndex, scoreIndex + 1).detach();

change the “+ 1” to a “+ 2”.

At least it seems to be working that way for me right now. No guarantee though; my knowledge of javascript is quite rudimentary.

1 Like

scoreIndex should be -1, so changing the slicing from (-1,-1+1) to (-1,-1+2) should not actually do anything. I tested this online and slicing from -1 to a non-negative number just gives you an empty list back.

1 Like

Well as I said, I’d don’t actually have enough knowledge to understand the whole script. I just know that somehow for me it works in the view. :woman_shrugging:

1 Like

ah… I forgot that I changed another line as well, compared to your code. So for

let score = window.$(".level-progress-dashboard").children().slice(scoreIndex, scoreIndex + 2).detach();

I had changed the +1 to +2
and I had left this

 window.$(".level-progress-dashboard").children().slice(0, keepProgressBar ? -3 : -2).remove();

unchanged compared to the original.
But again, I don’t really know what I’m doing here. :sweat_smile:

1 Like

My interpretation of this second line was: “delete everything except the last 2/3 elements”. Everything here was the new stuff added by this script in the previous round of rendering from cache. However, A lot of stuff seems to have moved, so whatever it was protecting is no longer there, I think. This leads to “the last 2/3 elements” to also include newly added lines that should be deleted, so you get duplicate lines when everything gets added a second time.

It works!

You made me think the infamous quote: «Nothing more permanent than a temporary solution».

Thank you @MagicalGrill!

1 Like