akhodakivskiy / VimFx

Vim keyboard shortcuts for Firefox
https://addons.mozilla.org/firefox/addon/vimfx
Other
1.41k stars 174 forks source link

Firefox 57+ support / Turn VimFx into a WebExtension #860

Closed lydell closed 3 years ago

lydell commented 7 years ago

Note: VimFx is dead. It won't be updated for Firefox 57+. See README.md for more information.

Orginial post below. Warning! It contains some outdated stuff.


Firefox has several types of extensions. The newest type is called “WebExtensions.” Mozilla plans to stop supporting all other types than WebExtensions at the end of 2017.

See Mozilla’s blog post Add-ons in 2017 for more information.

VimFx is not a WebExtension.

The other types of extensions are very flexible. They can do almost anything. While that is really cool, it also holds back the development of Firefox. Wonder why multi-process Firefox took so long?

WebExtensions are not as powerful — yet. Mozilla seem to be open to adding new APIs, but it will take time.

VimFx will be maintained and continue to work like it does now as long as Mozilla supports the “legacy” types of extensions. But no new features will be added. The more features, the harder it will be to turn VimFx into a WebExtension.

For a couple of months, I looked into converting VimFx to a WebExtension. But I've lost the motivation.

So, for now I recommend supporting philc/vimium#2425.

I want to create a new extension with the best of VimFx. But I don't know when that will happen.

Here are a bunch of interesting links:

Summary:

letientai299 commented 7 years ago

Hi @akhodakivskiy, I've followed this topic for a while. Since there's nothing news recently, I wonder:

lydell commented 7 years ago

Thanks for reaching out, @letientai299! Ive updated the issue description.

What is the current status of WebExtension VimFx versioon?

There is none.

Where is the repo of WebExtension version?

There is none.

When could we suggest new features for VimFx?

Never. (Or when a new maintainer decides that it would make sense.)

f1u77y commented 7 years ago

There couldn't be any WebExtension version now because its APIs don't have proper keyboard shortcuts handling (yet?).

On 03/28/2017 09:49 AM, Tai Le wrote:

Hi @akhodakivskiy https://github.com/akhodakivskiy, I've followed this topic for a while. Since there's nothing news recently, I wonder:

  • What is the current status of WebExtension VimFx versioon?
  • Where is the repo of WebExtension version? (So that we could learn and contribute)
  • When could we suggest new features for VimFx? The issue template still direct to this issue, which is clear that feature request are not accepted.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/akhodakivskiy/VimFx/issues/860#issuecomment-289679537, or mute the thread https://github.com/notifications/unsubscribe-auth/AKyf5bQhlGEAyg5Q9HLrNdBHf73Gr312ks5rqK2KgaJpZM4LdYpl.

-- Bogdan Sinitsyn

lydell commented 7 years ago

There could absolutely be a WebExtension version now: Vimium is living proof. But the keyboard shortcut handling is very different in WebExtensions, and more restricted. A WebExtension version will be similar but different. Never ever 100% the same.

Eremiell commented 7 years ago

So I just noticed, my Firefox Nightly tagged VimFx as legacy today and came around to see, how things are. What I read here is a bunch of bad news.

I have Vimium installed in my Google Chrome and VimFx is one of the huge reasons I stick with Firefox. Even without VimFx I still wouldn't convert, as the other reasons add up, but it feels and works so much smoother and generally better.

I have no clear insight into how much work it is to convert VimFx or an other legacy add-on into the WebExtension, but I still really hope, this will happen.

Just wanted to personally thank you for all the hard work so far and show how much useful it is to me and certainly countless others and express my hopes it will survive this change.

Thank you and everyone who helped make this happen so far again.

lydell commented 7 years ago

I have no clear insight into how much work it is to convert VimFx or an other legacy add-on into the WebExtension, but I still really hope, this will happen.

Thanks for the positive words! But realistically, VimFx is basically dead. 😢

Eremiell commented 7 years ago

Is there any way I could possibly help? Most of my work happens in C++, but I probably can write an ECMAScript line or dozen. But I'm no expert on the domain, neither ECMAScript, nor browser plugins. Still would love to give a hand if possible.

lydell commented 7 years ago

Is there any way I could possibly help?

