This commit is contained in:
achiyae
2023-08-05 15:57:08 +03:00
parent f0a5f9317f
commit 60b84e8229
6 changed files with 67 additions and 71 deletions

View File

@@ -1,3 +1,5 @@
import {setSetting} from './utils.js'
const settings = [
{ key: 'Complete', shortcut: 'Alt+C', status: 'enabled', type: 'Command' },
{ key: 'Improve', shortcut: 'Alt+I', status: 'enabled', type: 'Command' },
@@ -45,29 +47,6 @@ async function checkCommandShortcuts() {
})
}
/**
* Set a setting in storage {@link https://developer.chrome.com/docs/extensions/reference/storage/#type-StorageArea:~:text=to%20the%20callback.-,set,-void}
* @param key
* @param value
* @param callback
*/
async function setSetting(key, value, callback = null) {
let obj = {}
obj[key] = value
chrome.storage.local.set(obj, callback).catch(error => {
console.log(`Failed to set ${key} setting. Error: ${error}`)
})
}
/**
* Get a setting from storage
* @param {string | string[] | object} [keys=null] - The keys to get (see {@link https://developer.chrome.com/docs/extensions/reference/storage/#usage})
* @param {function} [callback=null] - Callback function
*/
async function getSetting(keys = null, callback = null) {
return chrome.storage.local.get(keys, callback)
}
async function setup() {
addListener('Improve')
addListener('Complete')