Works well so far, thanks!
Hey. Am I crazy or did you remove some feature requests from your post? I didn’t have time to answer until now… Don’t hesitate to ask!
Sorry about that, but I decided to have a shot at it. It’s by no means perfect and performance may currently be of some concern when replacing words in “var replaceCallback”.
https://greasyfork.org/scripts/5164-wanikanify-vocabularizer
Just a heads up, you may wish to edit your original post’s URL to gresyfork - when clicking it, it instead goes to the dropbox version, so I worked with that initially. Truth be told, I prefer the right-click context menu. It’s a bit underwhelming in how GM allows you to control the menu from the toolbar, and I find it easier to access from a context menu.
With that out of the way, the notable changes are:
- The menu creation that initially happened at the lower half of the script is now entirely sectioned in the top of the script. Logo is now base64 embedded, which also doesn’t raise HTTPS issues in browser bar anymore (ie: mixed secured content).
- Majority of the menu checks have been simplified, I think. Could do with some more work with the API key thing perhaps, but eh…
- Removed checking of new updates automatically, it became annoying and interferes with new functionality.
- New Functionality (which were my suggestions in the previous post): Three user-editable arrays at the top of the script. The user can now ignore specific meanings from WaniKani entirely, add their own custom words with either choice of having them automatically conjugated or to be exempt from conjugations. (PLEASE BACK YOUR ARRAYS UP IN CASE UPDATES OR GM OVERWRITES IT!)
- Removed hash code checks of currently stored JSON in the SQLite DB, as it was now redundant - instead, the previous entries are deleted (rather than set with: GM_setValue(“value”, “”) as you had specified previously).
- Re-implented your “downloading” check, as it was never being utilized (if I remember correctly, it wasn’t in any conditions or any suitable conditions).
- Filtering function now removes duplicate entries from the ending JSON array, thus the array can only contain unique objects (ie: I’ve removed key:value maps).
- Added Kana to the titles of replaced strings, rather than it only being English and Kanji
Conjugations definitely require some work however, so that’s likely next. Although it’d be nice to work out an alternative replaceCallback for string replacement that doesn’t require a for-loop in my array of objects scenario.
Hopefully you’re okay with all that If you have anything to add to that, please let me know.
Edit: Replaced the for-loop with your method, re-purposed the way it was assigned for it though. Performance is now fine. Your base script was actually quite pleasant to work with, thanks! Again if you wish to let me know of redundancy in my fork, please let me know.
Hey, that sounds really great I’ll check it out very soon! I find it hard to believe my base was pleasant to work with; this was my first WK userscript and I have little to no Javascript experience (except for userscript dev). Also I didn’t really think about making the code readable for others, haha.
In case you’re using github, you could fork my code https://github.com/looki/wanikanify to develop your changes.
It was definitely better than not having a base at all. I’m new to editing in GM myself, and have only a couple of other scripts I’ve either made or forked on my GreasyFork. In fact I didn’t realize “GM_xmlhttpRequest” existed, so that made things surprisingly easier from what I can tell. Now that I’ve properly gone through the documentation it appears to be lacking a lot of things you’d expect otherwise though. I don’t happen to use GitHub, sorry! I’m still trying to work on some nuances and making the script easily accessible before I release it proper (currently unlisted on my account), not to mention conjugations. While refreshing vocab a lot of performance increases could be made I believe, especially as ‘for…in’ is hardly optimal compared to a for-loop, and may not need to go over object properties.
Edit:
You may want to fix conjugations around line 176 on version 1.4 from your GreasyFork code:
// Remove leading ‘to’Should instead be:
meanings[m] = word.substr(3);
// Remove leading ‘to’Otherwise the conjugations will not be added (eg: ed, ing, etc). Or so my testing and console logging seems to find.
meanings[m] = word.substr(3);
word = meanings[m];
Edit:
Tried profiling for loop vs for in performance via the firefox profiler, getting these timings in ms:
For loop: 1361 / 1168 / 775 / 716 / 814 / 979
For…in: 1093 / 1272 / 783 / 940 / 982 / 1413
Performance seems fairly comparable and negligible currently, however the for-loop seems generally better from this small test range.
Edit:
Seems Firefox’s compiler prefers i++ rather than ++i. For loop seems to be averaging around 600-700ms.
Edit:
I’ve properly released my version here: https://greasyfork.org/scripts/5164-wanikanify-vocabularizer
I’ll refrain from posting anymore on it in the future here as to not derail from your version and the work you’ve put into yours. If I feel it’s worthwhile in the future I may create my own thread, however again, thank you for your base script.
That’s hilarious, somewhat, and the fault of the user.
Frankly, the scripts from Looki and myself only affect the page on load. It shouldn’t affect anything afterwards, for example any dynamic text or even a google search results unless the script is manually re-run. So that person from that reddit thread must of been using the Chrome version maybe? Or a different script/add-on entirely.
In the case of our scripts, you can exempt specific sites from being affected by the script in GreaseMonkey for example. Or, disable it entirely or tell it not to auto-run for a short period of time.
Hahaha, that’s great. But yeah, as Kaimera said, that should not happen with this.
Kaimera, I’m stunned by the amount of work you’re putting into this! To tell you the truth, now that I’m at a pretty high level I’m not really using the script anymore but instead try to read more actual content, for which I still have my kanji highlighter script (which I’ll rewrite soon enough~) That’s why I haven’t updated it in a while. Still, the script is neat and I’m glad it will continue to live on in your hands. I think it’s pretty clear that you know your way around this so I don’t see why I should even bother to update mine anymore, haha.
It’s really strange that Firefox is faster using i++. It doesn’t make sense from a logical point of view; one would think it’s EXACTLY the same with today’s code optimizers but even if not, ++i should be faster since it doesn’t need to copy the old value.
You’re free to post in this thread and I’d gladly update my original post for you. You can also just open a new thread. Whatever suits you best.
Maybe the firefox profiler isn’t that accurate compared to say… Javascript’s window performance functions. Either way compilers these days seem fairly well optimized for it, so it shouldn’t be an ordeal.
If you did update your thread to link to my version, that’s entirely up to you. As long as you’re credited still I’m okay with whatever xD
I did find EhonNavi to have some 600+ hiragana Children books, the issue with that however is still taking the time to constantly translate new vocabulary not yet seen in SRS. As it is with WaniKani taking my time now I’ve had to keep my schedule more in check, so I’d rather not burn out or overload myself with books just yet unless I could see what the main vocab is beforehand to memorize that before continuing.
Kaimera said... So that person from that reddit thread must of been using the Chrome version maybe? Or a different script/add-on entirely.The same poster said later that it was indeed Wanikanify, but yeah it could very well be the Chrome version.
Great work, thanks!
I just installed this for firefox - not gonna lie, it’s pretty slick.
Just installed this. It works great so far!
Kinda hilarious, now my browser’s a weeaboo °3°
No but really, it’s a fun script and I’ll probably have it enabled for a while every now and then just for the funsies and maybe to see how many of the vocab I could actually already see/use on a daily basis (even though things like “I am” become “I 午前”, but fixing that would be too much to ask, I’m aware of that).
Anyway, thanks for giving me some 楽しみ. pun intended
RayderBlitz said... Kinda hilarious, now my browser's a weeaboo °3°If you used my script (previous page) you can filter these out, so "am" won't be replaced. I can't remember the full extents I wrote that in, but it worked.
No but really, it's a fun script and I'll probably have it enabled for a while every now and then just for the funsies and maybe to see how many of the vocab I could actually already see/use on a daily basis (even though things like "I am" become "I 午前", but fixing that would be too much to ask, I'm aware of that).
Anyway, thanks for giving me some 楽しみ. *pun intended*
Edit:
I've properly released my version here: https://greasyfork.org/scripts/5164-wanikanify-vocabularizer
Yep - sorry, but I don’t support this script anymore. Luckily Kaimera made some improvements to it. I added your version to the OP.
Kaimera said... If you used my script (previous page) you can filter these out, so "am" won't be replaced. I can't remember the full extents I wrote that in, but it worked.Ah, tyvm dear sir.Edit:
I've properly released my version here: https://greasyfork.org/scripts/5164-wanikanify-vocabularizer
looki said... Yep - sorry, but I don't support this script anymore. Luckily Kaimera made some improvements to it. I added your version to the OP.Oh, I didn't mean to nag about it since I have some programming experience myself and I know those little things can be a hassle at times, I merely meant to mention what I noticed without trying to rant about things I want. Sorry if I came off as rude.
I'm happy with it as it is, since for me it's mostly just a fun-script (hope that doesn't offend you in any way, but probably not), so I wouldn't even mind not having a script-script like Kaimera's since yours does the deal for me. But since it's there I'll gladly use it as well.
Haha, don’t worry, I didn’t take any offense to that or anything. Just wanted to point out that this is no longer in development.
looki said... Haha, don't worry, I didn't take any offense to that or anything. Just wanted to point out that this is no longer in development.Hehe, alright.
I guess it's finished anyway, or isn't it?
Hmm, I mean it seems to work fairly well, and this was pretty much just a port of the Chrome plugin with the same name, so I guess so. I even made it a little bit smarter than the Chrome one, I think.