WaniKani Custom SRS - WIP

0.2.3 (just released) should fix that - it was an oversight on my part :sweat_smile: It also adds a checkbox to enable/disable item packs!

2 Likes

Ok, I tried all new features out now:

Enabling and disabling decks works fine, but in order for the review button to display the correct amount of reviews after enabling/disabling a deck, you need to refresh the site. I’m not sure if that’s intended, but I wanted to point that out :slight_smile:

I saw that you also added an option to add a meaning and reading explanation! After testing it, I was about to comment that it didn’t safe my information, but then I noticed that there was an update that fixes that lol

Regarding loading the item informations, it works now again for both custom as well as WK items!

Btw, is it somehow possible to add the information which radicals a kanji consists of?

(Also, it appears like the stroke order script works with the custom items, which is really cool!)

1 Like

Thanks for testing it out! I did indeed push an update to fix the explanations not being saved.

For sure, along with linking vocab that kanji are in, kanji in vocab, and kanji that use a radical. I’ve started work on them but slightly lower priority than e.g. context sentences! I also plan to, at some point, add a button to auto-fill details using a Japanese dictionary API like Jotoba/Jisho.

Ah - thanks for pointing that out. I’ll get it fixed :+1:

2 Likes

0.2.6 released, with pack export/import added! I’ve tested it a bunch but I likely missed a couple of bugs so it would be amazing if you could try it out at some point! Here is a quick example I exported, you should be able to copy-paste it into the import field which you get to from the packs menu:

Test Pack
{"name":"Test 1","author":"Test Author","version":"0.3","items":[{"id":0,"type":"Radical","subject_category":"Radical","characters":"一一","meanings":["Double grounds","ground"],"auxiliary_meanings":[],"srs_stage":0,"last_reviewed_at":0,"meaning_explanation":"The ground - but twice!","kanji":[]},{"id":1,"type":"Kanji","subject_category":"Kanji","characters":"猫","meanings":["cattivas","cat 2","second cat"],"auxiliary_meanings":[],"srs_stage":0,"last_reviewed_at":0,"meaning_explanation":"There's cats - but two!","primary_reading_type":"onyomi","onyomi":["恭"],"kunyomi":[],"nanori":[],"radicals":[],"vocabulary":[],"reading_explanation":"Read the same as cat, hmm"}],"active":true,"nextID":2}

One warning: unfortunately there was a bug with how I was storing item identifiers before, so if in your test pack you at any point removed any items other than the very last one then it’ll be bugged. If you want to fix it without having to remake the pack from scratch you can export it, then paste it into Notepad or something and CTRLF to find all the "id": fields (one per item) to make sure that they’re numbered 0, 1, 2, 3, etc. without any gaps.

2 Likes

Thanks for letting me know! I will test it out tomorrow, as I don’t have any more reviews today anymore!

2 Likes

Do you spoof WKOF data? Omega uses WKOF for sorting and filtering

Maybe you could intercept the HTTP request and return custom data?

3 Likes

For anything that makes web calls I intercept them and add in my data there. Unfortunately AFAIK userscripts can’t intercept the initial page HTML and WK seems to like putting data such as the queue in that initial HTML, so for that I have to wait for the DOMContentLoaded, take the queue out, modify it, then replace it (not ideal because it visibly flashes the change…). But for submitting items / getting item info etc. I intercept the web requests to add in custom data in the same format as WK does.
I’m not really sure what the WKOF data looks like? Does it just pull from the queue? Or does it store extra info?

They seem to have the reviews page set to redirect if the server detects there’s no reviews, and AFAIK there’s no way to prevent the redirect and get the original page… Right now the best I can think of is always taking one WK review item (the latest due for review) out of review sessions so that there’s always at least one review due - obviously not ideal but wouldn’t affect stuff too much as long as I made sure to always just get the latest item due for review so that it’s not one item getting infinitely delayed (obv would mention it in the script description and would probably aim for non-level-blocking items like vocab). But if anyone has a better idea I’d love to hear it!

3 Likes

It just assembles the paged results of each WK API endpoint into a single array (for each endpoint), and stores that directly in indexeddb. If you want to inject your data into WKOF, you could either capture (i.e. put a wrapper around) the WKOF Wk fetcher function, which is in wkof.ItemData.registry.sources.wk_items.fetcher(), or add your own data source, which would allow users to select those items separately.

If I recall correctly, the minimum requirement for adding a data source is:

wkof.ItemData.registry.sources['custom_srs'] =
{
   description: 'Custom SRS',
   fetcher: custom_srs_fetcher_function
}

And I think the fetcher function needs to return a promise that returns an item array formatted similar to WK’s /subjects endpoint, because other scripts will expect many of those item fields to be present.

6 Likes

Thanks for the info! :smiley:
I’ll have to take a closer look at it - I assume the main use of that would be to improve compatibility with other scripts? Or would it have other benefits I’m missing? (I assume it doesn’t have a way to solve my doing-reviews-when-there’s-no-WK-reviews issue right?)
I admittedly originally considered looking into whether using WKOF could make this script easier but decided that it would take longer to learn the codebase for it than to just write the parts I needed myself lmao

3 Likes

Yeah, the primary benefit is that scripts that use WKOF as a data source will, in many cases, automatically pull in your data. For example, your items will show up in Self-Study Quiz and Item Inspector. Double-Check may be able to work with your items seamlessly (I can’t remember how much data it pulls from WKOF versus the quiz queue, though).

2 Likes

Double-Check seems to work fine so far - but it does sound like a good idea to get it to work with other scripts. I’ll take a look over the next few days. Thanks!

1 Like

Indeed, it does, at least for me!


I now tested importing the pack, and it seems to work fine, apart from the double cat being a single cat and the reading for it being 恭 instead of 恭恓 lol

I also tested the bug you mentioned, and it seems like it’s indeed bugged; I deleted the double ground from the pack and then did the review for the cattivas, and when I got it to Apprentice 1, WK told me that I lost connection and had to refresh. Luckily, it didn’t mess up the review session.

The fix you mentioned for the bug also works, but I have a question: I’m absolutely no expert regarding this, but shouldn’t one also fix the nextID fields so that they are numbered 1, 2, 3, 4 etc.?

Also, another thing I wanna mention: The script seems to interrupt the reordering of the Reorder Omega script, as instead of having the radicals first, they seem to have not been reordered at all. So it looks like it’s not 100% compatible with the Reorder Omega yet.

2 Likes

Hmm, I’ll look into that, I thought I’d fixed it on this latest update. Although it could be an unrelated bug maybe…
There’s one nextID field in each pack - the idea is that it stores the location of the next unused ID. When you delete an item my idea currently is for that ID to not be reused, so that I can correctly relate the items in an imported pack to those of an earlier version of the same pack, allowing importing updates that remove / add items while maintaining the user’s SRS levels for the items that haven’t been removed / added. So that field should always be the maximum ID that’s ever been used in that pack + 1.
Yeah Reorder Omega definitely has some issues still, I’ll look into it in the next few days after first getting some more basic features sorted!
Thanks again for helping me with testing this script! :smiley:

EDIT: Ah - I’ve found the new bug that’s happening when you remove items. I’ll get it fixed asap!

2 Likes

Thanks for the explanation, that makes sense!

No problem, I really like it and want to help as much as possible! :smile:


I think I found another bug. If I click on a day on my heatmap where I did reviews, it usually displays the items I reviewed on that day and some additional information, like this:

However, if I try to click on a day were I did reviews of custom items as well, I don’t get this information displayed.

3 Likes

Hmm, not sure why that would be happening as currently I don’t touch any of the WKOF data which I’d assume the heatmap uses. Could possibly be because it’s auto-saving all reviews sent via the event that fires when completing an item and doesn’t know how to handle / doesn’t check for negative IDs which is what I’m using for items in this script? @Kumirei

In other news, 0.2.7 released! Looks like the bug with the IDs I said I fixed last time wasn’t fully fixed, so old packs might be bugged again :sweat_smile: I promise this won’t be a common occurrence, I’ll try to keep new versions back-compatible as much as possible, especially once the script is a bit more complete!

  • Loads of bug fixes
  • Add option to change item SRS level
  • Prevent flashing with item change at the start of custom review session (not final solution, will improve it over time)
Here's a test pack in case it's easier for you to just import it to test than making one yourself
{"name":"Test Pack","author":"Hubbit200","version":"0.3","items":[{"id":0,"type":"Radical","subject_category":"Radical","characters":"一一一","meanings":["Triple ground"],"auxiliary_meanings":[],"srs_stage":0,"last_reviewed_at":0,"meaning_explanation":"The ground - but three times!","kanji":[]},{"id":1,"type":"KanaVocabulary","subject_category":"Vocabulary","characters":"さかな","meanings":["Fish","fishes"],"auxiliary_meanings":[],"srs_stage":0,"last_reviewed_at":0,"meaning_explanation":"Fish kanji, same as vocab","readings":[""],"reading_explanation":"Kana vocab is pronounced as per the kana, so no need to learn any other readings!"},{"id":2,"type":"Kanji","subject_category":"Kanji","characters":"猫","meanings":["cattiva","second cat"],"auxiliary_meanings":[],"srs_stage":0,"last_reviewed_at":0,"meaning_explanation":"Cat, like vocab.","primary_reading_type":"onyomi","onyomi":["恭"],"kunyomi":["恭恓"],"nanori":[],"radicals":[],"vocabulary":[],"reading_explanation":"Read the same as cat, hmm"}],"active":true,"nextID":3}
3 Likes

