[Userscript] Wanikani Heatmap

I made a little userscript to synchronize review cache data with a nice GUI.

You can export the data in JSON-form into clipboard or file, for example to use dropbox/onedrive/googledrive, and also read it from clipboard or file.
It allows you to import reviews without creating duplicates. But you can also overwrite everything, for example to restore a backup.

Download: https://phi.pf-control.de/userscripts/WaniKani_SyncReviews/WaniKani_SyncReviews.user.js
Mirror: WaniKani_SyncReviews

2 Likes

This actually works pretty well to synchronize cache across devices.
The last few days I used the script extensively.

After my wanikani session on laptop or smartphone, I download the cache to my OneDrive folder. On my desktop PC, I then upload the cache-file before or after my session there and reload the page.
The heatmap then also counts the reviews from my phone or laptop.

(I use Firefox + Tampermonkey + the website + the userscripts on my smartphone.)

1 Like

I just spent a good deal of time trying to get my review_cache back after something caused my wkof.file_cache to get purged.

Fortunately, I had a browser tab open that still had the heatmap data active, so I was optimistic that it’d be possible to get the cache back, and it turns out I was right.
In case it may help anyone else down the line, below, I’ll explain the steps I took that led to getting the data back.

Essentially, with that tab active, I set a breakpoint inside of function day_click(data), I then clicked a day on the heatmap and ran the following (mostly taken from the Review Cache imported script, which didn’t have a context available at that time):

let press = function(com, data) {
    let last = 0
    let pressed = data.reviews.map((item) => {
        let map = [com ? item[0] - last : last + item[0], ...item.slice(1)]
        last = com ? item[0] : last + item[0]
        return map
    })
    return { cache_version: data.cache_version, date: data.date, reviews: pressed }
}
wkof.file_cache.save('review_cache', press(true, data))

This is super great! I used it when I spent two weeks in Sweden, so that I was able to keep my review streak, but when I copied my data back it… adjusted the time zones. Which meant I lost my streak, because I did my reviews in the AM Sweden time… which was still the previous day in my normal time zone. :frowning:

I wonder if there’s a way for me to fix this? It makes me sad to lose my streak because of time zone adjustment things.

Well, atleast the data in the cache can be adjusted.
In the heatmap script, you can go to settings, reviews and manually register a review at a past time to save the streak.

You can also do this with my script with a bit more control, by changing the first number of a review.
It is a unix timestamp. A number like 1734819203126 is the amount of milliseconds after 01.01.1970 00:00 UTC.

To modify the timestamps of your existing reviews, you could export your reviews, change the timestamps of the reviews you want to modify by 10006060*hours, and then overwrite the cache with that.
There are also converter websites for dates to unix timestamps, like https://www.epochconverter.com/

But just to save the streak, you could just copy an existing review entry, change the timestamp and import it as a fake entry.

1 Like

i’m wondering, would it be possible to add the ability to manually place markers, such as for level up goals?

1 Like

All of my data is gone for some reason. It seems there’s no way to get it back. This userscript was pretty much the reason I kept coming back every day so it sucks to see that everything is gone. I hope someone adds an auto-backup feature.

It was fun while it lasted

Edit: It seem ALL of my data is gone, including other scripts, so it isn’t this script’s fault. I’m wondering if it’s WKOF that’s broken

1 Like

Does anyone have an idea if this script will be affected by the announced dashboard change from WaniKani? Or at least if the data will still be saved/continued in case it can’t be displayed for a while after the change until the script got updated?

1 Like

I’m going to take a screen shot of my current Heatmap before Monday, just in case this is the end of the line for this much-loved userscript. :sob:

1 Like

Yeah, same. :smiling_face_with_tear:

That’s my plan too. I have a feeling it will be lost. Anyone know how to save the data? Maybe in a spreadsheet or something? I dont want to do it manually lol

The screenshots Koichi posted seem to imply WaniKani will now have a 1st-party heatmap widget, but I don’t know whether WK currently stores review stats so as not to start the map anew.

edit: Koichi confirmed it won’t start from zero but won’t include extra study stats.

1 Like

If I recall, the most recent version of the script stores your data locally on your machine, which was a change made some time back due to some API changes at that time. It was at that point that for people who use WK from multiple computers, the heatmap only contained the data for lessons and reviews done on that machine. At that time, there was some discussion around how to move the data from one machine to another, which would detail where the data is stored and how to get at it. I will do a quick search to see if I can find when/where that discussion took place.

Edit’: Start here and then read on. There are questions about where the data is and how to access it throughout the following posts for a bit.

2 Likes

Of course the new heatmap and streak counter may have a different interpretation of what day something is in due to timezones.

2 Likes

Most web services/platforms keep everything in UTC and let the browser/client on the user end convert to local time based on locale settings.

1 Like

Wanikani is mostly server side rendered and so doesn’t have access to the browser’s opinion on the user’s timezone until after the heatmap is rendered. It’s probably just going to be calculated based on the timezone in your user profile settings.

1 Like

Are there any plans to update Heatmap to work with the newest dashboard update from a few days ago? I desperately miss the heat map, especially now that I’m at level 60 and about to be done. I wanna see the full thing!

3 Likes

Mine works fine, try using location ā€œTopā€ or ā€œBottomā€

3 Likes

I haven’t been able to figure out how to do this successfully. I went in and tried editing the position from ā€œ2ā€ to ā€œ4ā€ as well as ā€œ0ā€ to try bottom and top both, but neither seemed to do anything for me. Is there something else you modified to get it to work?

1 Like

I can’t speak for Angelodmage, but I was able to get my Heatmap to show again by changing the position setting to Top. Have you checked this?

User Icon > Script Settings > Heatmap > Position

6 Likes