LinkHints.unhoverLast doesn't work in this situation
Describe the bug
An a element has two event listener onmouseenter and onmouseover, they produces two different effects. But vimium-c LinkHints.unhoverLast just cancels onmouseenter effect but not onmouseover effect.
To Reproduce
Steps to reproduce the behavior:
This is a paid website, so maybe I cannot produce.
Browser, OS and Vimium C versions
- Browser name: Chrome
- Browser version: Version 105.0.5195.125 (Official Build) (64-bit)
- Vimium C version: Vimium C 1.99.3, Google Chrome 105, Linux.
- OS name and version: Ubuntu 22.04
Extra infos If I execute below code, both two effects are canceled.
var event = new MouseEvent('mouseleave',
{view: window, bubbles: true, cancelable: true});
var cancelled = !aElement.dispatchEvent(event);
Vimium C dispatches mouseout (bubbles: true, cancelable: true) and then mouseleave (bubbles: false, cancelable: false) in order, and this order has been used by Chrome for years and is still correct on Chrome 106. So there're such potential reasons of this issue:
- the website binds
mouseleavelisteners in a child element, but LinkHints in Vimium C trends to select a parent element, and then the listener was not triggered - maybe the website's effects can not work well if
mouseoutandmouseleaveare simulated by Vimium C in a same "macro task".
Vimium C's another command, named
dispatchEvent, can be used to work around this compatibility issue:
Oh the correct mapping is:
map <v-dem> dispatchEvent direct="clicked" class="mouse"
run xxx dem#type=mouseout+dem#type=mouseleave&bubbles=false&cancelable=false
Added: syntax of run: https://github.com/gdh1995/vimium-c/wiki/Auto-run-a-tree-of-commands
Thank you.
Is there doc about dispatchEvent? I don't understand what direct and class options mean.
Um, basically:
- the command is to create a simulated "event" object and "dispatch" it using browser's
dispatchEventAPI (https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/dispatchEvent); classmeans the "class type" of an event instance to be "dispatched", likekeyboardforKeyboardEventandmouseforMouseEvent;typeis just thetypemember of a JS Event instance- other common properties are passed to the
MouseEventconstructor asoptions(https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/MouseEvent)
There's no document but only source code:
- entry point of
dispatchEvent: https://github.com/gdh1995/vimium-c/blob/68b4f58c092c806d79fb4461bd29c11aa5beb461/background/all_commands.ts#L188 class: https://github.com/gdh1995/vimium-c/blob/68b4f58c092c806d79fb4461bd29c11aa5beb461/background/all_commands.ts#L193direct: https://github.com/gdh1995/vimium-c/blob/68b4f58c092c806d79fb4461bd29c11aa5beb461/content/link_hints.ts#L548
This is worked for me.
map <v-dem> dispatchEvent direct="clicked" class="mouse"
run Q dem#type=mouseout+dem#type=mouseleave&bubbles=true&cancelable=true
So does your test page require bubbles=true? But mouseleave should not have a bubbles of true, as far as I've tested on recent versions of Chrome and Firefox on Win11.
Sorry, I just try and pick first successful expression.
After some tries, I find run Q dem#type=mouseout+dem#type=mouseleave&cancelable=false just works which remove bubbles=false
Hello, v1.99.90 has been released on Chrome Web Store, and its LinkHints.unhoverLast (also also dispatchEvent) supports a parameter of bubbles=true:
map xxx LinkHints.unhoverLast bubbles
And you may take a try.
@gdh1995 This works perfectly. Thanks for your work.