Updates to Lessons, Reviews, and Extra Study

Thanks for the input.

It looks like my approach will be to listen to willShowNextQuestion to know what the upcoming question is, and also to modify the quiz-queue, replacing the correct reading with the onyomi version when appropriate. I wanted to do it by messing with the function that evaluates if the input is correct, but I don’t think you can change event data after they’ve been fired, and I couldn’t figure out how to reach the AnswerChecker to convert the input back to hiragana right before evaluation.

The data shown in the info dropdown is not pulled from the quiz-queue, nor does it seem pre-rendered so it seems I will have to handle this by looking for changes in the DOM, like I did before.

just found this, then what code equivalent to this? (i’m working on someone’s script)

var currentItem = $.jStorage.get("l/currentQuizItem");
var currentquestiontype = $.jStorage.get("l/questionType");

I think (but I can’t confirm) that you are supposed to do

 window.addEventListener('willShowNextQuestion', newQuestion);

The event that is passed to newQuestion contains the information on the upcoming (if the page just loaded the event will fire for the current item as soon as you do anything) item.

  var newQuestion = function (e) {
       var currentquestiontype = e.type;
}

Note that this is likely to require a larger refactor since you can’t pull the data on demand with this method.

1 Like

Look for the list of events up above.

Try, (or perhaps some other events)

window.addEventListener('willShowNextQuestion', (e) => {
    console.log(e);
});

I think it is a CustomEvent object, with contents inside e.detail.

Data on demand is

JSON.parse(document.querySelector('script[data-quiz-queue-target="subjects"]').textContent)[0];
2 Likes

I actually think this was the right call. Like many here, though, I didn’t appreciate how many users would dislike this change, especially since “enter” works during reviews. Kudos to @Sinyaven for catching this.

Following standards for enter and tab navigation makes sense, but what is a user supposed to tab TO on lessons pages to navigate to the next item?

It’s not a problem with reviews, since a text input for your response is active, enter proceeds to the next item.

I just created a new account (so I could have some lessons) and it appears there is no input or button on lessons pages that always proceeds to the next item. The 5 (or however many) items have buttons on the bottom, but you’ve got to do a LOT of tabbing to get there.

Wouldn’t the simplest solution to this one user complaint be to add an input or button to the lesson pages (labeled “continue”, “next”, “>” or something?) with tabindex=1? That is, it seems like there should be something equivalent to the text input on review pages.

Sorry I am not sure I have entirely understood what you are asking. A user can tab onto the slide navigation buttons and press enter to go to the next slide. If they want to skip to the next subject/item they can use the g shortcut key. Does that answer your question?

The use of enter key on a form input field is expected to do one of 2 things, submit the form (which is the default) or navigate to the next input field (this requires special handling by the developer). This is why it works in reviews as using the enter key is used to submit your answer.

Sorry I wasn’t clear, I’m doing umpteen things at once atm.


EDIT:

Apologies, I missed the bit about using g. It’s possible I’m not the only one.

Regardless, I’d still think the first tab item should be a button that does what g or d or all apparently do (and that enter used to).


Before the update, hitting enter once took users to the next page.

I just tested in my browser, and it took me typing tab seven times to get to this point:

Then hitting enter gets to the examples.

Then five more tabs and another enter to finally get to the next subject.

Shouldn’t their be a right-chevron, proceed button with tabindex=1 that always proceeds to the next page when activated with enter?

@tofugu-scott a big positive, is that the pause I noticed inbetween lessons is unnoticable now that the changes have been deployed to the production environment.
Nevermind, seems like it really depends on the kind of mood the system is in, it’s back to quite a noticeable pause.

2 Likes

Sorry that it took so long. In the new version, any calls done to wkQueue in immediate succession (i.e. without any awaits in between) are grouped together into a single queue recomputation.

@require  https://greasyfork.org/scripts/462049-wanikani-queue-manipulator/code/WaniKani%20Queue%20Manipulator.user.js?version=1167374
3 Likes

How does this work exactly? I just updated to the latest version and doing wkQueue.lessonBatchSize = 9 without an await immediately updated the UI. This was in the console though, so I don’t know if that works differently for some reason.

Before calling the internal function that recomputes the queue, I added an await true;. This means that the control flow goes back to the code that did the call to wkQueue, and only once this code is finished, the control flow goes back to the code following the await true. And even if during this period, there were multiple calls that require a recomputation of the queue, I only do it once.

1 Like

I never considered that awaiting a value is the same as a 0ms timeout

Is there no kind of race condition or timing issue with this approach? I’m probably missing something (as I’m not really familiar with how async works in JavaScript), but that was my worry.

I will admit that I don’t understand what the await true or the requestApplyManipulationsGeneric method are doing at all.

This describes my motivation for using Lesson Filter precisely. Large blocks of kanji followed by large dumps of vocabulary don’t work as well as when I can interleave vocabulary with guru’d kanji.

2 Likes

@tofugu-scott While looking at what it would take to migrate my script, I noticed none of the elements have ids anymore which is what I was using to figure out where I wanted to insert stuff. Was that a conscious decision? Kind of curious as to the thinking behind the design.

Javascript is single-threaded, so it won’t cause a race condition. The control flow will only return to the queue manipulation once your code has finished executing (or pauses because of an await).

I’m not remotely following how that happens or where that logic is, but I guess I’ll take your word for it. :sweat_smile:


Unrelated question… I’m really not happy about the thought of the queue not honoring the WaniKani lesson order. I know Scott discouraged it, but it doesn’t seem that hard to reimplement the ordering options. After all, the options are level then type, level then random, or random. All of which seem easy to implement with basic sorting functions given the level, type, and user preference can all be retrieved from the API. So two questions:

  1. Do you think it would fit in with the theme of your script to implement that behavior within it and are you willing to add that?
  2. If not and assuming I want to do it myself, is there any part of your script I’d still be able to leverage (like applying the changes to Turbo) without getting messed up by the summary endpoint’s arbitrary order? Or would I be better off just building it all myself at that point?

I do think that this would make sense to have in the script, but I don’t know when I will have the time to do this. Furthermore, this requires even more info from the API, and at that point I think I will keep the Open Framework dependency to at least have the benefit of the wkof caching.

2 Likes

Can you elaborate on this please? I was using jStorage to get the currentItem during a review. What is the migration path for the same functionality?

I presume I need to listen for this event. However I am not familiar with Turbo, nor with how to access the data, or properties, of an event.

Is there simple snippet that shows syntax for this event?