forked from OsaSoft/youtube-better-subscriptions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon.js
41 lines (33 loc) · 792 Bytes
/
common.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
const PREFIX = "osasoft-better-subscriptions_";
const DEFAULT_SETTINGS = {
"settings.hide.watched.label": true,
"settings.hide.watched.default": true,
"settings.hide.watched.refresh.rate": 3000,
"settings.log.enabled": false
};
const SETTINGS_KEY = "settings";
let brwsr;
try {
brwsr = browser;
} catch (e) {
if (e instanceof ReferenceError) {
brwsr = chrome;
}
}
function getStorage() {
return brwsr.storage.local; //TODO: use sync?
}
function getSyncStorage() {
return brwsr.storage.sync;
}
function setVideoInStorage(videoId) {
let obj = {};
obj[videoId] = Date.now();
getStorage().set(obj);
}
function hide(element) {
element.classList.add("hidden");
}
function show(element) {
element.classList.remove("hidden");
}