Nobody, including me, have "signed up" for doing this so far, so you wouldn't "help" but rather "do it all yourself". If you want to do that – great! You'd make lot's of people happy. Having worked on every single part of the code base, I can provide guidance to anyone who would like to try porting to a WebExtension a go. 👍

Eremiell commented 7 years ago

I'm not sure, I'm the right person to push the whole thing through as I haven't done any major ECMAScript since 90s before the whole "block scripting in your browser" movement (which was huge at least locally), which turned me other ways. I may look into WebExtensions docs (there are some, right?) once I have an hour or two to see what it actually expects. I have agreed before to go ahead on projects I had no technical knowledge about and if it gave me one thing, it was to look into it before whenever possible.

I'd love to see VimFx to roll on and if I find out, I'm able to help that, be it rewrite it myself, I'll give it my best. But don't put up bets on that yet. If anyone else feels like pushing it forward, someone with more experience in ECMAScript and browser extensions, I'll gladly assist.

braham-snyder commented 7 years ago

another alternative is qutebrowser (it's not Firefox, but that's of course better in some ways: it's unencumbered by WebExtensions, for example), whose author just funded a kickstarter (that hasn't ended yet) to work full-time on v1.0

f1u77y commented 7 years ago

I'd like to try translating (subset of?) VimFx to WebExtension. I know that Vimium exists but their main goal is to support Chrome and not to struggle with non-trivial Firefox incompatibilities. And I do also like the VimFx way(extensive usage of default browser features instead of reinventing the wheel).

I've looked into the code but I have now some questions to @lydell:

  1. AFAIK features like "focus some browser element" are dead due to nature of WebExtensions. That could be main reason for Vimium authors to implement their own UI for opening pages(which I don't like). Could there be any progress in the related issue?
  2. I cannot understand how does the smooth scrolling work. As I can see it calls element.scrollBy({ top: someNumber, behaviour: 'smooth' }) but when I try to call it from the console, scrolling is not smooth.
lydell commented 7 years ago

@f1u77y Awesome!

  1. Yep, "Click browser element" is dead, and won't come back, and yes, this is the main reason for Vimium re-implementing UI stuff. You'll have to look at bugzilla for progress on potential APIs for such things, but I haven't seen anything there lately, and I actually don't expect any progress either. For now, all commands that simply can't be done must be dropped.

  2. Smooth scrolling uses element.scrollBy({ top: someNumber, behaviour: 'smooth' }), that's correct. (Search for "spring" through the entire codebase and you'll find everything you need to know, including documentation.) In other words, VimFx uses the web standard for "native" smooth scrolling. Unfortunately, the default scrolling speed is a bit too slow. The speed can be adjusted using the layout.css.scroll-behavior.spring-constant in about:config, though, so VimFx temporarily sets that pref to a different value while scrolling. Chances are that VimFx has failed to reset that pref to the previous value again some time, which might be why you don't see the smooth scrolling when running the code in the console. Try resetting it, and then run document.documentElement.scrollBy({top: -100, behavior: 'smooth'}) in the console on this page; that should scroll 100px up smoothly (it does for me at least). A WebExtension can't set the layout.css.scroll-behavior.spring-constant pref temporarily though, so you would need to implement your own smooth scrolling, like Vimium does. That might be good anyway, since the current setup is a bit hacky and many people prefer Vimium's "scroll without stopping" behavior: #811.

I'd say that the biggest challenges for a WebExtension version of VimFx are:

senden9 commented 7 years ago

@lydell: To point 1: What is with the HTMLElement.click() method? It seems to be a DOM standard. Is it not possible to call this from webextensions? (I have to say that i never before programmed a webextension)

The-Compiler commented 7 years ago

@senden9 That's for web elements, not browser UI things.

f1u77y commented 7 years ago

so VimFx temporarily sets that pref to a different value while scrolling

Yes, that was my fault. I've set the spring constant to VimFx value and made it work. Thanks!

you would need to implement your own smooth scrolling

What's the problem with instructing user to set it himself? Yes, that's not smooth scrolling out of box, but that works the same as default Firefox scrolling and I don't think adding any solutions that browser already has is a good idea except if they are notably different from browser ones.

Extensive usage of default UI with modified keyboard shortcuts was the main reason behind using this extension for me.

lydell commented 7 years ago

