[Userscript] Leech training

It’s been a while since I hit zero so I’d never noticed! I’ve updated the script to include your change. I don’t think it’ll automatically remove that colouring without a full page refresh, but there’s no background updating either so it should all be grand.

1 Like

That’s interesting. Are you using Firefox?

Oh yes…

Okey doke. I’ll install firefox and see if I can recreate the issue. Probably won’t be before the weekend.

1 Like

First step done. Clean Firefox install (on a mac), added the Open Framework script, and the leech trainer, and managed to complete a leech review session. Do you have other tampermonkey scripts enabled?

1 Like

Like a thousand

1 Like

It could be that one of the others is causing a conflict, though that’s a weird message to see. If you try a clean profile with just what’s needed for the leeches script does it work?

What’s a clean profile?

Turn off all other non-related scripts and see if that works

1 Like

The same :frowning:

Your profile is where your bookmarks, passwords, extensions, etc. are saved to. You could try and create a completely new one using the Profile Manager (Profile Manager - Create, remove or switch Firefox profiles | Firefox Help) and then install just the bare minimum to see if it’s working.

It’s not a common error from what I can gather, and it could be a completely different extension it’s conflicting with.

This is a great script thanks! I made a slight modification to add a link to open the current item’s wanikani page in a new tab as I wanted to re-read the mnemonic for some of my leeches.

176. '  <a style="display: block; padding: 10px 0; color: #fff; background: #555;font-size: 1rem;" class="wkLink" target="_blank" href="">Open</a>'+
376. dialog.find('.wkLink').attr('href', `https://www.wanikani.com/${itype}/${item.name}`);

Maybe worth adding properly? (without my terrible styling :sweat_smile:)

1 Like

I’ll take a look at adding that. Should be easy enough to add it to ones you get wrong. No point in making it easy to look it up before you answer.

2 Likes

Just wanted to say I haven’t forgotten, and I will get to this.

Hey!
Thanks for reviving the script, but I think there is some issues on server side now, I’ve got internal server error from https://wk-stats.herokuapp.com/leeches/lesson?api_key=....
It seems like the api request https://api.wanikani.com/v2/study_materials?updated_after= is malformed, it’s returning with 422: The updated_after parameter must be a valid ISO8601 format.
Is the server side code accessible somewhere?

1 Like

At the moment the code isn’t visible. After forking the original repo I realised it contained a large dump of WK data which I wasn’t too keen on having publicly available under my name so I made the repo private. I still need to do a proper scrubbing of the repo to make sure I’m not distributing that info.

I just tried the leech trainer and it seems okay at the moment. Is it behaving itself now?

I used the leech trainer a few minutes ago, and I didn’t notice anything out of the ordinary.

Regarding @IcePhoenix 's problem, ISO 8601 deals with time and date formats. Maybe this is a localization problem, where IcePhoenix’s browser tries to the tell the backend the time in a format it can’t understand? I personally prefer to “normalize” date and time data when it doesn’t have to be human readable. A UNIX timestamp (Date.prototype.getTime(), Date.prototype.setTime() etc.) might be worth a look.

Unfortunately the response is still the same after reinstalling the script and removing the leech_train_cache from local storage.

The request to the leeches/lesson route got a current epoch timestamp as a get parameter named _ but after consulting the source I think It’s just the byproduct of ajax to avoid caching, so it wouldn’t intended to be consumed by the backend.
Assuming from the response it’s unable to produce the desired date format, because it sends the updated_after field as empty, hence the 422 response from WK API.

Digging trough the forum, it seems this is not a regression, this is still the same issue, maybe the server side cache gone awry for some users.
Good luck with the repo cleanup(or the substitute extension), unfortunately go is uncharted territory for me.

I applied the very scientific solution of restarting the server, but heroku restarts the servers every night anyway, so I’d be surprised if it works.

I’ll make some time to try and get to grips with the server before too long.