From eef60af1111ee120edcbb0f9ed934362cf9cd1ef Mon Sep 17 00:00:00 2001 From: Bruno Bernardino Date: Tue, 4 Jun 2024 19:12:39 +0100 Subject: [PATCH] Privacy Consent Screen (#78) * Privacy Consent Screen This introduces a privacy consent screen that needs to be accepted before using the extension, as requested by Mozilla in order to allow it to be publicly available in their Add-ons marketplace. It also releases this as 0.7.0. * Don't show privacy consent popup in chrome * add link to new browser privacy policy * fix privacy policy link * Update popup.html --------- Co-authored-by: Hugh O'Brien --- chrome/manifest.json | 2 +- firefox/manifest.json | 2 +- shared/src/background.js | 17 ++++++++++++++++- shared/src/lib/utils.js | 6 ++++++ shared/src/popup.css | 4 ++-- shared/src/popup.html | 19 ++++++++++++++++++- shared/src/popup.js | 40 +++++++++++++++++++++++++++++++++++++++- 7 files changed, 83 insertions(+), 7 deletions(-) diff --git a/chrome/manifest.json b/chrome/manifest.json index cdd4565..9bb9167 100644 --- a/chrome/manifest.json +++ b/chrome/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 3, "name": "Kagi Search for Chrome", - "version": "0.6.1", + "version": "0.7.0", "description": "A simple extension for setting Kagi as a default search engine, and automatically logging in to Kagi in incognito browsing windows", "background": { "service_worker": "src/background.js", diff --git a/firefox/manifest.json b/firefox/manifest.json index 9ee569b..77b26e7 100644 --- a/firefox/manifest.json +++ b/firefox/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 3, "name": "Kagi Search for Firefox", - "version": "0.6.1", + "version": "0.7.0", "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" diff --git a/shared/src/background.js b/shared/src/background.js index b2ab3d4..17950b9 100644 --- a/shared/src/background.js +++ b/shared/src/background.js @@ -10,6 +10,7 @@ let sessionApiToken = undefined; let sessionApiEngine = undefined; let sessionSummaryType = undefined; let sessionTargetLanguage = undefined; +let sessionPrivacyConsent = false; let IS_CHROME = true; // Very hacky, but currently works flawlessly @@ -18,7 +19,15 @@ if (typeof browser.runtime.getBrowserInfo === 'function') { } async function saveToken( - { token, api_token, api_engine, sync, summary_type, target_language } = {}, + { + token, + api_token, + api_engine, + sync, + summary_type, + target_language, + privacy_consent, + } = {}, isManual = false, ) { sessionToken = typeof token !== 'undefined' ? token : sessionToken; @@ -32,6 +41,10 @@ async function saveToken( typeof target_language !== 'undefined' ? target_language : sessionTargetLanguage; + sessionPrivacyConsent = + typeof privacy_consent !== 'undefined' + ? privacy_consent + : sessionPrivacyConsent; let shouldSync = sync || !isManual; if (typeof sessionToken === 'undefined' || sessionToken.trim().length === 0) { @@ -49,6 +62,7 @@ async function saveToken( api_engine: sessionApiEngine, summary_type: sessionSummaryType, target_language: sessionTargetLanguage, + privacy_consent: sessionPrivacyConsent, }); } catch (error) { console.error(error); @@ -70,6 +84,7 @@ async function saveToken( api_engine: sessionApiEngine, summary_type: sessionSummaryType, target_language: sessionTargetLanguage, + privacy_consent: sessionPrivacyConsent, }); } diff --git a/shared/src/lib/utils.js b/shared/src/lib/utils.js index 7dbee71..574bc1e 100644 --- a/shared/src/lib/utils.js +++ b/shared/src/lib/utils.js @@ -108,6 +108,8 @@ export async function fetchSettings() { const summaryTypeObject = await browser.storage.local.get('summary_type'); const targetLanguageObject = await browser.storage.local.get('target_language'); + const privacyConsentObject = + await browser.storage.local.get('privacy_consent'); return { token: sessionObject?.session_token, @@ -119,6 +121,10 @@ export async function fetchSettings() { api_engine: apiEngineObject?.api_engine, summary_type: summaryTypeObject?.summary_type, target_language: targetLanguageObject?.target_language, + privacy_consent: + typeof privacyConsentObject?.privacy_consent !== 'undefined' + ? privacyConsentObject.privacy_consent + : false, }; } diff --git a/shared/src/popup.css b/shared/src/popup.css index dfcc45c..ac44f85 100644 --- a/shared/src/popup.css +++ b/shared/src/popup.css @@ -344,7 +344,7 @@ p { margin-bottom: 5px; } -#summarize_page, #request_permissions_button, #fastgpt_submit { +#summarize_page, #request_permissions_button, #fastgpt_submit, #privacy_consent_button { background-color: #ffb319; border: 1px solid #ffb319; color: #191919; @@ -369,7 +369,7 @@ p { margin-right: auto; } -#summarize_page:hover, #request_permissions_button:hover, #fastgpt_submit { +#summarize_page:hover, #request_permissions_button:hover, #fastgpt_submit:hover, #privacy_consent_button:hover { background-color: #f7a808; border: 1px solid #d9950d; } diff --git a/shared/src/popup.html b/shared/src/popup.html index aa9de5a..4461959 100644 --- a/shared/src/popup.html +++ b/shared/src/popup.html @@ -83,6 +83,23 @@ + +