[Userscript] Niai 似合い Visually Similar Kanji

i am looking forward to your exploits, mr internet wizard man

I think I have fixed it – if you want, you can try out the new version here:

Install Niai with fixed “locked items” display

In this version, I have re-enabled the code that uses wkof (only if it is available) to fix the displayed item info. Instead of querying the WK items from wkof every time the Niai section gets displayed (which can happen very often during lessons and reviews), they are only requested once, which should prevent the wkof loading popup from appearing during the session.

If wkof is not installed, Niai now uses options["Current Level"] to determine the user’s level. Until today, I did not know that WK provides this information readily available.

1 Like

Ill try and report as soon as I can, thanks a bunch.

1 Like

Hey, I installed your fork, but it doesnt seem to work. Below in the screenie there it highlights words I used to have unlocked before the reset, but I am currently level 4 so ‘snow’ and ‘heavy’ should not highlight. I do have alot of scripts installed though, so that might interfere.

I assume you have WaniKani Open Framework installed?

Could you go to some WaniKani page, open the browser console (Ctrl+Shift+I) and paste the following code into the console?

await wkof.ready(`ItemData`);
let items = await wkof.ItemData.get_items({wk_items: {options: {assignments: true}}});
items.find(i => i.id === 673).assignments;

Then press Enter, expand the result, and post a screenshot of it (or copy the result as text). I would especially like to know what the srs_stage is, and what unlocked_at contains.

Example screenshot


Where exactly do I paste this? I only really have a filter bar there.
Looks like this:

I can set it to English if that helps you. Does this forum have DM or can I add you e.g. Discord, so we dont spam the thread?

Just below the yellow warnings and red error messages. Also, I think this thread is the appropriate place to spam about fixing bugs in the Niai script. And no need to change the language, I can read German just fine :slight_smile:

Wait, I just noticed something… if you use Ctrl+Shift+J to open the console in Firefox, it opens a different console than the one you should use. Why does Firefox have two different consoles!?

Use F12 instead. Or Ctrl+Shift+K (only in Firefox) to be immediately directed to the correct console tab.

Does anyone know whether acm’s 似合い Visually Similar Kanji script works on an Android device?

You need a browser that supports browser extensions, so that you can install a userscript manager (Tampermonkey). You could try Kiwi browser.

1 Like

okay, heres the result:

1 Like

Thanks! I had assumed that locked items would have srs_stage === -1, but that is only valid for wkof interaction and not for the API. I have changed it to use unlocked_at instead. You can test the fix here:

Install Niai with fixed “locked items” display

Thanks, I’ll report as soon as I have more kanji lessons.

I’m studiously trying to ignore this comment and stop wondering how my Burn Progress script is calculating the total number of published items correctly. The code I, uh, borrowed gets the number right, and uses wkof, but I distinctly remember just summing stages 0…9.

You are not filtering using wkof, which would look like this:

const config = {wk_items: {filters: {srs: `0,1,2,3,4,5,6,7,8,9`}}};
const items = await wkof.ItemData.get_items(config);

This would exclude locked items, because wkof uses -1 to denote locked items in this filter. Instead, you are using the srs_stage values returned by the API (which wkof does not modify and just passes through), and there, 0 can mean either locked or unlocked but not yet learned. Furthermore, if an item does not yet have an assignments object (locked items you never learned before – not even before a level reset), you set its srs stage to 0.

1 Like

Sorry, I never answered. Works perfectly fine for me now, thanks mate!

1 Like