[Userscript] Lesson/Review Count in Forums

Mine seems fixed too. :+1: Thanks!

This led me to finally get this script working (for me) again! For some reason it never auto-updated (I probably failed to hit “update” some time it popped up), so I was a bunch of versions behind! (This fix caused me to check, and see that my last update was a long time ago rather than today.) Updating and refreshing (a few times) made everything work. (This fairly obvious solution did not occur to me because other scripts have successfully updated in the interim, probably because sometime along the way I figured out I had to hit the “update” button when/if an “updated script!” tab popped up.)

Just, y’know, in case anyone was worried for me over here.

Disclaimer: I am completely clueless of how cache is normally handled.
I went into the the Application tab in the developer tools and had a look at the cache storage for the forums. In there I found a cache for /v2/summary with the exact data being displayed in the header. I figured it was somehow being cached by either the browser or maybe Discourse themselves decided to do it (like I said, I am clueless), so I googled how to ignore cache in XML requests, which lead me to that header. I tried it and it seemed to work.

Good enough :+1: :slight_smile:

I suspect, though, that it’s actually a WK problem. Normally, the server is responsible for telling the browser (and all of the routers between the server and the browser) how long something should be cached. I haven’t looked at the response headers, but if I had to guess, I’d say they stopped populating the correct cache headers.

1 Like

Ah, that makes a lot of sense. Thank you!

Hey, has anybody made something like this for the Dashboard/ wanikani.com? I miss having it up in the top bar with numbers…

1 Like

I think what you want is @Kumirei’s script [Lessons & Reviews In Header].
It’s listed in [Kumirei’s Userscripts] thread.

3 Likes

Thank you! : D

1 Like

I have this script and @Kumirei’s Like Counter script installed on my forum page. Every time I refresh the page (with Chrome’s refresh button) the active script counter on Tampermonkey icon increase by two. This is no big deal but I thought you would want to know.

I use up-to-date Chrome on Windows 10.

Based on a little bit of experimentation, it seems to do this with only Kumi’s script installed. No idea what could be causing it. Seems like that should be a Tampermonkey bug since there shouldn’t be a way (from within Javascript) to directly affect the script count.

Interesting. I’ve been experiencing the bug as well, but I didn’t know it was due to the like counter. I have no idea what might be the cause

An interesting mystery. Let me know if you figure it out. I would attempt it myself if I didn’t have a product demo next week.

1 Like

Actually, I am still experiencing the bug with the Like Counter turned off, so I don’t think it’s specifically that one script. A hard refresh seems to reset the count, while a regular refresh increments it.

I don’t have this bug with the Wanikani dashboard scripts. If it is Tapermonkey acting out it does so only in the forums.

@Kumirei
I wonder if Discourse is loading multiple iframes for some reason, and scripts are being loaded per-iframe. It could be a Discourse bug!

Edit: Well, if that’s the case, doing a console.log() inside the script isn’t showing more than one message in the console. I wonder if iframes log to the same instance of the console. I’ve noticed before certain devtool behavior is different for iframes.

1 Like

Would that cause the number to increase at every refresh? I would think it would only cause a static multiplication of the number, not an increment at every refresh

Unless discourse had some sort of state bug, which I’ve seen before with a stuck-open post editor.
But I’m not sure if that’s the case here.

1 Like

Also, wondering if it can be reproduced on meta.discourse.com.

Yep. Happening there for me with only Spongebob Timecards and a Youtube link highlighter script active

1 Like

Whenever I’m on any page on the forum (and scroll down from the top of the page, even just a bit), and then click the button with my profile pic to check notifications, the page scrolls down a whole page. Doesn’t happen when scripts are disabled, and it seems like it is related to any scripts that uses the header like this script, or @Kumirei’s Like Counter or Regular Status scripts.

This header
image

Haven’t seen anyone mention it, so hope it’s not just me. Has been like this for a few days.

Edit: Huh… happens when I click the search button :mag: and hamburger menu too.

image

2 Likes