[Userscript] WaniKani JJ External Definition from Weblio (JP) and Kanjipedia

On various WaniKani pages, the script displays J->J definitions of Kanji from Kanjipedia and of vocab words from Weblio. Weblio results with suitable reading and Part-of-Speech are shown first.

In addition, various radicals can be deemed Kanji, as well as some Kanji aren’t in Kanjipedia, so fixed accordingly. (Weblio aggregates from various sources including Wiktionary and Wikipedia.)

If you have an old version of the script (version 0.10 or below) please upgrade to the new version. [Change Notes]

Note: You cannot simply update your script because the script author has changed, therefore technically it is a new script. Please delete the old script from your computer and install the new version from scratch. Thanks and sorry for the inconvenience!

NicoleRauch's fix for version < 0.5

Get the pre-0.11 script at GreasyFork.

0.10: Displays the kanji readings from Kanjipedia on the kanji, lesson and review pages.

0.9: Bugfix: Accidentally scraping scripts from weblio leads to a blank WaniKani page.

0.8: Adapted script to new weblio page structure (which prevented the script from finding any information).

0.7: General cleanup, bugfixes, layout improvements.

0.6: Initial “new” release. Hotfix for an issue that can lead to error 429 “Rate limit exceeded”

Vocabularies

Kanji

Radicals

Item Pages

13 Likes

CORS has to be done on the server side, so unless you control the server, the only option is to use a CORS Proxy. A proxy is a middle-man server that adds the headers needed to bypass CORS.

See [here], for example, though I haven’t tested this particular proxy.

Updated the screen for Kanji. Also removed する for the する verbs

If you need a proxy, delete Line 23

proxy = '';


Confirmed not to work

Error:

Works with GM_xmlhttpRequest (greasemonkey has better examples, same API).

1 Like

Just as I am getting fucked by HTTP (Kanjipedia), but not HTTPS (Weblio). Works like a charm. Also works without ‘Disable Cross-Origin Restriction’.

BTW, it needs // @grant GM_xmlhttpRequest

Interestingly, it is GM_xmlhttpRequest, but GM.xmlHttpRequest. I use TamperMonkey on Safari, BTW.

Use @connect to whitelist domains by default and to avoid a spooky prompt window.

// @connect kanjipedia.jp
// @connect weblio.jp

2 Likes

Fixed the script to use observer() and MutationObserver. Please see if it still breaks.

Assuming you want to update new item:

$.jStorage.listenKeyChange(‘currentItem’, function(key, action) {
// do your stuff
});

jStorage documentation
Then you can just listen see if the info tab was opened or if whatever event you care about was triggered.
Anyways, doing this through jStorage might save you some sanity points.

Now, also added to lesson pages and item info pages.

ERROR: Execution of script 'WaniKani External Definition' failed! Argument 1 ('target') to MutationObserver.observe must be an instance of Node

Seems it is no longer works on info pages.
On review session all is ok.

Safari 12.1.1
Tampermonkey

1 Like

Which userscript can change “Vocabulary Meaning” to ”意味” in the prompt banner, as seen in the OP’s screenshot? I’ve searched for probably 3 or 4 hours and thought there wasn’t anything that could do that.

BTW, I noticed that during some vocabularly lessons this script was generating many 404s for random images like 7.png and others which looked like they could be icons for definitions. I couldn’t tell why the images were being loaded from the stack trace but once I disabled this user script they went away.

I think there is v0.6 – WaniKani External Definition by @NicoleIsEnough

Is it fixed yet?

Uh - thanks for the reminder! :see_no_evil: :flushed:

I worked on it for some more but then life happened… Will look into it asap!

Also, @NicoleIsEnough

v0.6

Might be fixed now, by using @lyo/cheerio - npm

// @require https://cdn.jsdelivr.net/npm/@lyo/cheerio

I just checked the code of the version I released more than a year ago (v0.6) and it fixes the problem with the WK error messages. So all good so far :slight_smile:

Back then, I had noticed that there were quite a few situations where the userscript would not work correctly for me (i.e. it would not give me a definition, and there were some issues with displaying the definition), and so I slowly started rewriting the userscript to address these issues. As it has been a while, I’ve released the current code today as v0.7: WaniKani External Definition

If anybody still notices vocab words or kanji for which the information is wrong or is not being displayed, or any other issues, please feel free to notify me here.

Thanks for sharing your work

2 Likes

@NicoleIsEnough Weblio definitions for all vocab don’t seem to be working (i always get Definition Not Found displayed, but the external link to weblio does work). This is true in lessons, reviews and on vocab pages. Kanjipedia definitions for kanji are working fine. I’ve tried turning off all other scripts as well

Thanks for the heads up! I can reproduce the behaviour on my end. I will look into it - probably they just changed the structure of their pages or something.