forked from ylh/tiddlymarker
-
Notifications
You must be signed in to change notification settings - Fork 1
/
storage.js
51 lines (46 loc) · 892 Bytes
/
storage.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
47
48
49
50
51
const defaults = {
sync: {
quickmode: false,
careful: false,
reqfav: true,
savingmode: "download",
/*taburi: "",*/
address: "",
auth: false,
username: "",
password: "",
safety: true,
bookmark_fmt:
`let o = {
title: title,
tags: "Bookmark",
fields: {
rawtitle: rawtitle,
link: url
}
};
if (icon !== undefined) {
o.fields.icon = icon.title;
}
return o;`,
favicon_separate: true,
favicon_fmt:
`return {
title: \`\${hash}.\${ext}\`,
tags: "Favicon",
text: data,
type: mime
};`,
justinstalled: true
},
local: {
state: "ready",
error: {}
}
};
const storage_obj = async (a, k) =>
await browser.storage[a].get({[k]: defaults[a][k]});
const local_of = async k => (await storage_obj("local", k))[k];
const pref_of = async k => (await storage_obj("sync", k))[k];
const fake_update = async (a, k) =>
browser.storage[a].set(await storage_obj(a, k));