-
-
Notifications
You must be signed in to change notification settings - Fork 44
/
localstorage.js
132 lines (123 loc) · 2.91 KB
/
localstorage.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/*
* File: localstorage.js
* Project: discord-rpc-client
* File Created: Sunday, 12th February 2023 9:36:50 pm
* Author: Tee ([email protected])
* Github: https://github.com/teeteeteeteetee
* Discord: Tee#0001
*
* Last Modified: Saturday, 25th November 2023 2:49:42 pm
* Modified By: Tee ([email protected])
*
* Copyright (c) 2023 Tee, Stainless Love
*/
const csInterface = new CSInterface();
export const rpcConfigurationTemplate = {
enabled: {
enabled: true,
description: "",
name: "Rich Presence Enable",
type: "checkbox",
hidden: false
},
details: {
enabled: true,
description: "",
name: "Details",
type: "checkbox",
hidden: false
},
state: {
enabled: true,
description: "",
name: "State",
type: "checkbox",
hidden: false
},
timestamp: {
enabled: true,
description: "",
name: "Timestamp",
type: "checkbox",
hidden: false
},
largeImageKey: {
enabled: true,
description: "",
name: "Large Icon",
type: "dropdown",
hidden: false
},
largeImageText: {
enabled: true,
description: "",
name: "Large Icon Text",
type: "checkbox",
hidden: false
},
smallImageKey: {
enabled: true,
description: "",
name: "Small Icon",
type: "checkbox",
hidden: false
},
smallImageText: {
enabled: true,
description: "",
name: "Small Icon Text",
type: "checkbox",
hidden: false
},
partySize: {
enabled: true,
description: "",
name: "Party Size",
type: "checkbox",
hidden: true
},
partyMax: {
enabled: true,
description: "",
name: "Party Max",
type: "checkbox",
hidden: true
}
}
export const extensionConfigurationTemplate = {
updateNotification: {
enabled: true,
description: "",
name: "Update Notification",
type: "checkbox",
hidden: false
},
catMode: {
enabled: false,
description: "",
name: "Cat",
type: "checkbox",
hidden: false
},
}
export function setConfiguration(name, configuration){
window.localStorage.setItem(name, JSON.stringify(configuration));
csInterface.dispatchEvent('com.tee.panel.settings')
}
export function getConfiguration(name){
return JSON.parse(window.localStorage.getItem(name))
}
export function getConfigurations(){
const conf = {}
Object.keys(window.localStorage).forEach(key => {
conf[key] = getConfiguration(key)
})
return conf
}
export function compare(obj, prop) {
return JSON.stringify(obj) === JSON.stringify(prop) ? true : false;
};
export function resetConfiguration(){
window.localStorage.clear()
location.reload()
}