[UserScript] Wanikani Self-Study Plus (v 0.1.13) [Unsupported] (for now)

UPDATE: Okay, well the code is still a bit of mess, but I’ve just been getting a bit excited and maybe a little adventurous with my intentions.
I believe I have it working now (but I won’t know for sure until I get my reviews down to an acceptable level).

Reviews are now pushed into your main reviews by default. (if you have no official reviews I think it may not work, but at the time of writing I have 2600+ again so can’t very well test that theory at the moment)

Here’s a screenshot:



As you can see, I haven’t added any meaning/reading explanation properties but the WaniKani Community Mnemonics script works well with it.
(yes N/A is me, I submitted the mnemonic before I had really tested compatibility and my username didn’t get sent along with it)

Also, I dug through the site’s code to find how items were levelled down, and now replicate that behaviour (before it just dropped one level)
-End Update.

I strongly suggest exporting your list to a csv file, otherwise there is real possibility of losing your revision list if you clear your browser data or some technical glitch destroys it.

This is an extended version of Shudouken’s Wanikani Self-Study userscript
/t/Userscript-Wanikani-Self-Study-115-Add-your-own-Vocabulary/4597/1

Wanikani Self-Study Plus
Version 0.1.13
https://greasyfork.org/en/scripts/5899-wanikani-self-study-plus
provide YOUR_API_HERE (first occurrence only)
locksOn is true by default, set to false if you want to disable the locking feature.
lockDB is true by default, this means any kanji not returned by the server will now be locked
reverse is true by default, it adds an additional quiz for any item that has both a meaning and reading, giving you the meaning (English) testing you on the reading, getting any of the three wrong will affect the SRS in the same way as getting them all wrong will.
asWK default true, pushes reviews into existing pending reviews on the site. The sites native code handles the delivery of the test and thus the reverse flag has no effect here.

Imports files with the extension csv. (skip the first line)
Format is
kanji,reading 1{tab}reading 2,meaning 1{tab}meaning 2
Format is reversed for tsv
kanji{tab}reading{tab}meaning 1,meaning 2
this may be easier to make with a spreadsheet since you can put comma’s in a cell a lot easier than tabs.

Exports to csv, same formatting as above

Previously known as “Self Study Ethan Edition” (ugh!)
When I originally started tinkering around with this script I just wanted to add a locking mechanism and incorporate the WK API.
The only reason I ever gave my version the moniker “Ethan Edition” was that I needed some way to differentiate it from the original version and wasn’t particularly creative.

I have now renamed it to the equally creative, but far less self-serving, Self-Study Plus, and since it seems I have the original authors blessing, I’ve given it its own thread.

Report bugs below or on greasyfork.

