Homophone explorer

explanation is here:

The “homophone explorer” script performs some data queries internally, rather than relying on an abstraction library such as the open-Framework.
In this particular case, the URL of the API token has changed recently (around March’19). So the URL needs to be updated in the body of the “homophone explorer” script.

Long story short - edit the “homophone explorer” sources, and replace the old SETTINGS_URL value with :
var SETTINGS_URL = ‘https://www.wanikani.com/settings/personal_access_tokens’;

5 Likes

Thanks for this script @Thaos! You rule!

Was broken for me too - looks like the stylesheet may have changed.

To use the purple vocab background you can edit the source, jump down to about line 639 (I’ve got version 0.9.1) and change the t.liWrapper line to the below.

// time to create list item for each item
t.liWrapper = $('<li>',{'class':'vocabulary-' + homophones[readingsIndex].vocabs[i].character + ' character-item'});

Bringing this thread back from the dead, but I just tried this fix and it worked! Thank you, and thank you @Thaos also for the script!

Looks like the script hasn’t been updated so I had to select “Create a new script” from the TamperMonkey dropdown menu, copy/paste the source, and then swap out line 26 with that fix.

@Thaos : do you know if the homophone data needs to be regenerated?

I noticed that 履く and 掃く are homophones, but it does not seem to be reported by the script.

ps : I appreciate your script very much. Could you please also print the WK level of the homophones?

idem for 痛める (to hurt) and 傷める(to wound)

Have a look at http://niai.mrahhal.net/

It has synonyms, homonyms, and similar kanjis.

Here’s the result for “hypothesis”:

5 Likes

I followed all your instructions, reinstalled the script, am running on Chrome, turned off all other scripts, and the script on a vocab page still says my API key is not found. Any suggestions? I would love love this functionality… thanks for any help.

1 Like

Hello,
in the review window, can you please make the font-size the same as the rest of Wanikani’s original content?
To do so, I have the set the font-size to 16px, and let the line-height be automatically computed:

    $('head')
        .append($('<style>',{type:'text/css'})
                .html('.lattice-multi-character a {display: block;color:#fff; text-shadow: 0 1px 0 rgba(0,0,0,0.2); text-decoration: none; '+
                      'box-shadow: 0 -2px 0 rgba(0,0,0,0.2) inset; transition: text-shadow ease-out 0.3s; padding-left: 0.4em; '+
                      'padding-right: 0.4em; font-size: 16px; border-radius: 3px; background-color: #3f7fe9;}'+
                      '.lattice-multi-character li{overflow-x:hidden; overflow-y:hidden; color: rgb(51, 51, 51); display:inline-block; '+
                      'width: auto;margin-right: 2px;margin-bottom: 2px;text-align: center;}'+
                      '.lattice-multi-character ul{margin-left: 0;margin-right: 0;}'));

thank you so much, now it’s working

HOW TO GET THIS SCRIPT TO WORK:

This is a notice to all new users of the script. It took me a while to understand what I had to do in order to get it working, I hope this helps anybody in a similar situation.

  1. Download the script:
  1. On your userscript manager select the script and click “Edit”.

  2. Go to line 26 and replace the line:
    'https://www.wanikani.com/settings/account'
    with:
    'https://www.wanikani.com/settings/personal_access_tokens'

  3. Go to lines 639 - 640 and replace the lines:
// time to create list item for each item
                t.liWrapper = $('<li>',{'class':'character-item', id:'vocabulary-' + homophones[readingsIndex].vocabs[i].character});

with:

// time to create list item for each item
t.liWrapper = $('<li>',{'class':'vocabulary-' + homophones[readingsIndex].vocabs[i].character + ' character-item'});

Special thanks and credit go to @Thaos, @omoide and @quollism.

This answer to this might be hiding somewhere in this thread, but I have yet to spot it - where the homophones should be showing up it says it can’t find my api key - is there more code editing i can do to fix it? I’ve done the code changes on 639-640 and on 26 but the edit to line 26 did not solve the issue. Help :slight_smile:

I’m having the same durned issue. Have you figured out a fix by chance?

This script wasn’t maintained for a long time and was still built on API Token V1, so I’m quite sure (unless I’m really overlooking something here), that it’s out of order, now that 01/09 (09/01 for Americans) has passed. To get it to work again, someone would have to write the script anew, so that it works with the API Token V2.

3 Likes

Yes, the API_REQUEST_TEMPLATE variable, which is used at the very beginning of the script, shows it is a call to the API v1.4

2 Likes

ahhh, and in order to work it would need a straight up retool, vs changing a few lines of code.

I wish I could be the person who makes the updated version, but I’m no coder. :sob:

Two problems:

  • the way to read the API v2 key from the settings page cannot work anymore. The API v1 key used to be marked with a specific Html id, so it was straightforward to query its value.
  • I dont know the details of the v2 API.
    with the v1 API, the script would access specially crafted URL addresses, such as:
    https://www.wanikani.com/api/{VERSION_NUMBER}/user/{USER_API_KEY}/vocabulary/{levels}
    i dont know if it feasible with the v2 API, it seems you cannot just update the URL format, and the new key value.

@rfindley, could you please give some hints? Thanks & Regards

2 Likes

Most likely, it would be easiest to use the Open Framework so you don’t have to do API requests directly. Just do:

wkof.ItemData.get_items()
.then(process_items);

function process_items(data) {
  var items = data;
  [...]
  // Do something here with items
2 Likes

I’m four months late, but does rfindleys answer mean there’s now a way to update the script to API v2?

My understanding was that the code modification to migrate to the v2 API is not straightforward. I have not looked further since then.

1 Like

I imagine this script does not current work?? It’s bloody useufl

1 Like