Great tools in one line.
The goal of this extension is to provide some handy utilities that can be accessed right in the Chrome Omnibox.
Please run
npm start
orwebpack
at fisrt to make dist/ available. Then drag dist/ into Chrome.
namespace Omnibox
Input listener and dispatcher. Also handling new command register.
namespace Notification
Send notifications about results. Provides pre-defined notification types.
namespace Messaging
Handling external command register.
namespace Management
Extensions related stuff, launch, enable/disable.
namespace BrowserBasic
History, bookmark, top sites, tabs, Chrome urls.
namespace Time
Set a reminder.
namespace Misc
Exverything else.
Omnibox.register({
key: string, //The command text
format?: { reg: RegExp, info: string }, //The help text of correct input format, if any
description: string, //An explaination of what this command gonna do
input?: (content: string, suggest: (suggesResults: chrome.omnibox.SuggestResult[]) => void) => void, //This function receive user input and return suggestions
accept: (content?: string) => void, //Once user hit enter, this function handles everything else
extensionId?: string //WIP Identify an external command
})
When providing suggestions, there're three possible situations:
-
input() => void
Whenever
input()
function is provided, Omni Plus will use it to provide suggestions. -
No
input()
but hasformat
Omni Plus will check the user input using
format.reg
, when user got things wrong, it'll suggest"Correct Fomat {format.info}"
. If everyting is ok, Omni Plus will suggest thedescription
. -
No
input()
andformat
Omni Plus will use
description
as the only suggestion.
All registered command will be presented as new providerItem(info)
class providerItem {
public key: string;
public format?: { reg: RegExp, info: string };
public description: string;
public input?: (content: string, suggest: (suggesResults: chrome.omnibox.SuggestResult[]) => void) => void;
public accept: (content?: string) => void;
public extensionId?: string;
//misc properties and utility functions
misc: {
urlReg: RegExp,
encodeXml (str: string): string
}
//search provided data and return formatted suggestions array
search(data: any[], input: string, searchKeys: string[], suggestKeys: string[],
callback: (response: chrome.omnibox.SuggestResult[]) => void, condition?: any[]) => void;
//return suggestions array out of data without searching
form(data: any[], suggestKeys: string[],
callback: (response: chrome.omnibox.SuggestResult[]) => void) => void;
//return input content by removing key text
extract(content: string): string;
//self destroying
_() => void;
}
When writing the input()
and accept()
, there're some handy functions and misc stuff provided. Could be accessed using this.
or let self = this; self.