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).
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
But possibly less difficult than inserting the section twice while only logging to the console once.
@AlexandraIDV: These are the only further debugging steps I can think of:
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).
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.
Maybe check for the latest version of Firefox and upgrade if required.
Hopefully, one of these steps will uncover the problem.