[Userscript] Tofugu Latest

Yow. I didn’t even realize the first three were possibilities.

@AlexandraIDV Opening the Tampermonkey dashboard will check for 1. I think in Firefox Tools → Add-ons and themes will let you check for 2-4.

Re: 5, the one console.log call already added appears to show the script is only being run once, which is what has me so mystified.

Thanks for the reply!

1 Like

Regarding this, have you checked if the callback in the then handler of the fetch request is only executed once, or did you just check if the main script is only run once? I can’t think of any scenario where it would be called twice on one fetch with the default options, but it might be a good idea to check just to make sure.

I tested the script with the same setup (Firefox on Windows 10, same scripts) and I only get the output once. I even tried to see if I could get the then handler to run twice, but I could only get the script to execute once.


My instructions above were to add the console.log() call inside of the then handler, not inside the main script. I’m pretty sure those instructions were followed exactly (based on her console screenshot).

I’m trying and failing to understand how the <section> could be added twice without that console.log() also being called twice, though. If there were a page refresh in between the then() calls, there would still only be one <section class="tofugu-latest">, right?

I think Kumirei’s thoughts around multiple independent instances of the script are the only thing that make sense (one version of the script with the console.log() and the other without).

So weird.

1 Like

If a page refresh occurs the entire page will be reset, and tampermonkey will re-run all scripts from the start. Any scripts executing on the previous instance of the page will be terminated before the new one starts loading, so a refresh shouldn’t affect your script.

That would be one option, I wonder how that would happen though. Tampermonkey should prevent double installations. By default, if a script is already installed and you try to install it again, it will reinstall instead of add, so you’ll still be left with a single instance. I don’t know what the behavior would be with 2 script managers though, although I assume that would give problems during installation too. It’s quite hard to get a double install by accident :grin:


But possibly less difficult than inserting the section twice while only logging to the console once. :grin:

@AlexandraIDV: These are the only further debugging steps I can think of:

  1. Open the Tampermonkey dashboard and check that:

    • only three scripts are loaded: Tofugu Latest, Wanikani Double Check, and Wanikani Stroke Order
    • Open all three in the dashboard editor and ensure they contain the correct script (and not a redundant copy of the Tofugu Latest script somehow).
  2. Check the currently loaded extensions in Firefox. This should be under the Tools menu, Add-ons and Themes. I think it’s accessible via CTRL-Shift-A on a PC. Ensure that only Tampermonkey is currently enabled.

  3. Maybe check for the latest version of Firefox and upgrade if required.

Hopefully, one of these steps will uncover the problem.

1 Like

You could also add a check for the element before adding and, if it exists, either not do anything or replace it

I’ll add that as a bit of “belt and suspenders” programming in the next version.

I’d still want to know WHY it’s already there, though. Something isn’t right if it’s already present.


Yikes. I just looked at this thread for the first time in a long, long while, and it appears I dropped the ball.

Did the double-loading problem ever resolve itself? I can add some debugging to try and resolve the issue if not.

1 Like

Doesn’t seem very mobile friendly. (It’s Kiwi Browser for Android, btw.)

Also, how about <hr> between entries?

1 Like

That might be one option. I could also shorten the slugs for narrow screen sizes.

Geez, I accidentally made work for myself asking about a banana on a toilet. That’s a first.

I’ve not looked at this simple script in ages. Time for an update.

Would it be possible to use this script for other websites? There’s a website I can’t get an rss to work for, so I’m wondering if it would be simple to just swap out simple stuff with this script. I don’t code, so my apologies if this is a bad question.


It’s a reasonable question. I need to think about it when I’m not sipping’ whiskey! :smile:

Surprisingly, that’s actually easier to deal with than updates to the Tofugu grammar guide.

[Ughh. I take that back. I forgot about CORS.]

I suspect a major update to this script is forthcoming.

For the record: bananas now scare me.

1 Like

Also, please make Tofugu logo clickable.

1 Like

Dang, I hate it when I agree with every RFE.

(How did I miss that?!!)

1 Like

Alright, awesome :smiley: I’ll wait for a better time then

I just posted version 0.3 with the following fixes:

  • Clicking on the logo now takes you to the tofugu.com home page (requested by @polv)
  • It now displays better on smaller screen sizes (also requested by @polv)

Unfortunately, two other outstanding feature requests have not been implemented. I need to ponder if they are feasible and worth the effort of implementing.

  • @TofuguSayaka pointed out that the script only retrieves new articles to the blog by date. In particular, this means it does not notify of updates to the Japanese Grammar section of the Tofugu site, which is extremely unfortunate. Unfortunately, the script just grabs the RSS feed provided by tofugu.com. Like many blog sites, they don’t currently update the feed for “static” pages, only for the blog section. I will reach out to Tofugu to see if they can update the RSS feed on major updates to the grammar section (or at least create a blog entry when they do so).

  • Currently this has the RSS feed for tofugu hard coded (Tofugu). @DIO-Berry asked if it could be extended to support arbitrary blogs. Unfortunately, for security reasons all modern browsers prohibit cross-origin resource sharing. Basically, your browser won’t let a script provided by the wanikani.com domain access resources on a different domain unless it’s expressly allowed by the admins of the other domain. The fine folks at tofugu.com added such permission at my request, but other domain administrators are unlikely to add the required exceptions. There are workarounds involving local proxies and such, but they are far too much of a headache to implement.

Lastly, please note that there is a problem when using this script with the Breeze Dark user style: the visited state does not display correctly.

Default display

Display with Breeze Dark enabled (notice all articles display the same regardless of visited status)

Display with Pixel 5 screen resolution (note that article names are truncated to 15 characters)


Lol, they are only fixes for me and mobile experiences.

Tofugu logo is very small however. This smartphone is only like a month old, but you can’t really underestimate how small people’s screen size can be.

1 Like

:sob: thanks for keeping me updated and explaining at least

1 Like

Odd. I must have screwed up the CSS. It’s supposed to take 20% of the available space, with 10px of padding all around. I can only simulate in Chrome where it renders correctly (as shown above).

What model of Android phone do you have? (Or at least the screen dimensions)

Nah, Firefox DevTools gives me same results.