Source code
Revision control
Copy as Markdown
Other Tools
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
// List of sites we match against Topsites in order to identify sites
// that should be converted to search Topsites
export const SEARCH_SHORTCUTS = [
{
keyword: "@\u044F\u043D\u0434\u0435\u043A\u0441",
shortURL: "yandex",
},
];
// These can be added via the editor but will not be added organically
export const CUSTOM_SEARCH_SHORTCUTS = [
...SEARCH_SHORTCUTS,
{
keyword: "@duckduckgo",
shortURL: "duckduckgo",
},
{
keyword: "@wikipedia",
shortURL: "wikipedia",
},
];
// Note: you must add the activity stream branch to the beginning of this if using outside activity stream
export const SEARCH_SHORTCUTS_EXPERIMENT =
"improvesearch.topSiteSearchShortcuts";
export const SEARCH_SHORTCUTS_SEARCH_ENGINES_PREF =
"improvesearch.topSiteSearchShortcuts.searchEngines";
export const SEARCH_SHORTCUTS_HAVE_PINNED_PREF =
"improvesearch.topSiteSearchShortcuts.havePinned";
export function getSearchProvider(candidateShortURL) {
return (
SEARCH_SHORTCUTS.filter(match => candidateShortURL === match.shortURL)[0] ||
null
);
}
// Check topsite against predefined list of valid search engines
export async function checkHasSearchEngine(keyword) {
try {
return !!(await Services.search.getAppProvidedEngines()).find(
e => e.aliases.includes(keyword) && !e.hidden
);
} catch {
// When the search service has not successfully initialized,
// there will be no search engines ready.
return false;
}
}