[Userscript] WaniKani Lesson Filter

:warning: This is a third-party script/app and is not created by the WaniKani team. By using this, you understand that it can stop working at any time or be discontinued indefinitely.

What is it?

This script lets you specify the number of lessons of each type you want to do in a given session, while maintaining WaniKani’s intended lesson order. This means that if you use this script with the Ascending level then subject setting, you will get the radicals, kanji, and vocab that WaniKani wants you to learn first, just limited to how many lessons of each type you want.

How to Install?

  1. As always, make sure you have a script manager installed. If you don’t, follow these instructions.
  2. Get the script here: WaniKani Lesson Filter

Recommended Workflow

  1. On the settings page, use Ascending level then subject or Ascending level then shuffled.
  2. When doing lessons, type in the total number of radicals, kanji, and vocab you want to learn in the inputs. If you leave an input blank, the script will keep all lessons for that type.
  3. Optionally, use the orange input to specify the batch size you want to use. If you leave it blank, it will use the batch size from your settings.
  4. Click the Filter button to apply the input values to your lesson session.
  5. Optionally, click the Shuffle button if you want to randomize the order of those lessons.

image

Note: As of version 2.0.0, filtering will always reset back to the initial lesson queue, so it’s impossible to filter after shuffling. If you wish to have a shuffled queue prior to filtering, use the WaniKani Shuffled lesson order.

What to do if the UI doesn’t appear

The WaniKani team started making a lot of UI changes to the lessons page in 2021. Unfortunately that means this script is more like to break than before. In the event that the script’s UI (see image above) no longer appears, it may still be possible to use the script via the dev console. However, keep in mind that even this approach may not work depending on what WaniKani changed. To use the script using the dev console, use the following steps:

  1. Open the dev console via F12.
  2. Select the Console tab.
  3. The lesson queue can be filtered by calling window.lessonFilter.filter(radicalCount, kanjiCount, vocabCount, batchSize). Call it with the specific values you want to use (in place of the text radicalCount, etc.), and use null when you don’t want to override a value (just like how you’d leave the input blank in the UI version). For example, window.lessonFilter.filter(3, 5, null, null) means to filter to 3 radicals, filter to 5 kanji, and keep all vocab, and not change the batch size from the default
  4. The lesson queue can be shuffled by calling window.lessonFilter.shuffle(). Nothing needs to be passed in.

Support

  • This script has only been tested in Chrome using Tampermonkey, but will likely work in Firefox as well.
  • Please post any bugs/requests and I’ll get back to you as soon as I can.

Revision History

2.1.4 - Fix bug to once again treat blank batch size as using the user’s batch size from WaniKani settings.
2.1.3 - Alert when the batch size is invalid instead of picking default values.
2.1.2 - Allow kana vocab lessons. Fix lesson counts on top right of the page.
2.0.0 - Rewrite the script to work with the recent WaniKani update that rebuilt the lesson page.
1.3.1 - Fix an issue where the quiz would start early or require extra clicks / keypresses, particularly after changing the batch size.
1.3.0 - Add ability to filter and shuffle via the dev console in case the UI ever breaks due to changes made by the WaniKani team.
1.2.4 - Use new selectors to properly re-render the page after filtering/shuffling. This was necessary due to this change.
1.2.3 - Blur the buttons after they are clicked so that hitting Enter executes the default WaniKani action instead of ‘clicking’ the button again
1.2.2 - Fix a new bug from a recent WaniKani UI change.
1.2.1 - Decrease the chances of conflicting with other scripts.
1.2.0 - Add a new input for setting your batch size.
1.1.1 - Stop the item batch UI from overlaying the lesson filter UI.
1.1.0 - Your previously used filter values will now be saved and loaded automatically. The values will not be applied automatically and must still be applied using the Filter button.
1.0.0 - Initial release.

74 Likes

Alert to @AnimeCanuck, @aplayne, and @ccookf since the three of you have expressed interest in this script.

Awesome! I’ve already done my lessons for the day so I’ll check it tomorrow.

Oh, I’m not using Chrome! All my scripts and WK doings are on Firefox. In fact, I don’t even have Chrome installed on my Windows 7 drive…

Can I copy-paste your Tampermonkey code into Greasemonkey? Do people know if that works, usually?

I think he’s saying he’s only tested in Chrome, but I don’t see any reason you can’t install it into firefox as normal

@AnimeCanuck Sorry for the confusion, @bladepoint is right. I just meant that I only tested in Chrome, but there’s no reason to think it wouldn’t work in Firefox. I’ve edited my original post to clarify this.

Speaking more generally, code that works in Chrome will generally work in Firefox and other modern browsers. I specifically didn’t use any newer JavaScript features so that I wouldn’t have to worry about browser compatibility. Let me know if you have any issues, but I expect it to work.

1 Like

This used to be one of my favourite sites at work until I started specializing in server-side code It tells you what versions of what browsers support a specified feature, and if it’s limited, what those limitations are:

