-
Notifications
You must be signed in to change notification settings - Fork 22
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
UX Improvements #25
UX Improvements #25
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"manifest_version": 3, | ||
"name": "Kagi Search for Firefox", | ||
"version": "0.3.5", | ||
"version": "0.3.6", | ||
"description": "A simple helper extension for setting Kagi as a default search engine, and automatically logging in to Kagi in incognito browsing windows.", | ||
"background": { | ||
"page": "src/background_page.html" | ||
|
@@ -18,12 +18,12 @@ | |
"default_popup": "src/popup.html" | ||
}, | ||
"permissions": [ | ||
"activeTab", | ||
"cookies", | ||
"declarativeNetRequestWithHostAccess", | ||
"webRequest", | ||
"storage" | ||
], | ||
"optional_permissions": ["activeTab"], | ||
"host_permissions": ["https://kagi.com/*"], | ||
"chrome_settings_overrides": { | ||
"search_provider": { | ||
|
@@ -47,7 +47,8 @@ | |
}, | ||
"browser_specific_settings": { | ||
"gecko": { | ||
"id": "[email protected]" | ||
"id": "[email protected]", | ||
"strict_min_version": "102.0" | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,9 @@ export async function summarizeContent({ | |
}) { | ||
let summary = 'Unknown error'; | ||
let success = false; | ||
const useApi = Boolean(api_token); | ||
const useApi = Boolean( | ||
api_token && ((api_engine && api_engine !== 'cecil') || text), | ||
); | ||
Comment on lines
+16
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now we'll only use the API if there's a an API Key and the engine isn't Cecil. |
||
|
||
try { | ||
const requestParams = { | ||
|
@@ -95,19 +97,41 @@ export async function summarizeContent({ | |
}; | ||
} | ||
|
||
export async function updateSettings(handleGetData) { | ||
export async function fetchSettings() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Made this function more "standard" (not taking a callback, returning the object). |
||
const sessionObject = await browser.storage.local.get('session_token'); | ||
const syncObject = await browser.storage.local.get('sync_existing'); | ||
const apiObject = await browser.storage.local.get('api_token'); | ||
const apiEngineObject = await browser.storage.local.get('api_engine'); | ||
|
||
await handleGetData({ | ||
return { | ||
token: sessionObject?.session_token, | ||
sync_existing: | ||
typeof syncObject?.sync_existing !== 'undefined' | ||
? syncObject.sync_existing | ||
: true, | ||
api_token: apiObject?.api_token, | ||
api_engine: apiEngineObject?.api_engine, | ||
}; | ||
} | ||
|
||
export async function getActiveTab() { | ||
const tabs = await browser.tabs.query({ | ||
active: true, | ||
lastFocusedWindow: true, | ||
}); | ||
|
||
// Chrome/Firefox might give us more than one active tab when something like "chrome://*" or "about:*" is also open | ||
const tab = | ||
tabs.find( | ||
(tab) => | ||
tab?.url?.startsWith('http://') || tab?.url?.startsWith('https://'), | ||
) || tabs[0]; | ||
|
||
if (!tab || !tab.url) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Found this new case, after permissions were granted, before they were requested, where we'd get a |
||
console.error('No tab/url found.'); | ||
console.error(tabs); | ||
return null; | ||
} | ||
|
||
return tab; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was the main thing preventing the extension from being compatible with Firefox. This version (102) is 1 year old, so I don't expect people to have problems not being able to install the extension.