Wanikani Open Framework [developer thread]

WKOF still can’t seem to quite get to the end of my reviews, which means I can’t use the Heatmap or the stats sites. I’ve waited it out for a week or two, but still nothing… :frowning:

1 Like

If you’d like, send me your API key and I’ll see what I can figure out and/or do.

2 Likes

API key sent.

As stated in the email, please let me know if you need more privileges than the standard read-only token.

1 Like

@UInt2048, are you still having problems?

I was able to load your data on wkstats, though it took about 6 seconds before the review_statistics started loading.

Also, I just tested Heatmap. It took probably 15 seconds or so before reviews even started loading. And then it paused for 30sec or more about 2/3 of the way through due to too many requests. But it resumed, and was able to load everything eventually.

Note: I did this at about 0800 UTC (4am New York time). I know the server load is lighter at that time, but I’m not sure if that could affect this specific issue.

2 Likes

I have been able to reach the WK History website today, at 2022-06-30T13:00:00Z.

Hopefully I don’t experience more issues but I can’t test Heatmap for a while…

FYI, there’s been a big update to Open Framework. WK has been modifying a lot of pages lately, including Jquery no longer running on a lot of them, so things have been breaking.

I removed a lot of the dependencies on jquery, but the Settings and Progress modules still require it because they are based on Jquery UI. So, I also added a new Jquery module (wkof.Jquery) that loads jquery if it’s not already included in the WK page you’re running on.

If your script needs jquery to run, you can simply do this:

wkof.include('Jquery');
wkof.ready('Jquery').then(do_something);

function do_something() {
   // By the time it reaches this point, Jquery will be already loaded,
   // so you are safe to run any jquery stuff from here on.
}

That ensures that only one copy and version of jquery is running on a page.

If you are already using the wkof.Settings module in your scripts, it will load Jquery for you (if it’s not still included in the WK page). But if your script actually calls jquery, I’d still recommend including Jquery directly in your script, because there’s a chance I’ll fully remove the Settings module’s dependency on jquery someday.

By the way, the pages WK has changed so far are:
/level/*
/radicals
/kanji
/vocabulary

6 Likes

Oh boy, that’s going to be a big one once it reaches the dashboard and lesson/review sessions.

Thanks you for this! It’s going to make it so much easier to fix all my scripts when they break

3 Likes

Hey, not sure if it’s just me but after updating your scripts, most likely the double checker, after you press enter to submit your answer in a review, you can no longer hit enter again to go to the next question and have to either click the arrow, or you can click inside the text entry box again and enter will begin to work again.

1 Like

Thanks for the bug report. Could you open the Javascript console (press F12 and click the Console tab) a post any errors you see there?

1 Like

Yeah, not looking forward to if/when that happens. But I don’t think it’ll be very soon (…crossing my fingers :grin:)

2 Likes

There are no errors. I just tried in extra study mode and it has the same issue as the actual reviews

Pressing enter here will not go to the next question until I click inside the text box again

In case you didn’t see it in the Double-Check thread, I posted an update to fix it. (I’m assuming you’re using Firefox?).

:point_right: [v2.3.1] - Fixed firefox issue where keys are ignored after submitting answer

1 Like

This is firefox. I’ll check that thread. Thanks.

Would you consider installing Jquery by default in the Framework instead of requiring some other script to include it? This would prevent a lot of scripts to break in the first place. Otherwise unmaintained scripts will be broken with nobody to repair them.

An alternative would be to make a script called “Install Jquery” that does nothing but install Jquery. People can fix a broken dependency by installing this script and have it run in the second place after Open Framework.

3 Likes

I thought about that, but the loading of jquery is asynchronous, so it won’t necessarily be finished loading before scripts try to use it. (It was synchronous as part of WK since it was part of the app.)

Fortunately, fixing old scripts is probably as simple as wrapping the whole thing is this:

wkof.include('Jquery');
wkof.ready('Jquery').then(()=>{
   // Insert script here
});
2 Likes

Then why don’t you make the load of Jquery synchronous?

  • Your simple solution is still a big hurdle for unmaintained scripts because of the lack of a maintainer to implement it.
  • There may be some cases where the correct solution may not be to place the whole script in the then clause body.

I personally prefer this approach. In my opinion it is out of scope for Open Framework to always inject jQuery, no matter if it’s needed or not.

I’m wondering if with the transition away from jQuery, they will also switch from jStorage to something else. That might become the bigger problem for unmaintained scripts.

3 Likes

I haven’t spent much time thinking about it, but… how?

Userscripts rely on @run-at, which, as far as I know, is inevitably asynchronous. You can use @run-at document-start and immediately add a script tag, but I think it will still potentially run other userscripts while jquery is loading.

Agreed. That’s why it only loads it if a script explicitly requests it via wkof.include('Jquery');

Agreed. Fortunately, most of jStorage is directly replaceable with localStorage. The exception, as far as I know, is the StorageEvent if a key is changed from within the same tab. I think it only fires if it’s changed from another tab.

But again, we can patch jstorage in if needed.

2 Likes

I think it should be synchronous by using

// @require  https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js

In that case Tampermonkey has already downloaded the jquery file and just pastes it into the userscript before injecting the entire thing, so I think it should be immediately available.

1 Like

True, but every script would load another copy, I think. And not necessarily the same version.

1 Like