Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Jetpack module for querying the datasource that powers the Firefox awesomebar.
const { Ci, Cc, Cu } = require("chrome");
Cu.import("resource://gre/modules/Services.jsm", this);
Cu.import("resource://gre/modules/XPCOMUtils.jsm", this);
function AutoCompleteInput(aSearches) {
this.searches = aSearches;
AutoCompleteInput.prototype = {
timeout: 10,
textValue: "",
searches: null,
searchParam: "",
popupOpen: false,
minResultsForPopup: 0,
invalidate: function() {},
disableAutoComplete: false,
completeDefaultIndex: false,
get popup() { return this; },
onSearchBegin: function() {},
onSearchComplete: function() {},
setSelectedIndex: function() {},
get searchCount() { return this.searches.length; },
getSearchAt: function(aIndex) this.searches[aIndex],
QueryInterface: XPCOMUtils.generateQI([
}; = function search(options) {
let controller = Cc[";1"].
// Make an AutoCompleteInput that uses our searches
// and confirms results on search complete
let input = new AutoCompleteInput(["history"]);
controller.input = input;
input.searchParam =;
input.onSearchBegin = function() {};
input.onSearchComplete = function onSearchComplete() {
let results = [];
for (let i = 0; i < controller.matchCount; i++) {
let result = {
url: controller.getValueAt(i),
title: controller.getCommentAt(i),
//label: controller.getLabelAt(i),
style: controller.getStyleAt(i),
image: controller.getImageAt(i)
if (options.onResult)
if (options.onComplete)

This comment has been minimized.

Show comment Hide comment

vitaly-zdanevich Aug 2, 2015

Can you please explain what is this and how I can use it?

Can you please explain what is this and how I can use it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment