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

Search engine choice #1

Merged
merged 5 commits into from Oct 15, 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

Show onboarding only once

  • Loading branch information
chrmod committed Oct 15, 2020
commit 9107ff66c4b196ff912ca8d4865ef47d42b5a2c6
@@ -1,12 +1,10 @@
async function onboarding() {
const onboardingTabs = await browser.tabs.query({
url: browser.extension.getURL('pages/choice-screen.html'),
});
const onboardingTabIds = onboardingTabs.map(t => t.id);
await browser.tabs.remove(onboardingTabIds);
await browser.tabs.create({
url: browser.extension.getURL('pages/choice-screen.html'),
});
const { isOnboardingCompleted } = await browser.storage.local.get("isOnboardingCompleted");
if (!isOnboardingCompleted) {
await browser.tabs.create({
url: browser.extension.getURL('pages/choice-screen.html'),
});
}
}

onboarding();
@@ -17,7 +17,7 @@
"manifest_version": 2,
"name": "Ghostery Search",
"permissions": [
"tabs",
"storage",
"cookies",
"webRequest",
"webRequestBlocking",
@@ -3,11 +3,13 @@ document.addEventListener('DOMContentLoaded', () => {
engines.forEach(engine => {
engine.addEventListener('click', async () => {
const name = engine.dataset.name;
try {
await browser.ghostery.setDefaultSearchEngine(name);
} catch(e) {
console.error(e);
}
await browser.ghostery.setDefaultSearchEngine(name);
const currentTab = await browser.tabs.getCurrent();
await browser.storage.local.set({
isOnboardingCompleted: true,
});
await browser.tabs.create({});
browser.tabs.remove(currentTab.id);
});
});
});
ProTip! Use n and p to navigate between commits in a pull request.