@Sinyaven I was just wondering if you might be able to give me a very brief idea of how you manage to reorder / change lessons? As far as I can tell, lessons don’t have a queue like reviews do, and the servers just send the pre-prepared HTML DOM for all the items in that lessons session. This seems like it would be a bit of a nightmare to modify. Do you actually reorganize it all manually or is it possible to change it hooking into one of the controllers or something?
Sorry if you’re busy, I was just hoping you might be able to give me a basic idea of how I could go about it (if you remember), as I’m working on getting lessons working in my custom SRS script!
(for now I’m just going to use a custom lesson UI but I’d like to get the proper lessons working at some point!)
That is correct – handling lessons is indeed a bit of a nightmare. But at least you can request the lesson page for any available item by passing its id in the URL (https://www.wanikani.com/subject-lessons/<lesson queue id>/<item id>
). However, since introducing the lesson picker, WaniKani also checks whether the given item id is actually part of the queue with this lesson queue id. Therefore, Queue Manipulator has to first get a lesson queue id for a queue containing all available items by going to https://www.wanikani.com/subject-lessons/picker
and submitting the form with all items selected.
After that, Queue Manipulator internally manages its lesson queue, builds the URL https://www.wanikani.com/subject-lessons/<lesson queue id>/<item id>
for the first item in the queue and navigates to it. The only thing left to do is to make small adaptions to the DOM: change the link to the next and the previous queue item, modify the list of items in this batch at the bottom, and change the link to the lesson quiz. Luckily, the items for the lesson quiz can be passed via its URL.
I’m afraid that none of this will help you with your Custom SRS script, since you want to add items that are not in WaniKani. I think that in this case, your only option is to do the entire lesson UI yourself.
Thanks for writing all that up! As you say, it’s looking like making my own UI will be by far the easiest option. It’s a pity the lessons are so hard-coded like that…
Thank you for confirming it though - I wanted to make sure I wasn’t missing some obvious way to edit items in the lessons or something!
Version 1.15:
Bugfixes after recent WK changes
Recently, WaniKani finished the transition to Turbo, and while Queue Manipulator was already compatible with the way Turbo loads pages, there was a small change to the lesson start URL.
Dropped support for lessons started through the lesson picker
I have decided to drop support for lessons and lesson quizzes started through the lesson picker for the following reasons:
-
One of Queue Manipulator’s main purposes is to allow users to filter the queue to their liking. The lesson picker has the same purpose, so interference from Queue Manipulator is mostly not needed or even counterproductive (e.g. if the user specifically selects a vocab from the lesson picker, but a filter in Queue Manipulator removes all vocabulary so that the lesson queue is finished immediately and the user gets taken back to the dashboard).
It could be argued that handling this is not the responsibility of Queue Manipulator – it should just do what it is supposed to do (also because this means that other useful features like reordering or lesson batch size changes are now missing from lesson picker lessons too). This brings me to the next reason:
-
Queue Manipulator needs to know the original queue before applying the changes to it. However, I don’t know the exact behavior of “Batch, please”, or of “Interleave lessons”, so I cannot replicate it, and I don’t feel like the result is worth the effort of looking more into it. I assume in most cases, the user does not need Queue Manipulator’s functionality when they are doing lessons through the lesson picker. But feel free to bring up counterarguments.
For now, Queue Manipulator ignores the entire lesson started through the lesson picker, unless the user leaves the lesson and re-enters it by going back in their browser history. I decided to ignore this hopefully rare special case.
// @require https://greasyfork.org/scripts/462049-wanikani-queue-manipulator/code/WaniKani%20Queue%20Manipulator.user.js?version=1418003
It would take an impractical undertaking to figure out the numbers, but since I believe Queue Manipulator’s biggest client script is Reorder Omega, that rare special case probably isn’t all that rare or special. But I understand your reasons overall.
In fact that case is the only way I use Reorder Omega. The lesson picker to pick my queue (because I like to group specific vocab together for a lesson), and Omega to reorder and filter it and set the batch size. I guess my question is, if started not from the picker, does Queue Manipulator simply use all available items as the starting queue and then apply the manipulations? This is the only behavior that would keep Reorder Omega usable on lessons for me I think.
Yes, this behavior has stayed the same.
Interesting to know that you combine lesson picker and Reorder Omega – I assumed that users who want that much control over their lessons that they hand-pick the items through the lesson picker would not want a script like Reorder Omega to tamper with their chosen queue.
It’s because I’m very weird about my lesson queue. Before the picker, I needed Omega to do the heavy lifting of creating the queue; now with the picker, the queue creation is less what I need Omega for and it’s more the custom batch size. Furthermore, I was thinking of making Omega’s behavior on the picker page more like [select a preset → selects items according to that preset on the picker page, ignoring sorting operations of course, so all you have to do is click the button to start the lessons and not worry about selecting the items] in my personal fork of it.
My lesson process has been: Upon reaching a new level I start on the new level items by mixing the new radicals and now previous level vocab in a ratio dependent on the number of radicals at that level (so I could end up with 3 batches of 3 radicals and 12 prev lvl vocab, for example). Once that’s done, I do all remaining previous level vocab. After that I start on the kanji, either 3 or 4 batches depending on total number for that level. Once the kanji are done I do vocab until a level up happens and start the process over. It’s always one batch a day and the batch sizes for vocab are all very similar (between 14 and 22, usually it’s 16 unless there was a lot of unlocked vocab) and the batch sizes for the kanji are at most 11 (because as far as I can tell there’s never more than 33 kanji in a level, but that might have changed with so many content updates).
The second reason I use Omega on my picker queue is sorting/ordering. I do not like it when the mixed radical and vocab batch mixes the radicals and vocab; the radicals need to be grouped together at the start and the vocab can do whatever it wants after. But that’s the only instance I order the lessons, so I suppose you are correct in assuming most are not going to really miss the manipulations from the picker.
In any case, knowing that the non-picker path starts with the whole amount of available lessons should make this change fine even for weird users of Omega like myself. I can and have already made a preset that does my New Level Up Lesson Ordering, it just won’t let me choose the specific previous level vocab like I could with the picker and that’s perfectly fine. Although I really would still like the custom batch sizing from picker at least.
Thanks for answering my question!
Oh also, if I remember correctly, way back in the forum thread where the picker was introduced, Scott gave a more detailed answer of the process by which it orders the lessons. I’ll see if I can find that (and more importantly if it’s still relevant) and add to this comment if so.
Comment was
This seems to describe the interleaving option. I’m guessing that “Batch, please” doesn’t do that last step of interleaving but everything else is the same. And for the info on interleaving, this is what the page linked to in the settings links to as an explanation.
So this bug has returned but instead of only being for the radicals now every item type can be affected. I’m getting kanji colored as vocabulary, vocabulary colored as kanji, and so on. It’s only ever the first item. And unlike what I reported before, it’s not due to multiple classes being applied, it’s squarely the wrong class.
I’m still working out how to first track this bug then reliably reproduce it as it still only happens randomly, it’s just that now instead of being very infrequent it seems to be closer to 50% of the time. I’ll keep you posted on my findings.
I have tested this a bunch now, but the problem you described has not happened even once for me. The code that is responsible for fixing the color (class) is admittedly not great – it uses timeouts (lines 214 and 219 in version 1.16) in an attempt to apply the color change after WK has finished changing the color. First after 50ms, and then once more after 1050ms for good measure. Can you determine if WK (or another script) changes the class after the second timeout, or if the class change done by Queue Manipulator is incorrect?
Version 1.16:
- Fixed some issues with lesson navigation
// @require https://greasyfork.org/scripts/462049-wanikani-queue-manipulator/code/WaniKani%20Queue%20Manipulator.user.js?version=1423219
Version 1.17:
- Updated to work with new JSON object structure in reviews
// @require https://greasyfork.org/scripts/462049-wanikani-queue-manipulator/code/WaniKani%20Queue%20Manipulator.user.js?version=1426722
So I’d been debugging a weird issue for a long time and I finally figured out the cause.
function renewTurboController(element) {
element.replaceWith(element.cloneNode(true));
}
This ends up stripping any event listeners for the element and any of its child elements.
Unfortunately, however, I don’t think there’s any “clean” solution to this that still utilizes the node cloning.
A somewhat reasonable compromise might be to fire a custom event with relevant data when this is done, so that scripts could use that to verify their listeners are still in place.
Sorry for the late reply. What relevant data do you want included in the event? The old node and the new node? Also, because I’m curious: is the conflict happening for the quiz-queue controller or for the quiz-statistics controller (since I’m calling renewTurboController()
for both of them)?
Nah my issue was unrelated to the inner workings of your script. I wouldn’t worry about that per se, unless you think there could be an issue.
Works for me.
Version 1.18:
Dispatch CustomEvent in renewTurboController()
If Queue Manipulator for some reason does not manage to update the quiz-queue and quiz-statistics by changing the respective controller’s internal variables, it falls back to refreshing the controller by duplicating it and replacing the old element with the new one. This can interfere with other userscripts, so Queue Manipulator now dispatches an event in these circumstances. The event is dispatched from the new node after it has taken the place of the old node. Example for listening to the event:
.addEventListener("replacedNode", e => handle(e.detail.oldNode, e.detail.newNode))
// @require https://greasyfork.org/scripts/462049-wanikani-queue-manipulator/code/WaniKani%20Queue%20Manipulator.user.js?version=1448112
Hi!! Can I please have assistance on how to use the WK Queue Manipulator? I was trying to figure things out by myself and trying out different things even messing with the script but could not really make it work.
I am trying to limit my reviews per session to maybe 100. I am coming back to Wanikani from 5 months break and it demotivates me to see 1500 items are still in queue for my review. Thanks in advance for the help!!
I wrote a userscript ([Userscript] WaniKani Lock Script) that uses this library to lock a set number of items which I think will solve the problem that you have with a large queue.
If not, it should at least give you a working starting point!
Works like a charm!! Thanks a lot, I appreciate the quick help