[Userscript] Wanikani Review Answer History

No, the radicals still don’t work. I went through your code with step-by-step debugging and there are still a few problems:

  • In the case of a radical review, let itemType = itemElem.classList[0] is radical, but WKAnswerHistory does not contain a property radical but only a property radicals, so the line if (!WKAnswerHistory[itemType][item]){ throws an exception.

  • I have now tested your script on a different PC where I have Reorder Omega installed, and item = itemElem.innerText now results in

    女
    Preset: 
    Sort
    

    because Reorder Omega adds a preset dropdown to the interface. Furthermore, if the item is a radical, you return the entire item object in getItemSRS("item") and then try to use it as if it were a string containing the slug in the line if (!WKAnswerHistory[itemType][item]){ (item is not a string containing the slug at this point!).

    Instead of trying to read the slug from the DOM which is more likely modified by other scripts, it would probably be better to always read it from the wkof item with items_by_id[review_item.id].data.slug.

  • Regarding slugs: does anyone know if they are now guaranteed to stay the same for every WK item? In the past, some radicals were renamed (for example butcher => building, and its slug is now building). Unless they never again do a radical overhaul, using the type/slug pair for identifying items might break at one point.


Alternatively, all these problems could be avoided by using the unique item id instead of the type/slug pair for identifying items: During reviews, the id is directly available in $.jStorage.get('currentItem').id, and on the item pages, you can get the id with parseInt(document.querySelector('meta[name=subject_id]').content).

2 Likes