[Userscript] WK Real Numbers

This is actually really helpful, but I found a bug you may be interested in. I accidentally hit the “Generate New API Key” button, and once I did everything went back to 42+. I managed to fix it by clearing the apiKey token in the F12 developer options menu, but there really needs to be a simpler way to do this. Maybe a sanity check where it checks at the end whether the numbers have successfully changed and prompts the user for their apiKey again if they haven’t.

Also, serious question: Why is this not just a standard feature?

1 Like

Because the WK team likes the 42+ joke :man_shrugging:

1 Like

Thank you, this still works fine for me. ^^

I got that yesterday as well. Maybe you have another script that’s making so many requests that you’re hitting the limit?

Yep, same for me. Its been temperamental for about a week now! And today I have a big 0 when there should be 120, using Chrome…

People having trouble with the original might be interested in trying my version of WK real numbers. I made it mostly for personal use, but it should solve some of the issues discussed here. In particular it will always either have fresh data or fall back to the 42+ if there’s an error, instead of using out-of-date cached data. (Also, it can find your API key without the popup-and-redirect flow, assuming you have generated one.)

1 Like

Agreed–for a paid service it does seem like users disproportionately have to provide DIY solutions/improvements for themselves for things that should be taken care of by the people running the site. That said, I’m overall happy with what the site does provide for the price.

1 Like

Could you put this on something like greasefork for an easy download link? I know it’s not a big deal but if it’s easy enough it’d be nice. Thanks. :slight_smile:

You can click the link in the readme to install it. Or, this one.

@Mempo The dev team recently added global variables for the real number of lessons and reviews, making API calls unnecessary. Do you want me to send you my new version of the script so you can decide if you want to incorporate it? Or if you prefer not to own the script anymore, I don’t mind uploading mine as a new script. Up to you.

1 Like

Yea, please, if you have an improved version I’d greatly appreciate it if you paste it here. I’ll update the script asap.

To be honest, I don’t check in here that often any more and I probably won’t write my own patches/fixes any more. However, I know what a pain it can be to deal with abandoned scripts since I’ve adopted a few ones myself. So in the interest of the users I prefer to still ‘own’ the scripts (at the least ones with huge amounts of users like this one) so they can still get automatic updates from contributors such as yourself.

1 Like

@Mempo Feel free to use or change whatever you want.

(function($) {
	'use strict';

	var wkData = window.WaniKani;
	if (!wkData || !wkData.studyInformation) {
		return;
	}

	var studyData = wkData.studyInformation.requested_information;

	if (!studyData) {
		return;
	}

	var lessonsEl = $('.lessons span');
	var reviewsEl = $('.reviews span');

	if (lessonsEl.length === 0 || reviewsEl.length === 0) {
		return;
	}

	lessonsEl.text(studyData.lessons_available);
	reviewsEl.text(studyData.reviews_available);

})(window.jQuery);
1 Like

I had an issue with this script because when loaded, window.WaniKani.studyInformation was undefined. I just used a 1 second timer to fix the issue. (I am using Firefox with violentmonkey btw)

window.setTimeout(function() {
    'use strict';

    var $ = window.jQuery;
    var wkData = window.WaniKani;

    if (!wkData || !wkData.studyInformation) {
        return;
    }

    var studyData = wkData.studyInformation.requested_information;

    if (!studyData) {
        return;
    }

    var lessonsEl = $('.lessons span');
    var reviewsEl = $('.reviews span');

    if (lessonsEl.length === 0 || reviewsEl.length === 0) {
        return;
    }

    lessonsEl.text(studyData.lessons_available);
    reviewsEl.text(studyData.reviews_available);
}, 1000);
1 Like

This fixed the issue I was having as well.

Now that 42+ is not the default behavior, this script is no longer needed.
However, if you’re actually looking to re-insert 42+:

3 Likes