[Userscript] WK Real Numbers

‘Economic’ may be a mistranslation from my mother tongue, sorry for that. But you have answered my questions. And yes, from that point of view, I think the effort of adding that part of the code is usefull. Thank you for taking the time to answer my questions.

Yeah… All of my scripts fetch the API key in slightly different ways, and honestly, it’s hard to say what effect you end up with if a dozen scripts try to fetch it at the same time.

With my last script (the new forums lesson/review status), I added a #require sub-script to handle the api key for all scripts that want to use it, so it would unify all apikey-related code. It also provides the beginnings of a framework for scripts to add their settings to a global settings page. (Too bad I don’t have time to retrofit all my old scripts!)

1 Like

@Mempo has something changed in WK that affected this script? For some reason the count doesn’t properly reflect the actual amount when below 42; I have 40 reviews now, and I can see that flash a bit and then it’s overwritten by 44, an older amount. If I check localStorage 44 is what’s stored, and even if I clear it, it resets to 44 after a refresh. Am I missing something?

There are other threads talking about review count problems at the moment, so it’s likely a temporary WK bug.

Well, if I disable the script the numbers are correct, but I suppose you could still be right :slight_smile:

I guess I’ll go back to squashing bugs at work while letting viet squash WKs! :slight_smile:

idk, seems to work fine on my account. I’ll check from time to time if it changes.

EDIT: Viet said he fixed it over here

1 Like

I’ve had problems with this script after resetting my key after resetting my level. I’m not skilled enough with scripts to figure out how to fix it.
I tried deleting and reinstalling it. It simply doesn’t trigger at all. I get the 42+ when over, actual number when under.
I love this script, and actually wish they didn’t do the 42+ (fun joke, but highly unuseful and disruptive…)

Try opening a console on wanikani by right clicking somewhere on the page, select “Inspect” and navigate to the Console tab of the window that pops up.

Should look something like the above.
Then copy paste the following line into the console and hit enter:

 localStorage.removeItem("apiKey");

This will remove the old key from storage and upon refreshing the page, WK Real Numbers will ask to save your new key.

1 Like

I got this when I did:
undefined

Sounded like an error, or something not quite working (to my unskilled knowledge :wink: )
But upon reloading I got the collect API prompt, now it works! =D
Thank you so much =^-^=

1 Like

Hi @Mempo, thank you for the script, it helps a lot.
I looked at the code and it seems the value-cache implemented in the script is never used, as ‘doneReviews’ is always true due to ‘|| true’.

A possible fix would be to write ‘Boolean(localStorage.getItem(“WRN_doneReviews”) === null || localStorage.getItem(‘WRN_doneReviews’))’ instead.

What do you think?

Thanks so much, this has been annoying me so bad.

Yea, lol, that’s a silly mistake :stuck_out_tongue:

I just want to add that I didn’t write the script. I just fixed the broken parts from the original one (by penx) and started this thread. If you have any more improvements or bug fixes, just let me know here and I’ll update it on greasyfork.

1 Like

Ye, I’ve been having issues where it’ll sometimes pop up that’s there’s no API, link me to the API, and won’t tell me anything about what to do with it. Looks like I have the same code as everyone else though and am using chrome. I’ve reinstalled it now so I’ll see if it happens again but ye… bit annoying when it pops up.

@Lukephos
You’ll only get notified when the API key is not found, so that’s your first problem: something/someone is deleting it. You might want to look into that.

I tested what happens (or should happen) next. If you have WK Ultimate Timeline installed, or maybe another script from rfindley, it could happen that those scripts fetch the API key before WK Real Numbers does. So if my script then navigates to your settings page, it doesn’t alert you anymore, because the key was already found. If WK Real Numbers saves your API key, it’ll show a pop-up alert which will automatically navigate you back to the dashboard if you click OK.

In any case, unnecessary redirect or not, the API key is set by the script, so you shouldn’t do anything about it.

@Mempo Can you please remove the “App Store” hook in the code? It’s quite annoying…

In what sense? Because it takes longer to load or something?

Because it adds a menu item for the App Store even though I don’t want to use the App Store. There’s no reason to have that item added to the menu since I don’t have the App Store script itself running.

1 Like

fair enough. Removed it.

1 Like

Did this happen to stop working for anybody else after the recent maintenance? It’s silly but I love this script and am perpetually baffled that there is no regular WK option to implement this behavior.

This works fine in Chrome but for some reason it’s not working in Firefox…

edit: nevermind, none of my userscripts are working so it’s probably nothing to do with this