[Userscript] Reorder Omega

Reorder Omega

:warning: This is a third-party script/app and is not created by the WaniKani team. By using this, you understand that it can stop working at any time or be discontinued indefinitely.

Why “omega”? Well, I had to up the ante from Reorder Ultimate 2

Already convinced? → Install Now ←

Sorting and Filtering

This is a highly versatile script which allows you to define presets consisting of actions, each of which can either sort or filter your items.

Each action can be of either of these types:

  • None: Does nothing
  • Sort: Sorts! Available sorting options are level, SRS, leech score, overdue, and type
  • Filter: Filters! These are WKOF filters, so if you get other scripts which include filters you can use those here.
  • Shuffle: Randomizes the order of the queue
  • Freeze & Restore: This is a special type which locks in the items you have already sorted and filtered, then brings back all the items you previously filtered out. This can be useful when designing more complex presets.

During a session you can easily switch between preset (although the idea is that you shouldn’t have to) by simply picking your poison from the drop-down

1

Self Study

With the advent of Extra Study I though it would be nice if you could somehow use these presets to sort and filter all items on Wanikani for a Self Study mode. If we do this on the Extra Study page you can leverage all the other scripts available for Extra Study, which would be a great boon. That said, this is not intended to be a replacement to the existing Self Study Quiz script, as I am most likely not going to be implementing all the features it has.

To get to the point, this script creates a button in the Extra Study section on the dashboard which takes you to a special instance of Extra Study where you get all the items on Wanikani and you use presets to narrow down what you want to study.

Other Features

While I was at it I thought I could also spread some of my favorite small features to the users of this script. These are not all enabled by default, but they are available for anyone that is interested.

  • Egg Timer: Displays how long you have been in a session
  • Streak: Displays number of correct answers in a row
  • Burn Bell: Plays a bell sound when you burn an item
  • Back To Back: Places meaning and reading questions after each other
  • Prioritize: Makes it so that meaning or reading always comes before the other
  • Voice Actor: You can choose to either randomize or alternate voice actor if you would like

Installation

→ Get the script here ←

If you catch any bugs don’t hesitate to report them.

Source

This script was written in Typescript, if you want to look at the source code it’s on GitHub

87 Likes

@rfindley It seems you have competition now. :wink:

6 Likes

I really like the preset idea. Depending on how many reviews and how much time I have I like to sort things differently, so this is a lot more convenient than my previous approach of just changing script settings every time.

I can’t currently seem to get either back-to-back or sorting to work though. Although it seems to initially sort the first item correctly, subsequent items seem to appear in the default random order. I’m also occasionally getting this error on the review page, although it might not be related to the actual sorting, as that seems to misbehave even in sessions where the error doesn’t pop up:

5 Likes

This seems like a cool feature :wink:

I am really surprised by the timing – just a few hours ago, I was re-reading our discussion about Reorder Omega and was wondering if you are still working on it or if I should try extending my Extra Study: Burned Items script to allow more control over the queue. But it seems like I don’t have to bother with Extra Study: Burned Items anymore :laughing:

1 Like

Hm. I expected some issues, but not with that, as I just took that from the back-to-back script I already had. I noticed and fixed a slight mistake with the active queue key. I don’t think that would cause your problem, but can you update and check again?

1 Like

Honestly, I am so happy that you brought it up back then. It was like the missing piece of the puzzle

I hadn’t touched it in a long time, but I got inspired by Extra Study and decided to start working on it again. I felt a bit bad when you started (and kept) working on the extra study scripts, as I was going to effectively replace it in a couple of days sweat_smile The audio only mode is really cool, though. I thought about incorporating that in my script, too, but I ended up not doing it

1 Like

No problem, the Burned Items script was initially only intended as an experiment anyway.

Seems like it is not compatible with Reorder Omega. I’m wondering what the problem is.

EDIT: Oh, of course – the queue fetch is invalid, so when I try to filter only the fetched vocab items it throws an error.

