[Userscript] Detailed SRS Popup

Also, this might be a separate problem, but I use Double-Check, but for some reason I see two lightning mode buttons, two re-type buttons, one mark right button, and one mark wrong button. Is this related? It feels like it started after I installed this

Edit: now suddenly it’s normal. I have no clue what’s going on with these two problems.

That is…odd.
Do be sure that you’ve completely refreshed the page after updating the scripts. I.e., using the F5 key or the browser refresh button.

Yes I did do that.

I enter the answer, it turns green, and I click enter again, but it doesn’t go to the next question. I click it again a few more times, and the answer turns into “undefined”, then the lost-connection pop-up comes up.

Edit: I tried turning off all other scripts then these two and WKOF, and this time, when I click enter after getting it correct, it just shows the same item again in a loop.

I don’t know what to tell you other than just stating the obvious. Clearly, something is interfering with the proper functionality. And I can confirm that this is something that is not inherent to all users of the script, since it works fine for me.

It may be useful for you to check the console to determine what kinds of errors are showing up, and if possible, check their stack traces to determine what scripts are malfunctioning and where.

Also, there’s any number of other things that might be contributing to your issues, even something like a very strictly configured adblocker, for example.

I looked at the console and when I first type in the answer and click enter, this shows up:


Then when I click enter again and nothing happens, this shows up:

Then when I click enter another time and it shows undefined that it tells me to reload, this shows up:

Also I have no adblockers and extensions other than Tampermonkey.

Edit: When I have the Queue Manipulator on but SRS Popups off, it works fine. So there’s something wrong when both of them are on

Looks to me like those first two errors are happening in Double Check.

And I tried to trace it back myself to figure out the issue, but it’s kinda insane what’s happening.
Basically, SRSManager isn’t even returning the default stage names map. However, since that’s WaniKani’s internal implementation and not part of a userscript, what seems like is actually happening is a script is modifying (or somehow deleting) the srsId property of the internal subjectIdSRSMap map.
Though that makes absolutely no sense to me.

I have doubts that Double Check itself is the problem, since myself and thousands of others use it, but you can always check out the Double Check topic and see if you can get help there after you’ve exhausted other options.

In any case, your next step should probably be to try again after disabling all other userscripts. If it works, then systemmatically reenable/disable them until you can narrow down which one’s causing the problem(s).


The third (and last) userscript error is in Heatmap, but that one I have seen before, myself.
Though it’s unlikely to be affecting your reviews, if you’d like to fix it, you can modify your Heatmap script locally with something like

This

Replacing these lines (around line # 52)

            window.addEventListener('turbo:load', async (e) => {
                setTimeout(main, 0)
            })
        }

With

        }
        window.addEventListener('turbo:load', async (e) => {
            setTimeout(main, 0)
        })

Essentially the only change here is moving the bracket up to before the addEventListener so that it’s properly added no matter what page you start on, which also ensures that it’s loaded after you finish a review session.
(What would be better, however, would be to define the anonymous function outside of the main function, and then add a removeEventListener call before it, so that future calls don’t end up recursively adding a new listener…, but it’s probably not too big of a deal, particularly if you’re regularly manually refreshing the page).
(though that would make the end of the main function look something like this instead)

        }
        window.removeEventListener('turbo:load', call_main)
        window.addEventListener('turbo:load', call_main)
    }

    function call_main() {
        setTimeout(main, 0)
    }

Anyway, and then you’ll want to do the following…

Replacing these lines (near line # 1097)

        if (!document.getElementById('heatmap') || heatmap.getAttribute('position') != settings.general.position)
            document.querySelector(position[0]).insertAdjacentElement(position[1], heatmap)

With

        if (!document.getElementById('heatmap') || heatmap.getAttribute('position') != settings.general.position) {
            let precedingSibling = document.querySelector(position[0])
            if (!precedingSibling) return
            precedingSibling.insertAdjacentElement(position[1], heatmap)
        }

This will prevent the console error you’re seeing, as well as many of the side-effects there may or may not be.

I fixed Heatmap like you said, and the only errors from it are “Review Cache: Error fetching reviews”, which is probably the reason I can’t see reviews before I installed Heatmap.
I also don’t think Double Check is the problem because the error occurs without it, and with Double Check, the error visible to the end user is different, but it’s the same error, just without “at t.new_submit_handler…”
Whatever is modifying the srsId property you’re talking about, it’s likely Detailed SRS Popup. I’ll try checking it on a different computer because it seems that it’s working for everyone else.
Edit: Happening on a different computer, so it isn’t because of this computer.