Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional Search Engines on ghosterysearch #23

Merged
merged 3 commits into from Nov 3, 2020
Merged
Changes from 1 commit
Commits
File filter
Filter file types
Jump to
Jump to file
Failed to load files.

Always

Just for now

Prev

fixing race conditions

  • Loading branch information
chrmod committed Nov 2, 2020
commit 67808faea5f4a9b471865b3f63b223a2b4bff695
@@ -89,31 +89,36 @@ async function start() {
requestHeaders,
};
}, { urls: [`${SERP_BASE_URL}/search*`]}, ["blocking", "requestHeaders"]);
}

browser.runtime.onMessage.addListener(async ({ action, args }, { tab }) => {
if (action === 'getTokenCount') {
return Promise.resolve(tokenPool.tokens.length);
}

browser.runtime.onMessage.addListener(async ({ action, args }, { tab }) => {
if (action === 'getTokenCount') {
return Promise.resolve(tokenPool.tokens.length);
}
if (action === 'getTopSites') {
return (await browser.topSites.get({
newtab: true,
includeFavicon: true,
})).filter(site => site.type === 'url');
}
if (action === 'getSearchEngines') {
return browser.search.get();
}
if (action === 'search') {
const { query, engine } = args[0];
return browser.search.search({
query,
engine,
tabId: tab.id,
});
}
return false;
})
}
if (action === 'getTopSites') {
return (await browser.topSites.get({
newtab: true,
includeFavicon: true,
})).filter(site => site.type === 'url');
}

if (action === 'getSearchEngines') {
return (await browser.search.get()).filter(
engine => engine.name !== browser.runtime.getManifest()["chrome_settings_overrides"]["search_provider"].name
);
}

if (action === 'search') {
const { query, engine } = args[0];
return browser.search.search({
query,
engine,
tabId: tab.id,
});
}

return false;
});

start();
ProTip! Use n and p to navigate between commits in a pull request.