Thanks for letting me know! Here are some observations that I made:

  • I think the option to set a word as kana vocab is new?

  • The first review item isn’t always a custom one anymore

  • I now see a button for doing custom reviews, even if I don’t have any WK reviews; However, it doesn’t work lol, I get redirected to the dashboard
    grafik

  • I noticed that when I go to my reviews and have a custom item as my first review, the custom item fade in (and even with the correct color)!

  • When I do my reviews and my first review is not a custom item, the WK items fade out, and I’m left with ā€œghost reviewsā€. I can still do them, but I can’t see what I am reviewing anymore.


    Also, in that screenshot, the number of the remaining reviews is kinda bugged: While it is loading the page, it goes up to 48 reviews (WK items + Custom ones), but when it is finished loading, it goes back to 45 reviews (WK items only).
    (Unimportant, but: I can see which item I’m reviewing if I’m able to drag it with the mouse like a picture (not sure if that’s what it is called; I clicked with the mouse on the item, moved the cursor somewhere else while continuing pressing the mouse, and after some attempts, I saw a copy of the item), but I didn’t always get the whole item at vocabs, so I’m really thankful for the double check script lol)

    Anyway, since the remaining review counter acted like I described, I went through a review session of 5 items the way I described in the spoiler, and the custom items did indeed not show up in the session.
    However, this is only the case if the first item is not a custom item. If the first item is a custom item, everything seems to work fine.
    TL;DR: If the first item in a review session is not a custom item, I can’t see the WK items + the custom items don’t show up in my reviews. If the first item is a custom item, everything seems to work fine (I haven’t done any reviews yet when the first item is a custom one, but I was able to see the item, and the remaining reviews count included the custom items as well, so I guess it works).
    I wanna note that this happened while having set さかな as Apprentice 1 to test the feature of setting the SRS stage. It might be related, but I’m not sure.

Regarding features: Do you think it is possible to display the time until the next review of an item, but make it optional so that you can decide whether you want to use such a feature? I’m not sure if everyone would like to have it displayed, but I’m sure some people would like that. And after all, I’m sure the settings page isn’t there for no reason :wink:

(I might have found more, but I ran out of reviews, unfortunately :sweat_smile: So this might not be all there is)

2 Likes

Thank you for testing it out!

  • Kana vocab isn’t new, but it wasn’t working properly before :sweat_smile:
  • The first review item should always be a custom one - if it’s not then that suggests there’s an issue with a specific change I made. What browser do you use (just in case it’s that)?
  • The review button is indeed now fixed to allow clicking when there’s custom reviews (although it looks like I need to still work on it a bit to change the text etc.) but yep, it doesn0t actually work yet!
  • The fading should only happen when you have custom items to review - and in those cases the custom item should always be first. So fixing the custom items not being first should hopefully also fix your issue of ghost reviews.
  • I’m very curious as to why the remaining counter is acting like you describe, I’ll need to look into that.

A setting to show time until review definitely sounds like a good idea, and should be quick to implement. It will be in the next update today/tomorrow :+1:

EDIT: Oh also just to check, did you have any reordering script enabled when testing it?

2 Likes

Whoops, must have overlooked it somehow then :sweat_smile:

I’m on Firefox. Since the last update of the script, the first item wasn’t always a custom one anymore, but if it was a custom one, it had the right color, so that’s good, I guess? In any way, I think it isn’t related to the browser :thinking:

Yes, I never disable it :sweat_smile: It is the first time that it behaved like this, though, despite that I had activated the reorder omega script in previous versions as well.

2 Likes

Hmm, I’ll test it out with Omega / Firefox to see if either of those are causing the issue, as I’m having trouble replicating it. In the last update I changed the method I use to add in the custom items but if it’s causing issues I’ll likely just change it back to how it was before, as it didn’t end up really improving much!
I will also work on proper Omega compatibility, but I first need to get it working with custom items not being the first in the review session :sweat_smile: I’ll probably add a setting to choose if they’re placed at the beginning or randomly mixed in.

2 Likes

I just tested disabling Omega, but the issue still happens. So, it’s either Firefox or one of the 1340934 other scripts I installed lol

2 Likes