What's the problem with instructing user to set it himself?

Different commands unfortunately need different values.

chetgurevitch commented 7 years ago

Chromium-vim has vimfx-like smooth scrolling, (I believe this is the relevant code).

Could that be applicable?

eejdoowad commented 7 years ago

So... I happened to work on smooth scrolling today in my keybinding extension. cVim's smooth scrolling works, but pauses for a split second after the first keypress. Vimium's smooth scrolling works great, but doesn't make sense. Have a look at how I do it. Also take a look at the smooth scroll polyfill.

eejdoowad commented 7 years ago

I'm building a keybinding web extension that derives from existing ones like Vimium, cVim, and VimFX. I want to address some of the challenges you mentioned:

Content scripts can no longer reach into every frame. So instead of loading one single content script per tab, we need to load one content script into every frame and have them communicate with each other. This affects event listeners and DOM element finding.

This complicates things a lot, but is manageable, (as shown by cVim and Vimium). You have to make sure to

  1. load the content script into every frame
  2. listen for events in all frames
  3. message between frames to access information and send commands.

An example is link hints. When you press F, you expect to see link hints for all visible elements, including those in frames. Only one frame will detect the F keydown event. It then messages all frames in the current tab telling them to find the hintable elements. Each frame messages back the total number of hintable elements found, and the total number is sent back to each frame so that the correct string can be rendered in the link hint.

Key handling can no longer be done in the main Firefox process, only in content scripts.

We're stuck with native DOM events... as you've no doubt discovered. This isn't too hard to work around, but... there will definitely be corner cases that will be hard to cover. E.g. Google Groups keyboard shortcuts are captured and might run before listeners installed by the extension.

Smooth scrolling needs to be manually implemented.

Piece of cake

Currently, Firefox's built-in UI for VimFx's settings is used. As a WebExtension, all UI must be manually implemented.

True. The options page is typically just an html page which saves stuff to local storage. Should be easy to port the firefox UI's functionality.

Taking decisions on all trade-offs and workarounds needed to get the VimFx experience as a WebExtension.

Are there any notable differences between VimFx and Vimium/cVim? Anything VimFX has that you feel those don't quite replicate?

Also, are there any docs on VimFx's architecture? How do you keep track of which mode is active? Vimium has its handler stack, cVim has variables and conditions, I use a state machine, what does VimFx do?

Also, have any tips on making link hints better?

One last also, VimFx is the only one i've noticed that addresses quirks mode behavior. Anything major to watch out for?

f1u77y commented 7 years ago

@eejdoowad

Are there any notable differences between VimFx and Vimium/cVim? Anything VimFX has that you feel those don't quite replicate?

I'd like to note:

eejdoowad commented 7 years ago
f1u77y commented 7 years ago
lydell commented 7 years ago

Thanks for your input, @eejdoowad!

Are there any notable differences between VimFx and Vimium/cVim? Anything VimFX has that you feel those don't quite replicate?

I can't really say anything about cVim, but I can make some comparisons with Vimium.

First I'd like to address the three points brought up by @f1u77y. In my opinion, those points are not very important at all.

My favorite features of VimFx that aren't in Vimium are:

You can also search for VimFx in the Vimium issue tracker to find VimFx differences.

Also, are there any docs on VimFx's architecture?

Other than that, there's not much more documentation on the architecture itself than the summarizing comment at the beginning of each file.

How do you keep track of which mode is active?

VimFx has one object for tracking global state (the VimFx class). Then, there's one object per tab keeping track of tab specific state (the Vim class). The current mode is tab specific, so it is stored on the Vim objects. The .name property on a Vim instance is simply the string name of the current mode. Each mode is simply an object that implement certain methods, such as onEnter(), onLeave() and onInput() (see modes.coffee and Mode object). Vim::_enterMode(modeStringName) is used to switch mode.

Also, have any tips on making link hints better?

Plenty. Hints mode is what I've spent the most time on in VimFx. See my comparison with Vimium above. I'm more than happy sharing what I've learned about it, so feel free to ask questions! Here are some links:

One last also, VimFx is the only one i've noticed that addresses quirks mode behavior. Anything major to watch out for?

Only one thing: Whether <html> or <body> is to be considered as the root element. This needs to be taken into account when:

Hacker News is an example of a real world quirks mode site.

