WaniKanify for Firefox


#1

NOTE: I won’t update this script in the future. Kaimera added some features to this script, though, which you can find here https://greasyfork.org/en/scripts/5164-wanikanify-vocabularizer More details on page 3.

Hello,

I really like the WaniKanify app for Chrome, but unfortunately I much prefer to use Firefox, so it’s a bit annoying to switch between the two. So, I looked for a FF port of the app but didn’t find any, therefore I felt like making my own script.
It is a userscript - not an add-on. I’m still a user script development noob, so the user experience really  kind of sucks for now. I just wanted to see if this works at all for you guys.

Install link: https://greasyfork.org/scripts/4719-wanikanify

By default it will run on every website, but not until you choose "Run"i n the Greasemonkey settings menu. The vocabulary can be manually refreshed there as well (which should be done after unlocking new vocab). When using it for the first time, it will automatically ask you for you API key. You can modify which pages this script should run on in its GreaseMonkey settings.

The script’s word detection is currently pretty simple; it attempts to detect vocab such as “United States of America” before replacing, say, “State” by 洲, but it’s not perfect yet. Also, it attempts to conjugate verbs somewhat (no support for irregular verbs at all).

Here’s a screenshot













Wanikanify
Wanikanify - A Google Chrome Extension
Wanikanify
Wanikanify
Wanikanify
Wanikanify
Wanikanify - A Google Chrome Extension
List of API and Third-Party Apps
The New And Improved List Of API and Third Party Apps
Wanikanify - A Google Chrome Extension
[Unsupported] App Store script
#2

Thanks, I will give this a try tomorrow.  I also prefer Firefox so I am excited about the work you have done on this!  One thing I would mention as a lesson learned from helping on WaniKanify is that you really should specify the API version in your call so that updates to the API don’t break your script.

Replace this:

http://www.wanikani.com/api/user/” + API_KEY + "/vocabulary/"
With this:
http://www.wanikani.com/api/v1.2/user/” + API_KEY + “/vocabulary/”


#3

Thanks, you’re right! Updated.
BTW, for now the script will (apparently) replace the vocab of the entire level that you’re on, even if you haven’t unlocked all the vocab from that level yet. I need some rest now, though!


#4

It seems there’s something wrong with the script. Running this just causes Firefox to freeze immediately.


#5

Well, since you’re on level 45, that might be because the amount of vocab is so huge and my code is inefficient. Sorry! You can press ctrl+shift+K to open the console and see if you’re getting any error messages after executing it  (it would be good only view JS and log notifications by disabling all other ones).


#6

Cool! I wrote Wanikanify for Chrome, and actually have been doing some development on it this week!

I’m going to have a lot of free time in February so I hope to have a new version for Chrome out then.

Thanks so much for the port! You rock!


#7

Thanks! I actually just had a look at your code and I’m using your word replacement method right now. That jQuery replaceText function is awesome! My only problem with it is detecting expressions that consist of multiple words. Right now I’m using a naive approach that first searches for 4 words at once, then 3, then 2,… but the problem there is it will only work if the words are aligned properly (e.g. “The United States of America” will check “The United States of” instead of “United States of America”) :confused:
 Gotta see how to fix that.

Anyway, the new script is online. nullterminator, please try this version - it’s a million times faster and does not slow down if you have more vocab (except once when creating the vocab table). People who already downloaded it yesterday should make sure to remove it from their Greasemonkey scripts, because it has a different name now (Simply Wanikanify - I’m sure chedkid is okay with it :p). It will only refresh every 12 hours, because I fear refreshing will take pretty long for level 20+ guys.

My next goal is to add some kind of UI so the user experience gets much nicer. Forcing the vocab to refresh, being able to filter out certain vocab (like in the chrome app)…


#8

@looki There is probably a smart way of doing text replacement and synonyms. My initial goal was not write a translator, or something that approached one. My use case was merely to put some Kanji on my webpages.

Simply Wanikanify is a great name!


#9

I just tested it out and it is working quite well!  My only initial suggestion is that you don’t include the entry in the vocabMap unless it has an SRS level.  That way it won’t show Kanji that haven’t been learned yet.


#10

I see, chedkid! Of course I don’t want to build a translator either, I’d just like more words to be replaced :slight_smile:

kelderek, you’re right; I actually briefly tried implementing that last night but I was way too tired and my JavaScript skills are so bad that I couldn’t figure out how to check if a field in an object is present! :stuck_out_tongue: I’ll try and figure it out right now.

EDIT: Updated the script, not yet learned words will not be replaced anymore.


#11

@looki, btw if you want to add some changes to the Chrome application (for example the substitution idea), feel free to send a pull request. 

https://github.com/josefalcon/wanikanify


#12

Alright! Not sure if that’s gonna happen though, given that I don’t use Chrome and have no idea how to write apps.

Update: WaniKanify is now by default enabled on all websites, but doesn’t actually execute until you choose ‘Run’ in the context-menu (see first page for screenshot). You can also now manually refresh the vocab and change your API key.

https://dl.dropboxusercontent.com/u/80112437/WaniKanify.user.js


#13

Update request via e-mail: You can now enable the script to automatically run on every page in the context menu (“Enable auto-run”).
Also, whenever the vocab is updated (and new vocabulary was imported), a popup will indicate this. Additional, manually refreshing the vocab will also indicate whether the vocab is already up to date or not.

https://dl.dropboxusercontent.com/u/80112437/WaniKanify.user.js


#14
I'm a Safari user and wanted something like that too, so I tried loading your script into ScriptBlocker (the Javascript blocker extension for Safari with a feature to add user scripts). Somehow contextual menus don't work so I can't interact at all with the script but I tried replacing every instance of :

var apiKey = GM_getValue("apiKey");

with :

//var apiKey = GM_getValue("apiKey");
var apiKey = "[my own API key]";

and commenting this line :

//if (GM_getValue("autoRun") == 1)

so the script always run automatically and it works like a charm! However if I want to disable it temporarily, I have to do it via ScriptBlocker.

Anyways, just thought I'd share my solution in case anyone else needed it! Thank you very much for the script!
P.S. I also commented  //alert("Successfully updated vocab!"); because it would do it on every page load, and if a page pulled other pages (like Google ads), it would alert me multiple times.

#15

Thanks. I never thought about other browsers than Firefox! Maybe I’ll try to come up with a nicer solution. Anyway, based on your input I just modified the code so the popup will only appear. Also I added auto-updates via the Greasemonkey @updateURL tag.


#16

Huh? (One possible fix is to manually override the watch method of vocabMap, but it’s a bit hacky).



Update: okay, fixed it. Replace the replaceCallback function with this.
Update 2: I also would prefer GM_registerMenuCommand here, since most commands (autorun switch, API key change and vocab refresh) aren’t frequently used, and most people would have autorun enabled, which would eliminate need for the “Run” command as well. GM places commands in its own menu instead:

Aaand another useful link: GM_config is a really useful (as I think) library for userscript developers which allows to make a better, more user-friendly settings UI.


#17

People still use Google products?  I use Safari here.  No WaniKani for me :frowning:


#18

Sorry for accidentally ignoring you there, iamale. :stuck_out_tongue:
The script has been updated to fix this bug and also uses the GreaseMonkey menu now. This should also make it more compatible with other browsers. I plan to update this script soon (more features, better vocab replacement and user interaction) when I have more time.

https://greasyfork.org/scripts/4719-wanikanify


#19

why not edit your post with the updated link?


#20

Oops. Because I had almost no sleep. Thanks!