-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.js
More file actions
49 lines (42 loc) · 1.23 KB
/
utils.js
File metadata and controls
49 lines (42 loc) · 1.23 KB
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
const isChrome = typeof browser == "undefined"
if (isChrome)
chrome.storage.onChanged.addListener(loadYCBsettings)
else
browser.storage.onChanged.addListener(loadYCBsettings)
function loadYCBsettings()
{
return new Promise(resolve =>
{
readSetting("YCBsettings", function(obj)
{
if (!obj.YCBsettings) // If it's running for the first time, store the following default settings.
{
YCBsettings =
{
numberChunkColumns: 1,
fullTitles: true,
sortByTopComments: true,
preferredTranscriptLanguage: ""
}
saveSettings()
}
else
YCBsettings = obj.YCBsettings
resolve()
})
})
}
function saveSettings()
{
if (isChrome)
chrome.storage.local.set({YCBsettings: YCBsettings})
else
browser.storage.local.set({YCBsettings: YCBsettings})
}
function readSetting(settingName, callback)
{
if (isChrome)
chrome.storage.local.get(settingName, callback)
else
browser.storage.local.get(settingName).then(callback)
}