-
Notifications
You must be signed in to change notification settings - Fork 6
/
preferences.js
46 lines (38 loc) · 1.18 KB
/
preferences.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
const Preferences = {
storage_area: 'local',
defaults: {
toolbar_button: 'show_menu',
show_notifications: true,
context_menu_items: true,
show_tags: true,
add_link_form_in_tab: false
},
async get(option) {
let option_value = {}
option_value[option] = this.defaults[option]
const value = await browser.storage[this.storage_area].get(option_value)
return value[option]
},
async set(option, value) {
let option_value = {}
option_value[option] = value
browser.storage[this.storage_area].set(option_value)
},
async migrate_to_local_storage() {
let value
for (option in this.defaults) {
this.storage_area = 'sync'
value = await this.get(option)
browser.storage.sync.remove(option)
this.storage_area = 'local'
this.set(option, value)
}
},
async get_keyboard_shortcuts() {
const shortcuts = await browser.commands.getAll()
return shortcuts.filter(shortcut => shortcut.shortcut)
},
async remove_keyboard_shortcut(name) {
browser.commands.reset(name)
}
};