lusakasa / saka-key

A keyboard interface to the web
https://key.saka.io
MIT License
862 stars 70 forks source link

'Clicking' the play button on bandcamp doesn't work #50

Open wisp3rwind opened 7 years ago

wisp3rwind commented 7 years ago

As the title says, f + selecting the play button (it does have a link hint) on e.g. https://whitneychicago.bandcamp.com/album/you-ve-got-a-woman-lion-cover-b-w-gonna-hurry-as-slow-as-i-can-dolly-parton-cover has no effect, i.e. does not play the song.

This applies to both up-to-date Firefox and Chromium with v1.23.1. If I can help debugging this, please tell me how.

eejdoowad commented 7 years ago

Thanks for the report!

This bug exists because the play button is implemented as a div wrapped within an anchor element: <a><div></div></a>. When Saka Key dispatches the click event, it dispatches the click to the anchor, not the div. But the event listener that pauses/plays is attached to the div, not the anchor.

The fix is as follows: If A) a parent element and one of its descendants are both clickable and B) the descendant fills up the parent, then assign the hint only to the descendant.

The current logic assigns the hint to the parent. I'm not going to fix this right away, as I intend to replace the logic for finding hints with VimFx's algorithm.

wisp3rwind commented 7 years ago

Alright, thanks for the response and the extension in general. I'm very much looking forward to more of VimFx' functionality being 'restored' here :)

lydell commented 7 years ago

The reason VimFx is able to click this “button” is because it uses an old Firefox API for checking if elements have click listeners (added using element.addEventListener('click', ...)). One would have to hack .addEventListener of all pages in order to do something similar in a WebExtension. See also https://github.com/akhodakivskiy/VimFx/issues/672 and https://github.com/akhodakivskiy/VimFx/pull/676.

eejdoowad commented 7 years ago

Oh I see now. Thanks for the explanation. Looks like I'll have to investigate either monkeypatching EventTarget.addEventListener or see how cVim and Vimium do it.

lydell commented 7 years ago

Vimium has an open PR for hacking addEventListener: https://github.com/philc/vimium/pull/1859