I know, I just didn’t feel like worrying about it. With something as simple as this, the only thing I might have used was let, and I didn’t even use that out of habit.

woop woop awesome!

1 Like

Thanks. I just used it and it worked fine.

May be nice to be able to set a default that it remembers. But it works fine as is. Thanks again.

Yeah, I was thinking of saving the typed in values so that the browser remembers what was used last. I’ll look into it.

2 Likes

Installing and trying this out today ~ with mostly only Vocab items and a few kanji at the end of my level, and leaving my settings to “shuffle”. I’ll try other settings once I level up in a few days. ^^

EDIT: Oh… So your “shuffle” button… when you meant it “acts like Shuffle”… you meant completely, not at all taking into account the numbers. I put in 3 kanji and 2 Vocab, and clicked it, and it returned 1 kanji and 4 vocab. When I clicked a second time, it returned 0 kanji (all Vocab). Clicking “Filter” returned expected results. Also I see you set it to be directly below Reorder Ultimate. (Thanks! I hadn’t picked anything there, so I don’t know if there’s any interference, but there doesn’t appear to be.)

If you do add that, could you make that an option?

Correct, the shuffle button acts completely independently of the inputs and filter button. If you look at my Recommended Workflow section again, you’ll notice that #3 says to click Filter to apply the input values and #4 says to optionally click Shuffle.

I expected the order to depend on which script was first in the script manager. In my testing though, mine always appeared below Reorder Ultimate. I’m not really sure why, but I didn’t think it mattered enough to look into it.

If you completely filter out a type in my script (by typing in 0), that type won’t be removed from Reorder Ultimate’s UI. There is a simple change that can be made in the Reorder Ultimate script to solve this, but I wanted to see if my script actually got non-negligible usage before requesting xMunich to update his script.

EDIT: My script is completely stateless, so nothing you do in Reorder Ultimate can break my script. It just may change the order of the queue, after which my script will of course maintain that new order when clicking Filter.

I’m not sure how I’d do that other than a variable at the top of the code so that people can manually turn it on and off. I’d rather not bloat the script’s UI like with a way to toggle between saving and not saving the values in the inputs, Any reason in particular you don’t like that idea?

Actually, I think that is really handy when working with them in conjunction - when leaving the main setting (in WK’s settings) to “shuffle” then you can choose which levels and items to even have in the pile with Reorder Ultimate, before filtering them with your script into what kind of lesson session you want to see. I think that’s just lovely. <3 (I was just making an observation. XD)

I had remembered that you had said that, however as it was still a button on your script, for some reason I still expected the numbers to be taken into account - for instance if I had any other setting besides “shuffle” in the WK main settings, I would expect your shuffle button to take those numbers I’ve input and shuffle that many items of those types from across the levels - probably overriding the ascending level order. *shrugs* Now I know it doesn’t work that way. (This is why one tries different things, after all.)

This is exactly the behaviour I had hoped it would have. ^^ Awesome.

I was thinking a simple yes/no checkbox.
Personally I don’t, as I vary my inputs all the time depending on my mood - how much I think I can handle at any time I’m doing lessons. When I’m pretty tired, I will not want to learn anything other than vocabulary, and even then I’ll keep refreshing/hit reorder(the centre of the scale, actually) to pop up 5 or as many as I can easier terms which I can guess the meaning and/or reading already. Having the cache/browser remember your last setting could make a tired person (me) bring up other things that I’m just not capable of at times such as those.

And also, it takes up (very little) memory (but that’s not a reason for a toggle, but a reason for none at all).

Even when I’m not sleepy, I often do one session of 1-2R, 2K, 1-2V, followed by 1K, 4V, (or just 5V), depending on how difficult the kanji were. Then if I come back in 4 hours after my first Apprentice review, I’ll usually want only Vocab (sometimes with 1 more Kanji if it’s not too late)… So for me, always changing it is beneficial to my personal style.

That may not be the case for everyone, of course. Hence the suggestion of a toggle.

(Sorry that was possibly way too detailed an answer.)

Just to clarify, saving the previously used filter would not automatically apply it; it would just pre-populate the inputs. You’d still have to click Filter to apply the values, and therefore you could still change the input values before filtering. This feature wouldn’t be useful for you, but it seems like it shouldn’t hurt either. Does that make sense?

Oh… It seems like I misunderstood again.

^^;

It has really been a long 3 days of watching children for 8 hours and getting up many hours earlier than normal to boot. Sorry.
はい、わかりました!

Version 1.1.0 is now live. Please let me know if you see any issues.

Changes

Your previously used filter values will now be saved and loaded automatically. The values will not be applied automatically and must still be applied using the Filter button.

Question! What items does the script pull from the lessons queue? First item you’re supposed to have, or a random item?

Meaning, if I use Ascending level then shuffled, will the vocab the script give me first from the previous levels, or will it just pick a random vocab?

The script will always use the first items of each type from the queue. So if you use Ascending level then shuffled, you will always get the vocab from the previous levels first. This is, of course, assuming that you haven’t clicked the Shuffle button yet.

1 Like