xcv58 / Tab-Manager-v2

Quickly and conveniently manage your open tabs https://tab-manager.vercel.app
https://xcv58.xyz/tabs
MIT License
172 stars 17 forks source link

Integrate with the browser Omnibox #469

Open xcv58 opened 4 years ago

xcv58 commented 4 years ago

When the user enters your extension's keyword, the user starts interacting solely with your extension. Each keystroke is sent to your extension, and you can provide suggestions in response. The suggestions can be richly formatted in a variety of ways. When the user accepts a suggestion, your extension is notified and can take action.

https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/omnibox

There are several use cases like:

  1. Enable quick action like switch to the matched tab, and open the URL (or search the input) if no matched tab
  2. Take quick action like group & sort tabs
  3. Take some actions in the shortcut stores (need to categorize the commands by whether needs the popup window)
xcv58 commented 4 years ago

I'm not sure whether it's possible, but it's very useful:

Move all tabs under the same domain to this window or in a new window.

xcv58 commented 4 years ago

Some sample code:

    browser.omnibox.setDefaultSuggestion({ description: OPEN_TAB_MANGER_WINDOW })
    browser.omnibox.onInputChanged.addListener((text, suggest) => {
      console.log('onInputChanged:', text);
      suggest([
        {
          content: OPEN_TAB_MANGER_WINDOW,
          description: OPEN_TAB_MANGER_WINDOW,
          deletable: false,
        },
      ])
    })
    browser.omnibox.onInputEntered.addListener((text, disposition) => {
      console.log('onInputEntered:', text, disposition);
      openOrTogglePopup()
    })
    browser.omnibox.onInputCancelled.addListener((...args) => {
      console.log('onInputCancelled:', args);
    })