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

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 @NicoleRauch

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, @NicoleRauch

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

@NicoleRauch 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.

Just as I thought, Weblio has changed something on their pages. The issue is should be fixed now. Thanks for reporting!

You can download Ver. 0.8 here: WaniKani External Definition
or e.g. upgrade it on your Tampermonkey dashboard.

If you find any pages where the definition still does not get inserted, please feel free to post the links here so I can look into it again.

2 Likes