[Userscript] WaniKani Context

Can you make a hotkey to toggle the context sentence appearing? I’d like to see if I can remember a vocab without it then toggle the context sentence as an extra hint.

Just found a problem with the script. It highlights the wrong word sometimes since it uses the same kanji, and since I assume the script highlights the first appearance of the word it gets mismatched. In this case kane (money) is highlighted instead of kin (gold). A possible fix for this would be nice otherwise I just have to be more vigilant in the future. I do like this script!


@rever4217 From a programming perspective, how would one even check this? Would a list of all WK words be needed to cross-reference?

I really don’t know. Without furigana it’s probably an impossible task. Probs no other way than to just search all the sentences where the word occurs multiple times and check each one manually.

Right, this error makes me wonder how it checks for the word.

1: Just searched part of the script, appears to look for the root (kanji) of the verb if the conjugated form is used? And I guess since 写る only has one kanji it just took the first instance of 写 which happened to be 写真.

I can’t code so I don’t know how to fix this, but I imagine something like searching for the instance where the root kanji is the only kanji present in the word may work since this would disqualify 写真 (since 真 exists). Then again there aren’t any spaces so how do you even define a word. Perhaps just taking the first instance of hiragana next to the root would work.

1 Like

Unless, 上がる and 上げる, or another verb pair like that, in the same sentence…

1 Like

The variety of special cases to look out for! I mean these cases are already special. I guess you need a way to properly get the root (sorry I called it stem before) as at the moment it only takes the kanji part of the root.

I would be interested to know how the extension decided that 。 is the answer, despite the original sentence not even having it at the beginning of the sentence.


This is great; I can’t wait to see how it helps once I catch up to my previous studies.

I noticed early the kanji start problem (where ()り in ()(ぐち) was highlighted for (はい)る)

That might be a problem in the corpus though. Combined with undo script it’s not a big problem.

edit: Actually it was the exact same double kanji bug; I just didn’t read carefully enough. The full example sentence is: “ちゃんと入り口から入ってください。” So it is just a problem of just choosing the first instance.

1 Like

Hey everyone,

Sorry about the radio silence. I currently am not using WaniKani, so my ability to improve and test the script is near zero right now.

I’m glad people are still using and benefiting from the script even while being gone.

That being said, if someone else wants to try their hand at improving the script, I’ll do my best to give pointers/support.


I installed this as a beginner as I thought it makes a lot of sense. A warning would be nice as it REQUIRES grammar knowledge to differentiate conjugations. As a beginner, I do not have that grammar knowledge so this script forced me to guess my answers several times. Very frustrating. In an ideal world I would like to see a version with context only using the standard form that is also taught by WK and an option to also include conjugations. I had to deactivate this script and will come back to it in a few months when I worked through genki…

1 Like

Is it possible to update the script to keep the original vocabulary word along with the sentence?

1 Like

Thanks for sharing this

1 Like

Does anyone know how to disable the highlight? I think it looks better with just larger font and key word centered.

I disabled it by editing the script. Go to line 157 and delete the mark tags and extra +'s, then add .bold() so you can still see the word bolded. Like this

        '<span>' +
        currentSentence.substr(0, vocabIndex) +
        currentSentence.substr(vocabIndex, vocabLength).bold() +
        currentSentence.substr(vocabIndex + vocabLength) +

Does this script have any options just to show the sentences with words until my current level?

Because I skip reading all the time the sentences because there are many words that I dont know the meaning and reading yet.

(Found this just now, so super late…)

The crux is you typically don’t always see words in the same context, which is why this method never works for me (I have tried. Multiple times).

After a few times, I just naturally start to recocnize which of the various context sentences this is and then I know what it means, even if I don’t remember the actual words.

If there were enough context sentences that it could show you a different one each time, then sure that’d be pretty realisic.

I’d find this a lot more useful if it’d replace the vocab after having answered instead. (Maybe I should try to learn enough userscripting to make such a script…)


Well… by stealing a bunch of stuff from this script as well as Anki Mode I’ve cobbled something together, mostly for my own usage.

Basically what my version does is that it replaces only the vocab meaning quizzes with this anki inspired verson:

  • The input box is removed
  • Pressing enter shows sample sentence (translation hidden).
  • With sample sentence visible, pressing h shows translation
  • With sample sentence visible, you now answer anki-style: 1 if you were wrong, 2 if you were right.

So basically I’ll first show just the word, then once I think I know what it means, or can put it in context, I compare with the sample sentence (or optional translation) and grade myself accordingly.

I also made one that just replaces the word with the sample sentence after you’ve typed the answer, nothing else changed.

Like I said, I made this for myself, and it’s not super high code quality (most of which is stolen anyway), but I thought I’d mention it in case someone wants to give it a try, in which case I’ll try to figure out what my greasy fork username was and share it there.

1 Like

I’m just linking this other script here so it shows up in this thread’s Post Links section for future searchability :link::mag_right:

1 Like

I’ve made a hacky edit to this script that I’m finding very useful.

Here is a gist of it.

The first major change is that it display the vocabulary as well as the sentence, with the vocabulary larger than the sentence.

The second is that I’ve added a text-to-speech function for the sentences. Assuming your browser supports it, if you click on an example sentence, a machine-generated audio will play.