[Userscript] Self-Study Quiz


Anyone else having the script randomly not work anymore? I don’t even see the quiz options etc. like I used to on the Kanji pages, or level pages. Was working as of last week, so not a clue what could have changed. On Chrome, Windows 10


I still think it’s odd that showing additional meanings will play the audio. I have audio-play turned on (gray - audio questions only). It was particularly weird when I got a popup saying a word had multiple readings, because when I checked the additional readings it played the audio after having just auto-played the audio.


@rfindley Let’s say I want to create a self study quiz with WaniKani items, but with supplemental information. For example, show a word (kanji and kana) and fill in the pitch accent. Is this even remotely possible with how this script (and the Open Framework) are designed right now? I know you allow for different data sources, but this data would be for WaniKani items, not completely unique items. Additionally, it isn’t clear to me if you can quiz anything other than reading/meaning/audio right now.


I had debated allowing a generic question/answer, but decided not to try adding it at this point.

I might be willing to add an API via the programmatic method of opening a quiz. Something like:

    ipreset: {...}, // Settings for selecting items
    custom_qna: {
        get_question:  my_question_callback,
        check_answer:  my_answer_callback

function my_question_callback(item) {
    // TODO: Given an item, return a string containing the 'question' to ask

function my_answer_callback(item, answer) {
    // TODO: Given an item and the user's answer,
    //       return one of the valid answer results:
    // return {
    //     action: 'correct', 'incorrect', or 'shake'
    //     message: string to be displayed (e.g. "We're looking for the on'yomi")
    // }


I’m not exactly in a rush for such a feature anyway, mostly because I’m not sure if I want to focus too much on pitch accent right now (more than absorbing it in the background) and it could be a lot of work to set up the script. I was mostly just curious.


@rfindley The settings dialog could use a small tweak with the default size. When I open it and then switch to the Items tab, the Save and Cancel buttons get cut off.

On a related note, I always go to the Items tab when I open the settings. Do you think it might make sense to remember what tab the user last made a save on and always go to that tab first?


Yeah, I agree with those changes.

I’ll work on it when I’m done with Ultimate Timeline. I’m about to get really busy again, so I really want to get everything converted to APIv2 asap.


The rest of code looks well structured with meaningful variable names, and then you have jw_distance() that sticks out like a sore thumb!

How can I trust that getting the Jaro-Winkler distance is all it does huh? I knew I was a fool for ever trusting you! :sob:



Seriousness, though, the reference code I used for the Jaro-Winkler algorithm already had meaningless variable names, and the code (being algorithmic in nature) wasn’t very human readable. So I just deleted the spaces and newlines to make the ugliness take up a single line. :sweat_smile:

I also remember having about 8 different string-distance algorithms (including the one Wanikani uses) that I tested before settling on JW. I had all of the algorithms on one line each, and the test cases took up the majority of the space in the js file.


@rfindley, I don’t know what I’ve done, but I can’t get the script to work properly.

My current issue is it’s just stuck on “loading”.

I can type in the box, but it won’t allow a submission. Also, when it’s asking for reading, my letters just come up as english alphabet and I’m assuming there should be an IME feature. If so, that part isn’t working properly for me either.


Try opening the javascript console and see if there are any errors reported (press F12 and click the Console tab).


Oh boy, yep!

Obviously if Tampermonkey couldn’t load, that’s the problem. But I’m not sure why? My other scripts on other pages work without issue.

Edit : Just realized I get that Tampermonkey error even when scripts are working. So I guess that isn’t it. I dunno, I’m lost now lol


It looks like the problem is that something is blocking ‘wanakana’ from loading. Wanakana (not Wanikani) is the IME that converts your text to Hiragana as you type.

Try pasting the following address in a new tab, and see if the browser lets you load it.


It should be a bunch of javascript code, so don’t worry about it making sense.

If it fails to load, maybe your location on the internet is temporarily having trouble with that address. If it does load, you may have had an update to TamperMonkey or your ad-blocker that thinks the Wanakana address is bad.


Site can’t be reached.

I’m at work, so it very well could be a blocking issue. I’ll try it again once I’m at home and see if it works properly there.

Thank you very much for your help!


@rfindley Since this one isn’t on Github I can’t make a pull request:
I propose the following change to line 689

        var dialog = (quiz.dialog = $(quiz_html));


        if (quiz.dialog) { close_quiz(); }
        var dialog = (quiz.dialog = $(quiz_html));

as calling ss_quiz.open more than once stacks dialogs up and hijacks their close method.


Good call. Will do.

I look forward to seeing what you’re making :slight_smile:


:point_right: [ v3.0.15 ] - When opening a new quiz, close any currently-open quiz.


Does quiz.close() handle the background tint? have i read the code wrong?


Yes, it does.

quiz.close == close_quiz

I think you’re thinking of dialog.close() instead of quiz.close().