[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