-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexport.html
More file actions
296 lines (259 loc) · 8.97 KB
/
Copy pathexport.html
File metadata and controls
296 lines (259 loc) · 8.97 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
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
<html>
<head>
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/toastify-js/src/toastify.min.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>export black</title>
<style>
body {
background-color: black;
color: white;
font-family: Arial, Helvetica, sans-serif, sans-serif;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
h3 {
color: wheat;
margin-bottom: 20px;
}
button {
width: 50%;
padding: 15px;
margin: 10px 0;
border: 1.5px solid grey;
border-radius: 8px;
background-color:black;
color: #fff;
transition: background 0.3s, color 0.3s;
}
input:focus, button:hover {
background-color: #444;
color: #ff5722;
outline: none;
}
button {
background-color:wheat;
color: black;
}
button:active {
background-color: wheat;
}
input[type="file"] {
padding: 8px;
}
#pop {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: black;
color: white;
padding: 20px;
border-radius: 10px;
text-align: center;
display: none;
z-index: 9999;
width: 300px;
}
#pop img {
width: 100%;
height: auto;
border-radius: 5px;
}
#bar {
width: 100%;
height: 5px;
background: lightgray;
margin-top: 10px;
position: relative;
}
#fill {
width: 0%;
height: 100%;
background: green;
transition: width 2s linear;
}
</style>
</head>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.1.1/crypto-js.min.js"></script>
<body>
<h1 id="nkn1">Export u r Data</h1>
<button id="nkn2" onclick="showy()">Download Data</button>
<div id="pop" style="display:none;">
<p id="txt">Reading Black Road...</p>
<img id="img" src="https://raw.githubusercontent.com/microintel/endgram/main/photo/venom-load.gif" alt="Loading">
<div id="bar"><div id="fill"></div></div>
</div>
<script src="https://cdn.jsdelivr.net/npm/toastify-js"></script>
<script>
function showy(){
Swal.fire({
title: 'What To Download',
showCancelButton: true,
icon:"question",
showCloseButton:true,
confirmButtonText: 'BlackRoad',
cancelButtonText: 'Current Time'
}).then((result) => {
if (result.isConfirmed) {
show();
} else if (result.dismiss === Swal.DismissReason.cancel) {
dat();
}
});
}
function dat() {
const now = new Date();
const day = now.getDate().toString().padStart(2, '0');
const month = (now.getMonth() + 1).toString().padStart(2, '0');
const year = now.getFullYear();
const hours = now.getHours().toString().padStart(2, '0');
const minutes = now.getMinutes().toString().padStart(2, '0');
const seconds = now.getSeconds().toString().padStart(2, '0');
const content = `${day}/${month}/${year} ${hours}:${minutes}:${seconds}`;
const blob = new Blob([content], { type: 'text/plain' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'lastseen.txt';
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
}
function gDB(db, store, keys) {
return new Promise((res, rej) => {
const r = indexedDB.open(db);
const data = {};
r.onsuccess = (e) => {
const db = e.target.result;
const tx = db.transaction(store, 'readonly');
const os = tx.objectStore(store);
keys.forEach(key => {
const gr = os.get(key.trim());
gr.onsuccess = (ev) => {
if (ev.target.result) {
data[key.trim()] = ev.target.result;
}
};
gr.onerror = () => rej("mlm");
});
tx.oncomplete = () => res(data);
};
r.onerror = () => rej('Error opening database');
});
}
function dJSON(data, name) {
let why= JSON.stringify(data,null,2);
let whi= pccon(why,"e");
const b = new Blob([whi], { type: "text/plain" });
const l = document.createElement('a');
l.href = URL.createObjectURL(b);
l.download = "Blackroad.txt";
l.click();
}
function exportData() {
const db = "black";
const store = "sst";
const keys = "blackroadINC,frotuXMMXG,nkncc,user,alast,alastrem,blackroadNote,accounting".split(',');
if (!db || !store || keys.length === 0) {
alert('Please fill in all fields with valid data.');
return;
}
gDB(db, store, keys)
.then(data => Object.keys(data).length ? dJSON(data, 'data') : alert('No data'))
.catch(e => alert(e));
}
function show() {
document.getElementById("nkn1").style.display="none";
document.getElementById("nkn2").style.display="none";
let msgs = [
"Reading data from Database...",
"Creating File...",
"Initiating download [ chakli ]..."
];
let pop = document.getElementById("pop");
let txt = document.getElementById("txt");
let fill = document.getElementById("fill");
let idx = 0;
let dur = Math.floor(Math.random() * (18000 - 10000 + 1)) + 10000;
let intv = dur / msgs.length;
intv=1000;
pop.style.display = "block";
let int = setInterval(() => {
idx++;
if (idx < msgs.length) txt.innerText = msgs[idx];
fill.style.width = `${(idx + 1) * (100 / msgs.length)}%`;
if (idx >= msgs.length - 1) {
clearInterval(int);
setTimeout(() => {
pop.style.display = "none";
exportData();
Toastify({
text: "BlackRoad Data File Downloaded Successfully",
duration: 3000,
newWindow: true,
close: false,
gravity: "top",
position: "center",
stopOnFocus: true,
style: {
background: "green",
},
}).showToast();
document.getElementById("nkn1").style.display="block";
document.getElementById("nkn2").style.display="block";
}, intv);
}
}, intv);
}
function rdbname(db, st, k) {
return new Promise((res, rej) => {
const req = indexedDB.open(db);
req.onerror = () => rej('DB open error');
req.onsuccess = () => {
const d = req.result;
const tx = d.transaction([st], 'readonly');
const s = tx.objectStore(st);
const g = s.get(k);
g.onerror = () => rej('Get error');
g.onsuccess = () => res(g.result);
};
});
}
let delus="";
rdbname('black', 'sst', 'user')
.then((val)=> {
delus=val["p"];
});
function pccon(t, y) {
const key = delus;
const chunkSize = 1000;
let result = '';
if (y === 'e') {
for (let i = 0; i < t.length; i += chunkSize) {
const chunk = t.slice(i, i + chunkSize);
const encrypted = CryptoJS.AES.encrypt(chunk, key).toString();
result += encrypted + '|';
}
return result.slice(0, -1);
} else if (y === 'd') {
const chunks = t.split('|');
for (let i = 0; i < chunks.length; i++) {
const bytes = CryptoJS.AES.decrypt(chunks[i].trim(), key);
const decrypted = bytes.toString(CryptoJS.enc.Utf8);
if (!decrypted && decrypted !== '') throw new Error("Invalid chunk or wrong key");
result += decrypted;
}
return result;
} else {
throw new Error("x");
}
}
</script>
</body>
</html>