Created
July 14, 2011 18:56
-
-
Save abhinavsharma/1083149 to your computer and use it in GitHub Desktop.
automatically add search engine with jetpack
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tabs.on('ready', function(tab) { | |
reportError("tab activated"); | |
let gBrowser = Svc.Services.wm.getMostRecentWindow("navigator:browser").gBrowser; | |
let doc = gBrowser.contentDocument; | |
let browser = gBrowser.getBrowserForDocument(doc); | |
if (browser.engines) { | |
reportError(Object.keys(browser.engines[0])); | |
browser.engines.forEach(function({uri, title, icon}) { | |
let type = (/xml$/).test(uri) ? Ci.nsISearchEngine.DATA_XML : Ci.nsISearchEngine.DATA_TEXT; | |
let e = Svc.Services.search.currentEngine; | |
try { | |
Svc.Services.search.addEngine(uri,type,icon,false); | |
} catch (ex) { | |
reportError(J(ex)); | |
} | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment