[Userscript] Reorder Omega

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.

6 Likes

What does “overdue” do exactly? Does it make [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

In addition to being able to sort by overdue in ascending or descending order I also include a filter for overdue, which I imagine most people would probably want to use in conjunction with sorting

1 Like

Does this work differently for the extra study page? For what it is worth Self Study seems to work fine the way I am doing it (populating activeQueue with complete data and practiceQueue with ids)

edit: although I have realized that they pick items from the back of practiceQueue and I need to reverse the queue…

I think extra study works exactly the same. The problem with the cache is not that it does not work at all – if an item cannot be found in the cache, it is loaded on demand. But it makes proceeding to the next review maybe a bit slower because the cache is not used.

1 Like

SOLD!

Weird issue. I wanted to test this with a normal review session and it’s filtering down to 10 items with no actions set under the none preset. I’ve disabled all of the other scripts on the review page except WKOF + Additional filters. Is there an option limiting the batches somewhere? If I close out my browser it seems to load the session with all of the reviews I’m supposed to have, but if I refresh the page I can see it reduce the outstanding items after everything loads. I’m an idiot and forgot I had script compatibility mode set.

Will filter first 100 will be cumulative for the day, or will that be for the session?

1 Like

That is strange, indeed. I’ll see if I can reproduce it tomorrow

It’s for the session. I did actually consider making a filter for daily cumulative, but I question how useful that would really be

1 Like

Gotcha, I was just curious. As for my issue I’m stupid and forgot that I had script compatibility mode on since it was making something else work.

2 Likes

Ah, poop! I forgot to account for compatibility mode. I’ll put that on the list for tomorrow. Glad you got it working

3 Likes

@ccookf To be precise if you switch between presets (or change the settings) the filters will re-run and even if you already did some items you could end up with a queue of 100 new items

1 Like

Are there even any scripts left that require compatibility mode? :thinking:


Feature idea: Some way to easily share presets. Creating presets can be a bit complicated, so maybe some users would prefer to use presets made by the community instead of learning how to do it themselves? I’m thinking of encoding the preset into a string that can then be pasted into the forum. This could also be used to make backups of your own presets, or to copy them to another PC.

1 Like

Not sure, but some users might not realize that Reorder Omega isn’t working because of it

That sounds fun! This could also be a nice solution for the issue with space in the settings. I was considering making a separate tab for each page (lessons, reviews, extra study, self study) to save some space, but then you might have to create the same preset multiple time if you want it active on multiple pages. Allowing imports and exports would make it easy to transfer a preset from one page to another

Funnily enough the other day I was considering creating a script that could export and import all WKOF settings. This would also be very useful for the Heatmap, which has plenty of settings which can be tricky to copy over.

2 Likes

I turned it on a few months back since that seemed to keep Ultimate Reorder 2 working.

2 Likes