@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ā¦
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ā¦
Hereās the full fix:
[v1.4.0] - Repair after WK update: API does not return locked items
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.
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.
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.
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:
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)
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:
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.