[Userscript] NHK Easy Practice With WaniKani (or any website that uses ruby)

: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.

I created this script as I like reading news on NHK easy, but I wanted a way to be able hide the furigana for kanji and vocabulary I already know. Currently anything with a Guru I level or higher will have its furigana hidden. It is way to easy for me to read the furigana unintentionally. This script was inspired by the way Bunpro does the same thing for their grammar exercises.

Here is an example with my current WaniKani level:

Userscript Download Location: https://github.com/entropyofchaos/NHK-Easy-Practice-With-WaniKani/raw/main/NhkEasyPracticeWithWaniKani.user.js

Instructions:

I don’t have a GUI yet to set your WaniKani API token, so here are some directions. Please enjoy my skill with Microsoft Paint as to used to create screenshots for you. :laughing:

If you have trouble or questions, please ask.

Here are some basic instructions to get this script working:

  1. [ General Script Installation instructions ] :point_left: You’ll need a script host plugin like TamperMonkey
  2. [Install the Userscript] :point_left: This link will install the userscript into your script manager.
  3. [Create a Personal Access Token] :point_left: Generate a read only Personal Access Token
    2.1 The webpage should look something like the image below. Click on the “Generate a new token” button to create your Personal Access Token

    2.2. Give your token a description and leave all the checkboxes unchecked. My script just needs to be able to read your stats, I don’t need to change anything. :slight_smile:

    2.3 Copy the token you created with the description you gave in the previous step. It will be listed under the “Token” header.
  4. Add Your User Token
    3.1 The first time you open up a page where this script can be run, you’ll get a pop-up to add your WaniKani API Token. Here you can enter the WaniKani token you copied.
    image
  5. [ Open NHK Easy ] :point_left: It’s time to start reading!

Releases:
0.1 Initial Release
0.2 Added ability to store WaniKani API using popup box (Thanks to @lingvolernado)
0.3 Fixed pop-up dictionary to now properly hide furigana based on level (Thanks to @lingvolernado)

Future Planned Features:

  • A user interface to update your WaniKani API Key. Done
  • Be able to click on a vocab word to toggle furigana on and off (same way Bunpro does it).
  • A way to cache your data from WaniKani so the script doesn’t have to download all your progress every time you load the page.
  • A way to set which WaniKani level to use when hiding furigana.
  • A way to filter kanji by JLPT level.
  • A way to add extra kanji you may know to be filtered.
  • A way to hover over a word and see the WK level. Maybe even give a link too the vocab word.

Other Cool Feature:

It so happens my script seems to work with the website https://hiragana.jp/en/. This site lets you give it a link and it attempts to add furigana. If you run my script with the website as well, it will attempt to remove the furigana for your known kanji and vocabulary that was added by this website.

As a note though, it appears the way it adds furigana isn’t always perfect.

  1. Sometimes it will split the furigana in weird ways causing partial furigana for words.
  2. Sometimes you may see words hidden that you don’t expect. This is caused by the fact that the script has to guess if a word in an article matches vocabulary you already know based on kanji readings. This is because of the way the furigana is presented in the HTML. So, for instance, if a vocabular is made up of two kanji with readings you know, that word may be hidden even if WK doesn’t have that word in its vocabulary list.

Expanding Functionality:

This script will work with any site that uses the ruby and rt tags. If you know of any websites that are Japanese and use these tags for furigana, please feel free to suggest them being added to the script’s list of sites to be activated on.

Also, anyone who wants to contribute to making the script better is free to submit pull requests. I have the source setup on GitHub [GitHub - entropyofchaos/NHK-Easy-Practice-With-WaniKani]. So, as long as the changes make sense for the script, I am very likely to be willing to accept your changes.

31 Likes

This script looks promising! :slight_smile: I’m giving it a try! Thanks! ^>^

1 Like

I love it! Thank you for sharing!

1 Like

@ekg I hope you like it. Tell me how it works out for you? :slightly_smiling_face:

@zuzu I am glad you like it.

If either of you find any issues, please share them so I can try to update the script.

1 Like

It doesn’t seem to work for me? :thinking: It’s still showing the furigana.

Oh no. :frowning:

What browser are you using and what are you using for your script managment? I tested this with Tapermonkey and Chrome.

I have TamperMonkey on Mozilla Firefox.

I will download Firefox and give it a try. Maybe its a browser thing. Unfortunately they don’t all work the same.

1 Like

Hopefully it’s something fixable! ^>^ I really like the idea of this script.

So it seemed to work for me in Firefox with Tapermonkey. Sorry if you did already do this but just trying to troubleshoot. Did you edit the script and add your WaniKani API key as I described above?

If you did, could you hit the F12 key on your keyboard. This will open up a debugger for your browsers. Then click on the tab that says Console. If there are errors, I should be able to see them.

Then maybe you can send me a screenshot like this. I intentionally made this fail by not inserting my API Key into the script.

1 Like

Sure! I’ll take a look. :eyes:

So, I only got this:

I also rechecked that the API token was properly there and I saved the change. Looks like it to me.

1 Like

Alright, I will try to look up this error message and see if I can fix it. I am still pretty new to JavaScript unfortunately. I appreciate your help also in helping me debug this.

I bet you could enlist some help from @Kumirei is they have time to spare? :eyes: I know very little coding myself. :sweat_smile:

1 Like

Well, I don’t know @Kumirei, but if they are willing to help, I will definitely take it. I put my code on GitHub with the hope of sharing and allowing anyone to add features for fix things if they want to help.

It never hurts to ask. @prouleau is a talented script author as well. :slight_smile: @prouleau do have time to give a hand with some debugging? ^^

1 Like

I have looked at the error messages and I suspect they are not related to the script. Can you turn off the script and check if the errors are still there? This will show whether my hunch is correct.

1 Like

So, I have seen this error before when I first started trying to write the code. However, I remember that the error would reference the NHK Easy website. Now I see edgekey.net mentioned. Are you using some kind of plugin or something for webpage loading acceleration?

I solved the issue on my machine by decreasing how many items were requested at a time. Maybe it is a similar issue still.

@prouleau Thanks so much for your help. I really appreciate it. :smiley:

I guess it could be uBlock Origin. :grimacing: I’ll try shutting it off! ^^

1 Like

That could very easily be it. If it blocked my script, it definitely wouldn’t work :laughing:

If that doesn’t fix it, if you’re ok to keep helping me test, I will create a separate version with debug logic to try to give some more data as to where the script is breaking.