taustation-fan/userscripts

discreet_helper.user.js is sometimes too fast

Closed this issue · 6 comments

Sometimes the discreet keyboard helper triggers a mission step before the people tab loads, which then looks like this:

Then it gets stuck, requiring manual clicking around to get into the flow again.

One possible solution would be to detect if the people tab has already loaded, by checking the NPCS heading is present:

if ($('h2:contains("NPCS")').length > 0) { ... }

But I'm not sure where to insert that.

@duelafn could you please help with that?

Yeah, I get this occasionally too, but I'm not sure how it is happening. The relevant chunk starts at line 88,

    // People page with a mission NPC
    node = document.querySelector('a.has-mission')
    if (node) {
        window.location.href = node.getAttribute('href');
        followed_link = true;
        return;
    }

That directly follows the NPC link that has the mission flag on it. There is no url prediction, so the NPCS header is already on the page along with most (though perhaps not all) of the people list.

I've tried a couple random ideas but neither seems to get rid of the issue:

  • I delayed setting the href in case the page had more to do before following the link setTimeout( function() { window.location.href = node.getAttribute('href'); }, 500)

  • I put an additional followed_link check immediately before setting location.href in case we were getting two key press handlers running simultaneously. if (!followed_link) { followed_link = true; window.location.href = url; }

Neither of these even seemed to reduce the likelihood of occurrence, I can still trigger it within one or two missions of aggressive key pressing.

I skimmed through tau station's veure-tabs.js hoping to find the page doing something odd, but everything there looked reasonable too - just seems to fill the people table and stop.

@duelafn fascinating :-)

I have another hypothesis: the people tab isn't displayed yet, so maybe we can detect the condition that triggers the error by checking the visibility of the element. I'll try that, but my javascript + DOM fu is a bit rusty now, so I don't know if I'll make any progress soon.

Ok, didn't work out :-(

If we cannot prevent this situation, we could try to recover from it. In this situation, there's always a people tab with an mission action star visible, something like $('.mission-flag--img:visible').length == 1.

Does that strike you as reasonable?

Finally got to this. Added a click on the people tab as a fallback if it is flagged. Helps this issue and helps go to people tab if you manually walk away and come back later.

I did encounter one time where the message was displayed and the mission moved on to the next location while leaving me in the current location, so the people tab wouldn't be flagged. I doubt this fix will address those situations. Hopefully they are rare.

Thanks @duelafn!