Here are some links:


Again, thanks for your input, @eejdoowad! I wish you the best of luck for your keyboard extension! Feel free to open issues here if you'd like to ask about something (anything at all!). Make sure to ping back here when you feel like your extension is starting to get in a nice state. I want to eventually link people to replacements for VimFx.

polyzen commented 7 years ago

I love the config file because it makes it easy to:

Doesn't seem the first two bullets will be possible with a webextension, so I mostly added the last item as a consolation (though it is great to have).

Shame to say I've only scratched the surface of VimFx.

eejdoowad commented 7 years ago

Thanks for the thoughtful response @lydell. I'll definitely review your link hints implementation thoroughly when I get around to optimizing mine. I had taken a look earlier, noticed bloom filters and huffman trees, then decided to save it for another day. What I have now favors ease of implementation and customizability over performance. Did you ever explore pre-computation/caching for link hints?

I've taken a similar approach with modes - each mode is a simple object with methods like onEnter and onExit, but also handlers for common DOM events and messages from other pages.

At this stage, Saka Key is usable for general browsing, but only normal mode and hints mode are implemented. The version on the Firefox marketplace is outdated, so it's best to build it yourself following the instructions on Github. Or try it out on Chrome.

@polyzen, the second bullet is possible. Surfing Keys sells itself on custom commands. 3 and 4 are really good points.

I'm currently working on:

All suggestions appreciated.

lydell commented 7 years ago

noticed bloom filters and huffman trees

To save you some time: We used bloom filters a few years ago, but not anymore. But very much huffman trees.

Did you ever explore pre-computation/caching for link hints?

Yep. My theory is that it can't be done. See also #409.

each mode is a simple object with methods like onEnter and onExit, but also handlers for common DOM events and messages from other pages.

Sound good! I forgot to mention that while most of all mode specific logic is contained in the mode objects, there are a few if vim.mode == 'hints' etc. sprinkled in event listeners and such. That has never grown out of control, though. But it definitely sounds nice to to have handlers for events on the mode objects! 👍

ensuring keybindings work across different keyboard types - (by using KeyboardEvent.code + modifiers to store keybindings)

For a long time, VimFx had trouble with other keyboard layouts than en-US QWERTY basically. See #249. Solving that required a lot of experimentation. What I learned is that some people want the character that would be typed when pressing a key to be seen by VimFx (event.key), such as German and Swedish users, while others want the key printed on the key cap to be seen by VimFx (event.code), such as Russian users. That's why VimFx has the "Ignore keyboard layout" option. So my advice is to not only use event.code! See https://github.com/akhodakivskiy/VimFx/issues/249#issuecomment-50230305.

HunterGraubard commented 7 years ago

I've been happily using VimFx for a long time, and with the release of Firefox 54 and its multi-process features, I decided to check compatibility for my add-ons... and found this thread. This is horrible news! VimFx is so much better than Vimium... I'm so sad to hear that it's not going to have a future...

lydell commented 7 years ago

@HunterGraubard VimFx works fine with multi-process and Firefox 54. (But VimFx is still basically dead.)

HunterGraubard commented 7 years ago

