I’m not following the WaniKani developments that closely anymore, so I only found out about the recent changes this morning. Sorry for the delay. If anything still does not work, let me know.
Sorry, it looks like wkItemInfo.currentState.reading is now returning [undefined].
It used to contain a list of readings, even when the user has not yet expanded the itemInfo.
To reproduce, just go to any vocab review and type wkItemInfo.currentState into your browser console. Expectation is that reading contains the readings and not [undefined].
I made a few assumptions about what form the data should be in, but I tried to cross reference it with the format retrieved in item pages and lessons, so it should be a good start. It’s somewhat of a backwards compatibility hack, while also now including the new structures under the plural forms of the properties (i.e., readings and meanings).
And @Sinyaven can make modifications as necessary.
Thanks for letting me know about the WK change, and thanks @Inserio for posting a fix. I have based my update on your proposal, but I decided to not add readings and meanings. I want to only include properties that I can provide in reviews, lessons AND item pages.
Version 3.12:
Fixed missing values in currentState after a recent WK update
In particular, _getRootElement().querySelector(`[id=user_synonyms]`) in _updateCurrentStateLesson() is null by the time it is called.
This happens when the user refreshes the page on the lessons page or opens them in a new tab, and in my experience it (and/or some other issue) results in an endless page refresh loop.
Turned off instant-inject mode in Tampermonkey and the issue persists.
I’m not able to reproduce this problem. Since the element with id user_synonyms is already part of the initial html, it cannot be a timing issue. So my next best guess was, that my e.detail.newBody + MutationObserver hack is failing once more. But this hack only applies to turbo page navigations, not to page refreshes, so I guess this can be ruled out as well.
Maybe there is a conflict between scripts? What other scripts are you using?
Hey, I wanted to know if you could add the ability to get the onyomi of an item on the lesson page, if it exists, where they teach you the kunyomi.
Because currently your script returns ‘none’ there because I think this info doesn’t exist on the page. But on other pages like the item info or quizzes the onyomi exists.
Or if you don’t want to add this, do you have an idea how I could access this info on the lesson page?