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


#1

https://greasyfork.org/en/scripts/35970-wanikani-external-definition


Learning Alternative Correct Responses
Complementary study material for Kanji
Leech Squashing
Getting the most out of vocabulary lessons
Better immersion vocab script possibility
Source for better (ie, more Japanese-like) meanings?
#2

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.


#3

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

If you need a proxy, delete Line 23

proxy = '';



#4

Confirmed not to work

Error:


#5

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


#6

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.


#7

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

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


#8

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


#9

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.


#10

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