[Userscript] Level Duration 2.0

If you can do so while keeping the script short and clear, then I will appreciate your effort.

But if it requires you to maintain two implementations (one for desktop, the other for mobile), then I prefer not to waste your time, thank you.

I assume they put a class somewhere indicating that it’s mobile, so it shouldn’t be bother. I’ll look into it.

Edit: it appears they do not, but I found a regex which should do what I’m looking for.
Edit2: Ah, I see now, it’s not a matter of whether it’s mobile or not, it’s only screen size. That makes it easier.
Edit3: Finally got the time to implement it. It was a simple change. @souvenir update and try now, I think it should work on mobile.

Great addition to WK. Thanks for maintaining this and also keeping the code clean!

1 Like

Thank you ^^

1 Like

Just wanted to report a small bug I’ve encountered. I’ve been on level 9 for 53 days but the counter stopped at 43. (Either that or it’s 10 behind for some reason). Not that it effects many people since I’ve been taking it really slowly, and it’s a minor issue, but I thought you may want to know. :slight_smile:

1 Like

Hmm. Working fine for me at 95 days (I’m on a break to focus on school). Could you double check on wkstats?

1 Like

Oh, I just noticed something strange. Since I haven’t done any lessons on level 9 yet, the wkstats shows a time of zero. Your counter is still counting however, and it turns out I was looking at level 8 which is 53 days, since it’s the last bar on my page I assumed it was from my current level. Sorry about that :sweat_smile: Seems everything is dandy then.

Edit: It’s adding the time to my level 8 score instead of my level 9 score. So that explains the ten day disparity also. But either way, the counter is fine.

1 Like

No problem ukKr5

@rfindley Is this intended behaviour?

1 Like

I was referring to the WK stats page. The counter, it seems, is still counting from the day I leveled up. The ten day difference between my level 8 time on WKstats and my time on level 9 on this counter is the ten days it took me to do level 8.

Sorry for the confusion. Also, uni is the reason for my break, so I empathise. Hang in there. :facepunch:

1 Like

It’s a bit funny, actually, because earlier in this thread oldbonsai advised me to use the started_at date (first lesson) instead, but I felt like unlocked_at (when you reached the level) was more natural.

1 Like

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).


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.

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.

// 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

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);

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