[Userscript] Dashboard Progress Plus

@rfindley I took a little bit of a look at your script. I think the WaniKani api changed a little recently. When you are getting the list of radicals and kanji, it looks like it is only returning the list of unlocked kanji/radicals instead of a full list. Since the service isn’t returning all items, the locked list items on the page are ending up undefined in the code.

I was able to fix it locally by updating it to replace undefined references with empty data instead of exiting the loop. I had to add a “meaning” because the capitalize_words function doesn’t check for undefined.

       if (data === undefined) {
            dlog(1,'wkdpp: Unable to find kanji "'+character+'. Substituting empty data"');
            data = {
              "meaning": "unknown"
            }
            //return;
        }

I have to say kudos on the rest of the script though. Because of all the null/undefined checks, it was really simple to just add a (mostly) empty object to get the functionality working again. I wish all the code where I work was that resilient…

2 Likes

Thanks so much for the head-start! I was able to jump right to the problem instead of having to hunt down what was going on.

Also, I’m glad you liked the code. As a contractor, robustness is a big part of the job. I like when my code ‘just works’, so my clients get years of use out of it without ever having to open it up. One of my favorite pieces of code is a task scheduler that has been reused in hundreds of places, and not a single line of code has ever had to be changed. If only that happened more often… :slight_smile:


Here’s the full fix:

:point_right: [v1.4.0] - Repair after WK update: API does not return locked items :point_left:


4 Likes

Little known fact, but in his spare time, rfindley discovers new prime numbers by hand, feeds the world’s starving using only three fish and solves conflicts in the Middle East just by his mere presence.

(ie, thanks for the fix :))

3 Likes

Brilliant! Thanks so much. This script is especially helpful for me right now because I’m coming back to WK after a long absence and really need to pay attention to how fast I’m moving through the kanji so I don’t level up too quickly and re-overwhelm myself.

1 Like

Lol… there’s only one person that can do all that, and it’s not me!
But I’ll happily take credit for occasionally writing good code :slight_smile:

Now that I think about it, sometimes programming feels like trying to solve a Middle East conflict… :grin:

4 Likes

:point_right: [v1.4.1] - Fix popup percentages (due to WK change?) :point_left:

Thank you for this. I wasn’t sure why I wasn’t able to study any kanji/vocabulary yet. I started yesterday.

Is there any chance of getting an extension to this script or even another script that adds the progression-tracking circles to the kanji and/or vocab progression lattice pages? Once we go up a level, we can’t check the progress of older stuff so easy, which is a shame.

^^^
The stats site’s Items tab has an even better summary of item info, and you can see all of your levels at a glance, and you can filter items to get a better analysis. It doesn’t show the sub-levels of Apprentice and Guru, but you can check individual items by hovering over them.
https://www.idigtech.com/wanikani/#items.wk.kan

I don’t get any progress rings, do you know how I can fix/diagnose this issue?

The userscript works so much as I can enable/disable compact mode.

Using Chrome Version 60.0.3112.113 (Official Build) (64-bit) with Tampermonkey 4.3.6 on Windows 10 64 bit.

Press F12 to open the developer tools, then click the Console tab. Tell me if there are any errors there.

Please see the attached image for errors in the console:

It looks like you’ve changed your API key.
Open the developer tools (press F12), go to the Console tab, and enter the following command (and press <enter>):

delete localStorage.apiKey

Then refresh the page, and it should fetch your new API key automatically.

If you still have trouble, you could set your apiKey manually in the developer Console:

localStorage.apiKey = "your_apikey_here"

Thank you! I’ve tried both of these ideas but they seem to have had no effect on the progress rings. Although maybe now there is a grey outline behind some of the icons is working (although I’m not sure what that outline means actually)

I used the API version 1 key.

e.g. with the delete localStorage.apiKey then refreshing the page.

It represents the 90% of the items that you need to level up.

2 Likes

Ahh, it looks like at some point you’ve uncommented the line for replacing the progress rings with a custom graphic. The error message said it failed to find “base64-encoded string here”. That text is a placeholder for a custom graphic.

Open the script and make sure lines 35-37 look like this (i.e. mainly, that they start with //):

// Alternate progress ring image (URL or Base64).
//   localStorage.wkdpp_progress_img = "http://example.com/progress.png";
//   localStorage.wkdpp_progress_img = "base64-encoded string here";

Then go back to the WK tab and open the Javascript console, and enter the following command:

delete localStorage.wkdpp_progress_img

Then refresh the page.

1 Like

No I haven’t edited that (attached screenshot) or at least if I did edit it, then it still looks like how it should be:
image

And I’ve reinstalled the script several times so I’m confident that can’t be the issue itself but…

I ran that command (delete localStorage.wkdpp_progress_img) and it fixed it! Thank you so much!

image

Hi - I’ve just noticed I’m now getting the kanji character itself in the popups, instead of the readings. Behold!


(Version 60.0.3112.113 (Official Build) (64-bit), TamperMonkey 4.4, Win10)

Do you know if something changed recently (API?) that could cause this, or is it just me?
Thanks so much for providing this extension - it has proven very useful for post-lesson drilling.

Nope, I’m having the same situation.

2 Likes

Interesting… I haven’t made any changes in at least a few months, so I’m not sure what’s up. I’ll take a look when I get a moment.

1 Like