1 Like

I’ll see if I can narrow down what’s happening with the sorting and back-to-back mode tomorrow afternoon. Greasyfork hasn’t synced the update yet it seems, so I’ll have to check if the update worked tomorrow as well. :grin:

1 Like

This looks great!

Any chance there could also be the option to alternate voice actor?

A really useful one though, you got it made incredibly fast!

Do you think it’ll be fixable? Otherwise I’ll have to stay on your burned item script - your voice mode one is now an indispensable part of my daily practice :smiley:

2 Likes

I imagine we could get it to work by working against jStorage only. I don’t touch the fetching logic at all, I just work with jStorage

Thanks!

Oops, looks like it didn’t automatically sync on push. Sometimes it takes a couple of syncs until it starts doing it

2 Likes

That is a good idea. I’ll think about it! Could probably make it a dropdown to choose between default, random, and alternate

1 Like

One of the reasons why I did the item filtering directly in the fetch is to avoid problems with the internal caching that WK does for the next 100(?) items. If I remember correctly, they cache the next 100 items and only replenish the cache when the number of items in the cache drops below… 20 I think? But if I manipulated the queue in jStorage, chances are that the cache will be filled with useless items because they were filtered by my script.

But I haven’t looked at that code in a few months, so maybe they already changed it.

2 Likes

Oh, I remember reading about that, but had forgotten all about it. Perhaps this script is fundamentally flawed, then. I haven’t had any review sessions of that size while testing. All the ids are available in jstorage and it seemed enough to just replace those, but maybe I wasn’t paying enough attention

1 Like

Maybe we can just ask the WK team to improve their code to correctly handle queue changes. But first I have to check if the code is still the same as I remember.

1 Like

The WK code has really changed since the last time I looked at it. It is practically unreadable now. I think I found the relevant code at line number 31909 (at least after letting Chromium format the code which otherwise is all in one line):

image

Z seems to be the cache, and R is probably what was called QUEUE_THRESHOLD in the past – so I think the problem with the cache still exists? It is really hard to tell from this minimized code.

1 Like

More like “successor”. I’m super glad someone was interested in taking over (or replacing) Reorder.

You can use the code map file to see the original. Add “.map” after the JS file url. Unfortunately, it requires some parsing. I’m not sure what format it uses, or what browser plugins might eliminate the need for parsing. Basically, I remove the unwanted stuff, then just do a search-and-replace:

  • \n → newline
  • \t → tab
  • \" → "
  • \\ → \

It’s a little bit of a pain, but much nicer to read.

8 Likes

What does “overdue” do exactly? Does it make [UNSUPPORTED] [Userscript] WaniKani Prioritize Overdue Reviews (reorder script) obsolete?

1 Like

I modeled it on your script, so it should function the same or a similar way. Not sure if your script also sorts underdue items as well, though. I score each item from -1 (just reviewed) to 0 (just due) and up (overdue), so sorting by overdue sorts every item by how due (rather than overdue) they are

1 Like

Gotcha. Mine also includes some degree of randomization and customization, but otherwise it sounds pretty similar.

1 Like

Oh. :sweat_smile:

That would have made sense. I just had to use the webpack:// “folder” instead of the assets.wanikani.com “folder” to see the readable versions.

Screenshot

That’s what happens if I just use trial & error instead of actually understanding what I’m doing. Anyway, the current cache code is

if (Object.keys(memo).length < QUEUE_THRESHOLD) {
    fetchSubjectsMemo(newReviewQueue.slice(-1 * QUEUE_BUFFER_SIZE));
}

If they change it to something like

if (!newReviewQueue.slice(-QUEUE_THRESHOLD).every(id => memo[id])) {
    fetchSubjectsMemo(newReviewQueue.slice(-1 * QUEUE_BUFFER_SIZE));
}

the caching should still work after a change of the queue, I think?

3 Likes