More updates for FF consent screen

This commit is contained in:
Jackson Harper 2023-11-17 12:18:30 +08:00
parent 8c04763376
commit f22bdaa1a2
13 changed files with 109 additions and 15 deletions

View file

@ -11,7 +11,7 @@
"url": "https://omnivore.app/"
},
"homepage_url": "https://omnivore.app/",
"content_security_policy": "default-src 'none'; child-src 'none'; manifest-src 'none'; media-src 'none'; object-src 'none'; worker-src 'none'; connect-src https://storage.googleapis.com/ https://api-prod.omnivore.app/api/ blob:; frame-src 'none'; font-src 'none'; img-src data:; script-src 'self'; script-src-elem 'self'; script-src-attr 'none'; style-src 'self'; style-src-elem 'self'; style-src-attr 'none'; base-uri 'none'; form-action 'none'; block-all-mixed-content; upgrade-insecure-requests; report-uri https://api.jeurissen.co/reports/csp/webext/omnivore/",
"content_security_policy": "default-src 'none'; child-src 'none'; manifest-src 'none'; media-src 'none'; object-src 'none'; worker-src 'none'; connect-src https://storage.googleapis.com/ https://api-prod.omnivore.app/api/ blob:; frame-src 'none'; font-src 'none'; img-src data:; script-src 'self'; script-src-elem 'self' 'unsafe-inline'; script-src-attr 'unsafe-inline'; style-src 'self' 'unsafe-inline'; style-src-elem 'self' 'unsafe-inline'; style-src-attr 'none'; base-uri 'none'; form-action 'none'; block-all-mixed-content; upgrade-insecure-requests; report-uri https://api.jeurissen.co/reports/csp/webext/omnivore/",
"icons": {
"16": "/images/extension/icon-16.png",
"24": "/images/extension/icon-24.png",

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -7,6 +7,7 @@
<meta name="viewport" content="width=device-width,initial-scale=1">
<style>
html,
body {
@ -28,7 +29,7 @@ body {
background: linear-gradient(150deg, #fff 55%, #ffde8c 55%);
background-color: #fff;
color: #3d3d3d;
font-family: sans-serif;
font-family: Inter, sans-serif;
text-align: center;
}

View file

@ -1,3 +1,3 @@
OMNIVORE_URL="https://demo.omnivore.app"
OMNIVORE_GRAPHQL_URL="https://api-demo.omnivore.app/api/"
EXTENSION_NAME="Omnivore *DEMO*"
EXTENSION_NAME="Omnivore *DEMO*"

View file

@ -7,12 +7,14 @@ build: *
rm -rf dist
yarn build-prod
firefox: build
firefox:
echo "building firefox package"
rm -rf dist
yarn build-firefox
FIREFOX_PKG_NAME="firefox-$(shell cat dist/manifest.json| jq -j .version).zip" ; \
FIREFOX_SRC_NAME="firefox-$(shell cat dist/manifest.json| jq -j .version)-src.zip" ; \
pushd dist; zip -r ../$$FIREFOX_PKG_NAME *; popd; \
zip -r $$FIREFOX_SRC_NAME src/* yarn.lock package.json .env.production webpack.js replace-with-process-env.js; \
zip -r $$FIREFOX_SRC_NAME src/* Makefile yarn.lock package.json .env.firefox webpack.js replace-with-process-env.js; \
echo "done"
chrome: build

View file

@ -8,6 +8,7 @@
"build": "env EXT_ENV=local webpack --config webpack.js",
"build-qa": "env EXT_ENV=qa webpack --config webpack.js",
"build-demo": "env EXT_ENV=demo webpack --config webpack.js",
"build-firefox": "env EXT_ENV=firefox webpack --config webpack.js",
"build-prod": "env EXT_ENV=production webpack --config webpack.js",
"pack": "web-ext build --overwrite-dest --source-dir dist --artifacts-dir dist_packed --filename omnivore-v{version}.zip",
"pack-stores": "webext-store-incompat-fixer -i dist_packed/omnivore-v{version}.zip"
@ -27,4 +28,4 @@
"nanoid": "^4.0.2",
"uuid": "^8.3.2"
}
}
}

View file

@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "process.env.EXTENSION_NAME",
"short_name": "process.env.EXTENSION_NAME",
"version": "2.8.2",
"version": "2.8.6",
"description": "Save PDFs and Articles to your Omnivore library",
"author": "Omnivore Media, Inc",
"default_locale": "en",

View file

@ -642,17 +642,47 @@ function checkAuthOnFirstClickPostInstall(tabId) {
return Promise.resolve(true)
}
function getConsentGranted() {
if (!process.env.CONSENT_REQUIRED) {
return new Promise((resolve) => {
resolve(true)
})
} else {
return getStorageItem('consentGranted').then((consentGrantedStr) => {
return consentGrantedStr == 'true'
})
}
}
function handleActionClick() {
getStorageItem('consentGranted')
console.log('process.env.CONSENT_REQUIRED', process.env.CONSENT_REQUIRED)
getConsentGranted()
.then((consentGranted) => {
console.log('consentGranted: ', consentGranted)
executeAction(function (currentTab) {
extensionSaveCurrentPage(currentTab.id)
})
if (consentGranted) {
executeAction(function (currentTab) {
extensionSaveCurrentPage(currentTab.id)
})
} else {
getCurrentTab().then((currentTab) => {
browserApi.tabs.sendMessage(currentTab.id, {
action: ACTIONS.ShowConsentError,
})
})
}
})
.catch(() => {
console.log('extension consent not granted')
getCurrentTab().then((currentTab) => {
browserApi.tabs.sendMessage(currentTab.id, {
action: ACTIONS.ShowConsentError,
})
})
})
// } else {
// executeAction(function (currentTab) {
// extensionSaveCurrentPage(currentTab.id)
// })
// }
}
function executeAction(action) {
@ -815,11 +845,19 @@ function init() {
console.log('onInstalled: ', reason, temporary)
switch (reason) {
case 'update':
getConsentGranted().then((consentGranted) => {
if (!consentGranted) {
const url = browser.runtime.getURL('views/installed.html')
return browser.tabs.create({ url })
} else {
console.log('consent already granted, not showing installer.')
}
})
break
case 'install':
{
const url = browser.runtime.getURL('views/installed.html')
await browser.tabs.create({ url })
// or: await browser.windows.create({ url, type: "popup", height: 600, width: 600, });
}
break
// see below

View file

@ -1,6 +1,7 @@
/* global
browserApi
showToolbar
showConsentError
prepareContent
getPageInfo
ACTIONS
@ -41,6 +42,8 @@
sendResponse({ pong: true })
} else if (action === ACTIONS.ShowToolbar) {
showToolbar(payload)
} else if (action === ACTIONS.ShowConsentError) {
showConsentError()
} else if (action === ACTIONS.UpdateStatus) {
updateStatus(payload)
} else if (action === ACTIONS.LabelCacheUpdated) {

View file

@ -189,6 +189,12 @@
)
}
function showConsentError() {
alert(
'You have not granted the Omnivore extension consent to save pages. Check the extension options page to grant consent.'
)
}
function updateLabelsFromCache(payload) {
;(async () => {
await getStorageItem('labels').then((cachedLabels) => {
@ -995,5 +1001,6 @@
window.showToolbar = showToolbar
window.updateStatus = updateStatus
window.showConsentError = showConsentError
window.updateLabelsFromCache = updateLabelsFromCache
})()

View file

@ -64,6 +64,23 @@ function saveAutoDismissTime() {
})
}
function handleConsent() {
var consentCheckbox = document.getElementById('consent-checkbox')
setStorage({
consentGranted: JSON.stringify(consentCheckbox.checked),
})
.then(() => {
console.log('consent granted')
})
.catch((err) => {
alert('Error setting consent: ' + err)
})
if (!consentCheckbox.checked) {
alert('This extension can not function without data collection consent.')
}
}
;(() => {
document
.getElementById('save-api-key-btn')
@ -81,6 +98,11 @@ function saveAutoDismissTime() {
: false
})
getStorageItem('consentGranted').then((value) => {
document.getElementById('consent-checkbox').checked =
value == 'true' ? true : false
})
document
.getElementById('disable-auto-dismiss')
.addEventListener('change', autoDismissChanged)

View file

@ -46,6 +46,26 @@
<button id="auto-dismiss-time-btn">Save</button>
</p>
<p>&nbsp;</p>
<h1>Privacy</h1>
<p class="consent-text">To function Omnivore needs to collect some data. This data is used to authenticate you with our servers, and save pages to your library.</p>
<p class="consent-text">Omnivore uses the following data:</p>
<ul>
<li><b>Tab Data</b>: When you invoke the extension, we access the content of the page you are currently viewing. This allows us to save the full content of the page, exactly how you are viewing it. That data is then transmitted to our servers and added to your library</li>
<li><b>Authentication cookie</b>: When you invoke the extension we access the auth cookie you used to authenticate at <a href="https://omnivore.app">https://omnivore.app</a>. This cookie identifies you as an Omnivore user and ties the saving operation to your Omnivore account.</li>
</ul>
<p class="consent-text">For full details about the data we collect you can read our <a href="https://docs.omnivore.app/about/privacy-statement.html">privacy statement</a></p>
<label for="consent-checkbox">
<input type="checkbox" id="consent-checkbox"> I consent to data collection
</label>
<button id="consent-button" onclick="handleConsent()">Save</button>
<p>&nbsp;</p>
</div>
<script src="/scripts/options.js"></script>
</body>