[Userscript] Level Duration 2.0

I think that the unlocked_at date is more natural too, which is why I’m surprised to find that WK is adding it to the previous level. However I’ve been reliably informed that it shifts the time to your current level once you actually start lessons. I’ll be doing that in another couple of days so it’ll be interesting to see what happens.

1 Like

@Krispy @Kumirei,

Since WK APIv1 doesn’t provide level-up timestamps, the current version of wkstats has to rely on radical unlock dates to guess when you’ve leveled up. Unfortunately, even though radicals are unlocked when you level up, APIv1 doesn’t give me that info until you actually do a lesson. So, time is added to the prior level until you do your first lessons…and then wkstats corrects the prior-level time and updates the current level.

The upcoming version of wkstats (https://www.wkstats.com:10001/) uses APIv2, which provides a lot more information, so it should (hopefully) always show accurate info about level-up.

(I’m not sure when the new version of wkstats will be done since I’m currently preoccupied with a software contract that doesn’t leave me with much spare brain power at the end of the workday).

2 Likes

You coded WK stats? Wow, I never knew that!

Edit: May I enter my API key and have a look?

1 Like

Go for it! It’s sort of in pre-release so people can use its improved features until I get a chance to finish it.

1 Like

Is there a different thread on WK I can use to report any bugs I encounter (if that’s something you want/need yet)? Though I’m aware there’s no point in bug reporting until you reach the point where you’re testing a more complete version of the site.

[Upcoming wkstats.com changes] thread has sort of become the discussion thread for the pre-release. Bug-reporting is appreciated, since the available features are mostly in their final state… with the exception of things related to estimated future level-ups, which is the main thing I still need to complete.

1 Like

Hi @Kumirei, thanks for the script. It is really helpful.

I have a suggestion for display format. I think it will be easier to digest the information if this script use day + hour format.
image

1 Like

Sure, I’ll make it a setting when I find the time

I tried to figure out how to do it properly with the WKOF settings menu, but that seemed tricky so I just made it simple and added a variable in the code. If you update you should now see displayHours = false at the top of the script, just change that to true and it will display the hours.

Not tested, but mostly cut-and-pasted from a [wkof documentation example].

// Include the Menu module, and wait for it to be ready.
wkof.include('Menu,Settings');
wkof.ready('Menu,Settings')
.then(load_settings)
.then(install_menu);

// This function is called when the Menu module is ready to use.
function install_menu() {
    var config = {
        name: 'level_duration_settings',
        submenu: 'Settings',
        title: 'Level Duration',
        on_click: open_settings
    };
    wkof.Menu.insert_script_link(config);
}

function load_settings() {
    var defaults = {
        displayHours: false
    };
    wkof.Settings.load('level_duration', defaults);
}

function open_settings(items) {
    var config = {
        script_id: 'level_duration',
        title: 'Level Duration',
        on_save: update_display,
        content: {
            displayHours: {
                type: 'checkbox',
                label: 'Display Hours',
                default: false,
                hover_tip: 'Include hours in the level-duration display.',
            },
        }
    }
    var dialog = new wkof.Settings(config);
    dialog.open();
}

function update_display()
{
    // Put code here that redraws the display based on changed settings.
    var displayHours = wkof.settings.level_duration.displayHours;
    // ...
}
1 Like

Thanks! I don’t really know JS I just know what I have to; so this whole thing with promises and async in general makes things confusing for me.

I’ve updated the scripts and it seems to work just fine!

1 Like

It took me a surprisingly long time to really learn proper use of promises. There are so many wrong ways to use them! (Some of which I like better than the ‘correct’ way).

2 Likes

I have updated the script and it work seamlessly. Thank you very much.

1 Like

This is the thread for the level duration script, the one which adds the info under your level circle. That’s the LevelUP Celebrator

whoops :slight_smile: didn’t mean to do that … Moving the posts the right place and deleting

It’s cool, I don’t mind

Hmm, looks like that I’ve been stuck in this level for a quite a long time.
image

(Been 900 days since I last served Crabigator)

But now I’m back with determination to hit that sweet level 60!

5 Likes

Any way one could still get the old Level Duration script? (pre UI rework)
It was still working fine with [UserScript] WaniKani Old Header :see_no_evil:

P.S: Change can go die D:

Haha, sorry for updating the script
I was planning on updating to support the Old Header script anyway, I’ll ping you when I do.

1 Like

@GrumpyPanda @SpookySpooks

Updated. Should work now? If it doesn’t, uh, yeah, post here

1 Like