After deciding today, on a whim, that I wanted to be able to answer a given question with all possible meanings and readings, I looked for a script to turn my wishes into reality and found this older solution by Mempo.
Sadly, this didn’t work for me, so I spent a few hours today debugging Mempo’s script and writing my own version of it.
What does it do?
It works on the same premise as Mempo’s original version: When answering, you can now input multiple answers, separated either by a semicolon ( ; ) or more than one white space. It should be fine to mix and match separators. If you’re a psychopath.
I figured out a way to direct this towards Wanikani’s own spellchecker, so Wanikani should act like each answer was submitted normally and isolated.
If any answers are wrong, the entire thing gets marked as red and the input field shows only the answers you got wrong, seperated by semicolons.
If you get it right, the answer field should hopefully display what you yourself entered (since everything is correct).
As a further improvement upon Mempo’s version, mine also works on lessons, not just reviews, and is fine with all registered readings/meanings of any kanji, vocabulary and radical (since it just uses Wanikani’s default checker)
Before you install
There are known bugs. They’re just minor annoyances, but please make sure to be aware of them before you install.EDIT: There are no longer any known bugs! Install away and please tell me about any problems you do find!
I both developed and tested this thing on Firefox & Tampermonkey. It’s untested on any other browser / script sandbox.EDIT: It is now tested on both Firefox and Chrome.
Now in case that was unsuccessful in scaring you off…
How to install
- Install Tampermonkey
- Install Wanikani Open Framework
- Installation Tutorial (Be sure to order the scripts correctly! The Framework must always be loaded first!)
- Download on Greasy Fork
- Developer thread on the forum
- Install my Script (The Wanikani Open Framework is no longer a requirement)
- Hope that it works! (o゜▽゜)o☆
Known issues and cries for help
In case of an exception, the page forces a reload and the console gets cleared. This writes the last user input into a URL as a parameter, causing the
@matchtag to no longer… well, match. This deactivates the script and forces the user to completely re-open the tab in question, cutting the study session short.
The reason that this confuses me is that I was pretty sure Tampermonkey surrounds user scripts in a try/catch, so why does this happen?
Similarly, mashing the enter key causes the same problem, so I’m assuming that it, too, produces an exception. My code handles an empty input just fine, only mashing the enter key (-> spamming the code with empty inputs) causes such a strange behavior. Of course, I can’t debug it, because then I can’t spam Enter anymore…
=> Both solved by @Sinyaven - thank you!
At the very end, my code calls the original button.click again to re-route execution to the original Wanikani stuff. In case of the answer being correct, however, I then afterwards re-apply the original input, AFTER the button.click call. Is this event code synchronous, or do I have to worry about causing weird race conditions?
The script kind of spams the dev console with info. Is that fine or bad form?
Mempo’s original script called event.stopPropagation to, I assume, stop the event from reaching default Wanikani code. I just kind of copied this without question, but should I be worried? This particular function seems to be slightly controversial, judging by my cursory Googling.
=> All answered by @Kumirei ! Thank you!
Since this script requires it and greasy fork told me to, I added
// @require https://greasyfork.org/scripts/38582-wanikani-open-framework/code/Wanikani%20Open%20Framework.user.js
To its header. Doing this doesn’t appear to be the norm, however, judging by other userscripts that claim to use the Framework. Is this tag wrong or alright?
=> It was wrong!
This script is kind of a derivative work of Mempo’s. Greasy Fork has a tag for this, but I don’t know how to set it. I would very much like to credit them for their work, but don’t know how.
Similarly, their original script doesn’t have a license tag. I would like to imagine that I didn’t just infringe copyright… I didn’t, did I?!
- Like I said, first post. This post is kind of a mix between asking for feedback and API/Third party, but I only saw one field for tags, so I went with the latter.
If there is a way to apply more tags (or if it’s in the wrong place here), please tell me.
EDIT: There isn’t, but if you see any other inconsistencies or problems with this post, the same still applies!
General feedback on this one is of course also always welcome! I wouldn’t mind adding new separators for instance, or allowing you to configure your own! (provided that I can figure out how to store a config )
I am far from done with improving this script! (but out of ideas!)
- Oops. Typos.
- Guess what?! WKOF is required again! (For real this time, I tested it)
- Added settings support
- Added setting to not immediately fail on a wrong answer if at least one answer is correct.
Instead, it will now cause a shake effect and tell you which answers were wrong
- Removed the
@requiretag again, as WKOF wasn’t actually required.
- Cleaned up logging and moved it to respective Debug and Info levels.
- Fixed known bugs
- Tested on both Firefox and Chrome this time
Version 1.0.1: Added
@require tag for the Wanikani Open Framework
Version 1.0: initial