philc / vimium

The hacker's browser.
https://chrome.google.com/webstore/detail/vimium/dbepggeogbaibhgnhhndojpepiihcmeb
MIT License
23.03k stars 2.47k forks source link

Feature Request: Command palette #3927

Open mehmetkaradeniz opened 2 years ago

mehmetkaradeniz commented 2 years ago

Hi,

I'd like to hear you guys' opion on command palette feature.

image

Basic Idea

Having some commands available for domains, pages, urls etc. For example: When you visit github and activate command palette, you will see list of commands available for github domain OR github/repo page. Real life example: When I'm on bitbucket pull request page, I run a command and it creates a pr message from all new commits on current branch.

Why this feature?

I like running pre-defined scripts (I'm calling them commands in this context) on the pages I visit frequently. Useful when you want to read or modify DOM, inject html or some functionality on the current page.

Some implementation details

It uses service classes and determines which service to use from current url or given url. Each service has list of available commands and handler for that command. When you activate the command palette (c-P hotkey), it lists commands fetched from current service. Completions handled by CommandCompleter similiar to other completers in completion.js Also it's possible to map hotkeys to these commands (Right now I use q, e, and , easy to extend)

I haven't thought about how to make this feature available for non-developer users yet. Maybe let users register scripts in options page and make them available on urls (regex match?)

I'm currently working on this feature for personal use and can provide a prototype.

muratakburak commented 2 years ago

This would be cool. You can write a script to create an issue assigned to you with a certain tag on azure or a script to like and leave a "Nice one!" comment on a youtube video. And then there could be vimium script store where people could publish and browse scripts. Such a dream lol

gdh1995 commented 2 years ago

You may add scripts as browser bookmarks and assign names like "prefix/tag: action". Then you can use Vomnibar to search them.

mehmetkaradeniz commented 2 years ago

Yes, Bookmarklets sounds like a good idea, but I've heard this would require to convert our scripts to one liner and no spaces etc. Can be hard maintaining our scripts especially if they are long and complex. Maybe adding one of those "Bookmarklet creators" inside the vimium and letting vimium handle this task can work.

Another option may be creating javascript snippets in browser's dev tools and searching them via Vomnibar.

gdh1995 commented 2 years ago

But, Vimium use chrome.storage.sync, which has a size limited of 100KB in total and up to 8KB for every option item (https://developer.chrome.com/docs/extensions/reference/storage/).

It seems no extension APIs can access snippets.

You may use code prettier before you want to edit a bookmarklet and uglify result code before saving it.