focalboard/experiments/webext/src/utils/settings.ts
Johannes Marbach 11c667b9bf
[GH-438] Add basic web cliper browser extension (#1582)
This adds a rudimentary web clipper browser extension. It allows to save
page titles and URLs into cards. URLs will be written into the first
found card property of type 'url' (if any).

Relates to: #438
2021-11-08 16:07:08 -08:00

29 lines
No EOL
871 B
TypeScript

// Copyright (c) 2021-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import browser from 'webextension-polyfill'
interface Settings {
host: string | null
username: string | null
token: string | null
boardId: string | null
}
export function loadSettings(): Settings {
return browser.storage.sync.get(['host', 'username', 'token', 'boardId'])
}
export function storeSettings(host: string, username: string, token: string | null, boardId: string | null) {
console.log(`storing host ${host}`)
return browser.storage.sync.set({ host: host, username: username, token: token, boardId: boardId })
}
export function storeToken(value: string | null) {
return browser.storage.sync.set({ token: value })
}
export function storeBoardId(value: string | null) {
return browser.storage.sync.set({ boardId: value })
}