ChangeLog
0.1.13 Meanings now also accept portion of answer before ‘(’  as correct; Some bug fixes
0.1.12 Items are now also added to main review queue
0.1.7 Fixed bug that caused it to crash when no API was provided. (However if both ‘locksOn’ and ‘lockDB’ are set to true, any words using Kanji will be locked)
0.1.6 API key stays persistent in storage, fixed bug that prevented currently locked WK vocabulary from downloading (still only levels 1-10 unless changed in code)
0.1.5 Improved performance when checking for unlocked items, CSV export functionality added.
0.1.4 Redirects to https protocol if using http protocol, checks referrer to avoid lagging unnecessarily (when looking for new unlocked vocabulary)
0.1.3 Colour-coded answer types, added information on when review list is to increase.
0.1.2 Added locksOn toggle to disable locks if desired, added button to import first 10 levels of vocabulary from WK, added wrap up button for large reviews, changed the way results are evaluated and displayed.
0.1.1 Allowed for a more robust parsing of csv and tsv files, added reverse deck option (on by default)
0.1.0 Fixed some performance issues, improved CSV import and added TSV support
0.0.9 Fixed crashes caused by Greasemonkey 2.0 update. (Thank you kobayashi)
0.0.8 Added CSV file import function
0.0.7 Name change and reworked logic

2 Likes

And just because I’m feeling generous, here’s a csv with 14 vocab to get you started. :stuck_out_tongue:

Edit:
I’ve finished the first of my sister’s many many decks, and the file now has 49 vocabulary.

https://www.dropbox.com/s/cqesqwennboml5j/SistersCards1.csv

1 Like

This is awesome.  Thank you so much for your hard work.

I’m sorry Ethan but this clearly does not include a 5,000 word  starter deck, lacks native pronunciation in several dialects and is missing in-context usage, thesaurus-formatted usage notes and comparison against synonyms???

Very well done! I might try it out when I finish WK. For the mean time, any way we can get some screenshots of the interface, what adding vocab looks like, etc?

1 Like
themudman said... I'm sorry Ethan but this clearly does not include a 5,000 word  starter deck, lacks native pronunciation in several dialects and is missing in-context usage, thesaurus-formatted usage notes and comparison against synonyms??????
デッマヅマン様、誠に申し訳ございませんでした。不名誉でした、そして切腹を行う必要があります。

Very well done! I might try it out when I finish WK. For the mean time, any way we can get some screenshots of the interface, what adding vocab looks like, etc?
 Sure I'll put some screen shots up later in the week, but the look isn't much different to Shudouken's original script at the moment, and there are screenshots of that (along with the original script) at the userscript mirror:
http://userscripts-mirror.org/scripts/show/381435
I moved the close window buttons and added some info pertaining to the locking system I implemented. The only other differences are the addition of some extra buttons, (import CSV in the import window,  and reset levels in the edit window). The reset levels button was mainly for me, so I could test the review system without having to delete/add more to the library all the time (or wait 4hrs).

One of the main features I added to original code was a locking system which works with the WaniKani API. The locks have three settings, "yes"(locked) "no"(unlocked) and "DB" (not in the current database), which could happen if the user isn't a paid member, hasn't provided their API yet or the Kanji hasn't been added to WaniKani. At the moment "DB" behaves like it is unlocked, although I am considering having it default to locked with the option to change it.
The idea was that you could add a heap of vocabulary in the beginning and have it unlock as you learn the Kanji on WK.

By the way, I have now completed another of my sister's decks, adding another 25 items if you want them:
5,000 - 74 = 4,926 to go.

https://www.dropbox.com/s/o25s01e07a4qw5a/SistersCards2.csv

I cannot guarantee their accuracy, because although my sister is one of the most studious and diligent people I know, they were made by hand in 2008 from Japanese newscasts and may not be in common usage or natural sounding.
Also, considering they are from newscasts, they cover some rather morbid words ("terminal illness" for example) and giving undue attention to them in your studies may limit your conversational topics and will perhaps not make you the life of your next Japanese shin-dig.

Does this work with Firefox + Greasemonkey?
I get the extra menu in the dashboard, but clicking the buttons does nothing =(

Chiv said... Does this work with Firefox + Greasemonkey?
I get the extra menu in the dashboard, but clicking the buttons does nothing =(
 I haven't tested it in greasemonkey sorry.

I started out in greasemonkey, but my firefox kept crashing (on its own even when there were no extensions running).
I'm currently developing it in tampermonkey on chrome, I'll look into making it work with greasemonkey at some point down the line, just not the immediate future.

I just ran it in Greasemonkey now and it works fine for me.
Edit: the upload CSV button doesn’t seem to work. Perhaps my version of firefox is a little behind HTML5 compatibility.

Can you give me some information on what is happening?
You have the dropdown menu but the windows don’t show up when you click the menu items?

Ethan said... I just ran it in Greasemonkey now and it works fine for me.
Edit: the upload CSV button doesn't seem to work. Perhaps my version of firefox is a little behind HTML5 compatibility.

Can you give me some information on what is happening?
You have the dropdown menu but the windows don't show up when you click the menu items?

Yes, totally right. The last item (after "Learn") is saying: "Please wait...".
If a click on item the url changes from https://www.wanikani.com/ to https://www.wanikani.com/#
What I did:
add the "@" before require
insert my API key.

Tried it with "allow all pop ups" settings.
But my Firefox is strange lately, does not show any furigana on NHK Easy.
I even disabled all Extensions/Addons (only Greasemonkey was left) just a second ago and still, no furigana on NHK and the script not working.
So might be just me.


perhaps the events aren’t firing properly, the “Please wait…” is basically a space filler which should change when the self study button is clicked to show the number of reviews waiting. Really it should only be there when it can’t be seen.

Clicking it should only bring up a window if reviews are waiting, if you haven’t added any, it will do nothing.

Most of the functions do not use pop-ups, they add layers to the page and open and close them by controlling their visibility.

I just updated greasemonkey and now I can recreate the problem.
(by ‘can’ I mean ‘have no choice but to’.)

I’ll take a harder look at it soon, but I got other things that I really should be doing right now.

Would it be possible to add ‘levels’ or ‘decks’ or ‘subjects’ to the vocabulary in order to classify certain vocabulary?

For example, if I’m reading cha no hon and I’d like to add vocabulary from that book to a certain ‘level’ where they are kept discrete from other vocabulary, would that be possible?

themudman said... Would it be possible to add 'levels' or 'decks' or 'subjects' to the vocabulary in order to classify certain vocabulary?

For example, if I'm reading cha no hon and I'd like to add vocabulary from that book to a certain 'level' where they are kept discrete from other vocabulary, would that be possible?
 Yes, managing sources and categories is on my to do list.

Chiv said...
Ethan said... I just ran it in Greasemonkey now and it works fine for me.
Edit: the upload CSV button doesn't seem to work. Perhaps my version of firefox is a little behind HTML5 compatibility.

Can you give me some information on what is happening?
You have the dropdown menu but the windows don't show up when you click the menu items?

Yes, totally right. The last item (after "Learn") is saying: "Please wait...".
If a click on item the url changes from https://www.wanikani.com/ to https://www.wanikani.com/#
What I did:
add the "@" before require
insert my API key.

Tried it with "allow all pop ups" settings.
But my Firefox is strange lately, does not show any furigana on NHK Easy.
I even disabled all Extensions/Addons (only Greasemonkey was left) just a second ago and still, no furigana on NHK and the script not working.
So might be just me.


 Found the culprit, the good news is it's not just you.
Greasemonkey just up and pulled the rug out from under us with the way it accesses objects, the javascript console is going crazy with 'permission denied' messages.

Shudouken's original script won't work either, and is doing pretty much the same thing.

I don't know how long it would take to go through and do things the 'new' way, but I'm guessing it will be sufficiently long that I should postpone it at least until the end of semester when I'll have a bit more time to look into it.

No problem, thank you very much for your hard work!
But do not forget the important things first, before investing more time here!
I think you already did enough for not having much time!

Chiv said... No problem, thank you very much for your hard work!
But do not forget the important things first, before investing more time here!
I think you already did enough for not having much time!
 No problem, I appreciate it.
It still works in Tampermonkey (at least for me :P) if you want to cross over to the dark side.

Here is a basic fix for the GM security issues:
https://drive.google.com/uc?id=0B5GwMqllQD1oc2gtaFVDRjFLR3M

The whitespace looks messed up for me, but I tried to change as little as possible so you can diff it.
This disables sandbox mode and runs the userscript code directly in the page.

Changes:

  • remove all @grants and switch to @grant none
  • remove jQuery @include. use WK’s copy. (without sandbox it breaks WK)
  • add GM_addStyle shim. (replaces GM_addStyle @include)
  • replace unsafeWindow with window (with no sandbox, can access window directly)
  • fix some funny double quoting in the ‘JQuery fixes’ section. this was causing the JS to crash on my firefox. I found the original source and it didn’t have doubled up quotes.
Tested briefly on chrome and firefox.

kobayashi said... Here is a basic fix for the GM security issues:
https://drive.google.com/uc?id=0B5GwMqllQD1oc2gtaFVDRjFLR3M

The whitespace looks messed up for me, but I tried to change as little as possible so you can diff it.
This disables sandbox mode and runs the userscript code directly in the page.

Changes:
  • remove all @grants and switch to @grant none
  • remove jQuery @include. use WK's copy. (without sandbox it breaks WK)
  • add GM_addStyle shim. (replaces GM_addStyle @include)
  • replace unsafeWindow with window (with no sandbox, can access window directly)
  • fix some funny double quoting in the 'JQuery fixes' section. this was causing the JS to crash on my firefox. I found the original source and it didn't have doubled up quotes.
Tested briefly on chrome and firefox.
 Nice, thank you. A lot of that is from the original Self Study that this code is derived from, so I only partially understood it.
I tend to look things up on the fly as I'm coding.
kobayashi said...

Changes:
  • remove all @grants and switch to @grant none
  • remove jQuery @include. use WK's copy. (without sandbox it breaks WK)
  • add GM_addStyle shim. (replaces GM_addStyle @include)
  • replace unsafeWindow with window (with no sandbox, can access window directly)
  • fix some funny double quoting in the 'JQuery fixes' section. this was causing the JS to crash on my firefox. I found the original source and it didn't have doubled up quotes.
I didn't see the link and thought the "Changes" were instructions 笑
Seems to be working now except for the file upload which I will look at today.
Thanks for your help.

Nice idea (obviously goes out to the original author as well!)!
I’ve had the same problems as Chiv in FF and in Chrome the menu doesn’t show up at all, no button or anything.