Yes, it may still work for now... but it's terrible news to hear that it's a dead project and that people are just being directed to Vimium... VimFx is really so much better than Vimium. I hope someone can take on the work required to keep this extension going. :(

chetgurevitch commented 7 years ago

The extension is going to stop working in a couple updates, would need to be completely rewritten and still couldn't preserve all the current functionality. It's not really a matter of needing someone to put in work.

eejdoowad commented 7 years ago

Is it possible to relicense VimFx's code, particularly the logic for finding markable elements, under an MIT license? My current implementation in Saka Key is very slow on Firefox, especially on large pages. Thanks

mcomella commented 7 years ago

FYI: it was announced that tomorrow's Firefox Nightly will disable legacy extensions by default so presumably VimFx will stop working in 57.

lindhe commented 7 years ago

Regarding @eejdoowad's seemingly off-topic comment on the license: I generally like copy-left licenses like GPL, so my initial reaction was that we should not budge. But then I dwelt on it and think that it might make sense to not use a copy-left license on a dead project. The biggest upside with copy-left I think is that it ensures that "you can benefit from my code, but I can too benefit from your changes to that code". And while that is a really nice feature for an ongoing project, I see no reason for it on a dead project. The only reason to keep at a copy-left license would be to try and spread GPL licensing, which at that point would be purely for ideological purposes with no real benefit to this project.

Unusual as it is for me, I'd vouch to relicense the code. MIT is a great license.

musoke commented 7 years ago

It's actually still working for now... but exppecting it to stop any day.

On 08/10, Michael Comella wrote:

FYI: it was announced that tomorrow's Firefox Nightly will disable legacy extensions by default so presumably VimFx will stop working in 57.

-- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/akhodakivskiy/VimFx/issues/860#issuecomment-321633389

lydell commented 7 years ago

@lindhe’s comment convinced me. I’d like to change the license, but there are more copyright holders. I emailed @akhodakivskiy and @zhuochun about a couple of days ago, but neither of them has replied yet. We also need to ask @XrXr (I don’t have his email address). If nobody answers, I guess we could change the license only of the files that only I have copyright on. We could possibly even change the license on stuff that @akhodakivskiy and @zhuochun have copyright on, because VimFx used to be MIT licensed and neither of them have contributed code after the license change to GPL.

XrXr commented 7 years ago

@lydell Got email from Github. I have no problem giving up my copyright on the stuff I contributed :) feel free to do whatever

zhuochun commented 7 years ago

I have no problem giving up my copyright as well. Thanks for notifying.

eejdoowad commented 7 years ago

Thanks for the relicense! Now I definitely have to port VimFX's algorithm.

Also wanted to mention that Saka Key is now a pretty good choice for Firefox (in my subjective opinion). It has import/export support, configurable profiles, good presets, smooth scroll, multi-frame link hints, and, as far as I can tell, no deal-breaking bugs.

Give it a chance by installing the Development Channel version from the Addons Marketplace. Don't install the default version as that's hopelessly outdated.

lydell commented 7 years ago

@eejdoowad The actual relicensing hasn't happened yet, but I'll get to it soon. Nice to hear about the progress on Saka Key! I want to try that out soon too, and add links to Saka Key and Vimium in the VimFx description so that people find their way to alternatives.

lydell commented 7 years ago

@eejdoowad VimFx has now been re-licensed to MIT. Enjoy!

I've also now officially declared VimFx dead, and added links to Vimium-FF and Saka Key in the readme as well as on AMO.

pluto439 commented 6 years ago

How about continuing development for palemoon instead? I can try to help with something.

I tried to switch to chromium, but I can't get used to the ui. I tried remove this "use f11 to exit fullscreen mode", but the answer I found honestly asked me to patch dll file in hex editor. I'm shocked by how hard it is to get such simple things. https://superuser.com/questions/1264349/how-to-completely-remove-press-f11-to-exit-full-screen-chromes-message

Also it's impossible to get "ctrl-v to enter address bar" and "esc to leave it" in anything that's not VimFx. It's kind of glitchy in VimFx too though, sometimes it mutes the page instead. Still, it's a must have for me. I can't compile chromium on my own pc, so I can't change anything in there. Maybe with palemoon I'll be more lucky.

lydell commented 6 years ago

Re-opening so peolpe can find this more easily.

lydell commented 4 years ago

Three years later … if anyone’s still around here I’d like to plug my new extension – Link Hints. It’s basically VimFx’s Hints Mode on steroids.

Note that it’s not a replacement for the Vim parts of VimFx – it’s just link hinting. It does not even offer Vim-style keyboard shortcuts. These days I just use standard browser shortcuts plus Link Hints.

Enjoy!

girst commented 4 years ago

congrats on shipping! I've been following your new project for some time now. any blog posts or similar explaining the inner workings planned?


note, to others reading this: vimfx (and the legacyfox shim for fx68+) is still being maintained for the forseeable future.

lydell commented 4 years ago

Nothing planned, but yes, I should probably write something about it.

braham-snyder commented 4 years ago

To those thinking "I need the vim parts", it sounds like there's some chance Link Hints could be integrated into other vim extensions.

Two big advantages would be vastly faster hinting and more intuitive placement.

Link for potential integration: https://github.com/lydell/LinkHints/issues/6

girst commented 3 years ago

Closing, as the information here isn't accurate any more. VimFx has supported Firefox 68 or higher for a while now.