tridactyl / tridactyl

A Vim-like interface for Firefox, inspired by Vimperator/Pentadactyl.
https://tridactyl.xyz
Other
5.19k stars 398 forks source link

Stories in theoldreader.com rss feed not hinted #388

Open cmcaine opened 6 years ago

cmcaine commented 6 years ago

The entries in the RSS feed on theoldreader.com still aren't highlighted. Thought #225 would fix this, but hasn't.

hint -c .header works fine.

Acceptable resolutions include:

bovine3dom commented 6 years ago

We could define all other hint mode selectors as magic selectors? Seems easier than additive flags.

glacambre commented 6 years ago

I don't have an account on theoldreader.com so I can't check but maybe the elements that aren't hinted aren't <a> elements. Could you check if their listeners are set either by an onclick attribute on their HTML tag or maybe in js via elem.onclick = function(){}?

cmcaine commented 6 years ago

They're divs without onclick attributes.

I assume js adds event listeners, but presumably on some ancestor element and we're not picking them up for each individual element.

I think a per-site fix is appropriate here, we just need to build the infrastructure for it.

On Sun, 15 Apr 2018, 12:45 glacambre, notifications@github.com wrote:

I don't have an account on theoldreader.com so I can't check but maybe the elements that aren't hinted aren't elements. Could you check if their listeners are set either by an onclick attribute on their HTML tag or maybe in js via elem.onclick = function(){}?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/cmcaine/tridactyl/issues/388#issuecomment-381400094, or mute the thread https://github.com/notifications/unsubscribe-auth/AFuQed-EDh2YAVXc5udxJsi21dUeR2dwks5tozLXgaJpZM4TVbfH .

glacambre commented 6 years ago

Looks like they set their event listeners through jQuery. It'd probably be good to be able to handle jQuery listeners on all websites. I'll read jQuery's source code to try to figure out what's happening.

glacambre commented 6 years ago

I think what's happening is that $(div).on("click", fn) adds fn to a list of functions that should be called when div is clicked. Then, jQuery adds an event listener on the whole HTML document. When an element is clicked, the handler for the HTML document is called. This handler looks at the target of the event and calls its event handler if needed. Then it does the same for the target's parent. And then for the target's parent's parent and so on until the event has bubbled through the whole DOM. I think fixing this would require dissecting jQuery's internals and handle each jQuery version separately. Clearly not worth it in my opinion. Your original idea of adding a per-site fix seems to be the best workaround.

Unrelated thought: if you ever need to reverse engineer a website's javascript, use chromium instead of firefox. The debugger is miles ahead in terms of features and speed.

cmcaine commented 6 years ago

Thanks for looking into it.

Procrastinating, I had a quick google for events and jQuery and listeners created by jQuery are stored in a global object, but I wasn't able to find them for the elements in question here:

nodesWithEvents = Array.from(document.querySelectorAll('*')).map(
  e => {
    let evs = $._data(e, "events");
    if (evs) return [e, evs]
  }
).filter(e => e !== undefined)
// Select container div for news feed
nodesWithEvents.filter(([e, evs]) => temp0.contains(e))
// Don't get the divs

Suggests to me that theoldreader has an event listener higher up the chain that controls opening and closing of story divs.

I can't see a companion for $._data() that would expose the underlying Map, which is a shame because it would be fine to just process that map but it's a bit expensive to ask jQuery about every element on the page.

bovine3dom commented 6 years ago

Potentially similar issue on https://kanze.co/blog/cinematography-in-user-experience-design. Event is click but we're not hijacking it.