Wanikani Open Framework [developer thread]

I decided to start working on creating Typescript types for WKOF, mainly for the intellisense in VS Code, how should I go about sharing these in case anyone else wants to try them out? I’m fairly new to TS, so I’m sure they’ll be mediocre at best, but might come in handy for someone

@rfindley What is the intended use case for get_state(), set_state(), and wait_state()?

Hmm… no idea. If they’re hosted somewhere, I could link them in the top-post. I’m open to other suggestion, too. Did you have anything in mind?

They’re for any sort of signaling between scripts, or between framework and scripts.
For example:

//=====[ script1.js ]=====
function navigate(location) {
   // Load a new page, then signal our new location for any listeners.
   wkof.set_state('location', location);
}
//=====[ script2.js ]=====
wkof.wait_state('location', 'dashboard', show_banner);

function show_banner() {
}

Also, wkof.ready() uses wkof.wait_state() internally, but it assumes that the signal you are waiting for starts with “wkof.”. So, for example,

wkof.ready('my_plugin');

is simply waiting for:

wkof.set_state('wkof.my_plugin', 'ready');
1 Like

Linking in the top post sounds good. I’ll think about it some more as I get it ready. I have the bulk of it done already, but I think I need to learn some more about typing to get it decent. I’m also not sure yet how to best utilize TS for userscripts

Ah, that makes sense. I’ve been doing React recently and the word “state” got me a bit confused.

This is pretty nice


Edit: If anyone wants to try them out I have them in a folder in my Userscripts repository

3 Likes

Are you ready for me to add it to the top-post?

Actually, now that I think about it… I may have made the top-post publicly editable. Feel free to try if you’d like.

[edit: Or maybe I didn’t?? I don’t see where that can be done. Maybe my Discourse rank has dropped since I don’t spend as much time on the forums.]

2 Likes

The top post is currently a wiki, so everyone should be able to edit it. You need to be a regular to make your own post into a wiki. I have no idea if you can modify if your post is a wiki or not after you make your post a wiki then drop down to member. :grin:

2 Likes

I think I will hold off for a couple of days while I try it out and iron out any mistakes

2 Likes

Okay, let me know if you want to borrow my iron

2 Likes

@rfindley could you make the settings available (through a gear in the top left as in reviews) on the new extra study session page?

It’s on the to-do list, tentatively Wednesday. Funny thing is, it was only a couple of weeks ago that I finally added it to the Lessons page.

1 Like

Oh my, I didn’t realize it wasn’t already there

Added my typescript types to the OP. They’re not perfect, but they helped me a lot as I was making my reorder script

1 Like

My apologies if this is the wrong thread, but I’m wondering what’s going on with WKOF trying to download reviews (for the heatmap)

It was frozen at this spot for at least half an hour before I shut it off.

@Kumirei Any ideas? The unexpected EOF in JSON entry in the console seems a bit strange…

Sorry, I’ve been doing some particularly heinous tax filing this season, and nearly forgot about your inquiry.

I noticed you got a blocked API request due to CORS header missing.
First, I just spotted this thread:

But usually it’s an issue with some sort of ad-blocker, security plug-in, or firewall that is manipulating headers.

And, in some cases, it’s you’ll see ‘null’ or ‘undefined’ errors due to the indexeddb becoming corrupted, on which case you can clear that. (Press F12, click on the Application tab, find indexeddb in the left panel, expand it to reveal wkof.file_cache, right-click on that and Refresh. Then reload the page).

1 Like

That thread seemed to be the issue I was experiencing (didn’t know that it was affecting people without scripts yet)

Anyways, it’s working now. Thank you for your help!

1 Like

I don’t know if anyone cares but I used your really awesome framework in the WK History web app. It really works like a charm!

I saw that there is a list of Userscripts that use wkof so I don’t know if I should post it here as well if it’s used in a website?

Btw do you know what could cause this small visual problem:

Images

image
In the beginning they are ontop of each other like this:

There are two loading boxes and one of them isn’t displaying anything. I checked but I didn’t call the wkof twice or anything like that, I did it with nested “then” statements. Also, if the subject data (with ItemData.get_items) is already loaded this bug does not occur. Any ideas?

I’m not sure if the list of scripts that use WKOF is needed anymore. Most scripts use it, and I have certainly not been adding my scripts to the list for a long time

3 Likes

I agree with that - vote to remove

3 Likes

I think its original purpose was for @rfindley to be able to check if any script was using a feature in WKOF before they changed it, but since a lot of scripts are not on the list anyway I think we can remove it now

2 Likes