[Userscript] Lesson/Review Count in Forums

Happened to me at first as well. Refresh fixed. No issues since.

Oh! How did I miss this yesterday!?
Installing the updated version now. (It’s been helping me already so much. ありがとう!)

EDIT: That works so great! (But your link from the post I grabbed it from told me it wasn’t the latest version…and gave me another link to something even newer.)

Sure thing. If it happens again I’ll post here and tag you or something.

It’s covering things up for me at the top of the page, and the refresh is not fixing it in my case :cry:

@rfindley The refresh, or just opening a second tab after the first has loaded, still fixes things for me, but I still get this problem intermittently. I’m not really sure what causes it.

v1.0.3 - Fixed intermittent overlapping at top of main content.

@tomboy, @Inserio

Hmm… Wish I could’ve seen a screenshot of what they’re talking about. I don’t think it’s happened to me at all.
Something looked weird for a second once yesterday… but then was fine again… might’ve even been the generic big picture just surprising me by flipping to the topic title and smaller circular picture.

I’ll update anyway for prevention’s sake.

Seems to be working nicely, thanks!
Are you planning to port the timeline and dashboard progress plus too?

Unfortunately, I don’t have time to do it currently.
They’re much more complex than this relatively simple script.

That’s cool with me. I just check the timeline right after having done reviews and then pop back here.
Although I’ve noticed that the Review count doesn’t update automatically to the grey 0 right after having done my reviews here…
There seems to be all kinds of time delays between WK and Discourse (not just this script)…

I want to blame Discourse for that…

It took time to go grey - but then the moment I had a single new review it went back to blue 1 instantly… It’s strange. Sometimes reloading the page can force-refresh it to be accurate, sometimes it can’t.
This time it took close to 10 minutes or so?

Yeah… one of the down sides of the new forums is that they changed the domain (www to community), which means anything I store in browser storage is not accessible between the main site and the forums. So, when you do Lessons, I can no longer pass a flag indicating that you’ve just completed some lessons, which would tell me I need to refresh the Lesson count. So, all I can do (without a lot more work) is simply update every 15min.

Unfortunately, that’s also part of the problem with adapting Timeline and Dashboard Progress.

Ahhh… that makes a lot of sense.
I thought it might be something like that.

Well, in that case, I wouldn’t port those over to the forums. (Plus where would they go without looking awkward, anyway?)

Hmm… thanks.
I wonder if you could get that to grab info at 10 minute intervals instead…? Or think that’d be too taxing on servers?

@rfindley you’re a genius of creating. <3 Thank you for all your hard work. :green_heart:

Also your avatar reminds me of Ghibli…

Yes, it’s Jiji from Kiki’s Delivery Service :slight_smile: . It’s from a scene in the grocery store where Jiji sees a mug with a black cat on it, and excitedly tells Kiki, “Kiki, look! Look!” (キキ、見て!見て!)

I just modified the background a little to make it stand out more.


I knew it! I thought it was Jiji, but I hate guessing and then someone being like “how could you even guess so far off? It’s clearly unrelated-thing-X!” so I just went with Ghibli, lol.

Yo @rfindley, I was wondering - why do people write code closure-style like that? Wrapping the entire script in (function(whatever) { ... })(seemingly_arbitrary_object)… why?

I’ve seen it elsewhere too, and I always get a bit taken aback by it. Seems so needless. Is it to scope everything to the script specifically; prevent tampering? Or is there some other reason? And why the gobj parameter that you don’t even use?

Have my own Jiji that I got from a random store in Akihabara. Sits next to my Pokemon center Pikachu.

1 Like

v1.0.4 - Always requery when page first loaded

I just realized… Discourse never reloads the original page as you navigate around, which means I can do a fresh query every time the page loads without adding tons of load to the WK server. So, now you can just refresh after lessons, and it will show the updated values immediately.

1 Like

The closure isolates the script, so other scripts can’t interfere with it. It’s too easy to end up with a same variable name in another script (like ‘apikey’), which leads to unpredictable behavior.

The ‘gobj’ is part of my standard script template. Its purpose is to allow access to things inside the anonymous closure. I use it during development, and occasionally it’s useful for accessing settings dynamically.

If you look at Ultimate Timeline, you’ll see that I do this:

var settings = { … };
gobj.settings = settings;

So, from the console, I can access settings directly:

window.wktimeln.settings[‘24hour’] = true;

(It isn’t necessary to type ‘window’, but I showed it here to demonstrate where wktimeln (a.k.a. gobj) lives)

1 Like

かわいい :slight_smile: