-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreset.html
More file actions
185 lines (139 loc) · 4.6 KB
/
Copy pathreset.html
File metadata and controls
185 lines (139 loc) · 4.6 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
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title> factory reset</title>
<style>
body {
font-family: Arial, sans-serif;
text-align: center;
margin: 50px;
}
button {
padding: 10px 20px;
font-size: 16px;
cursor: pointer;
}
#msg {
margin-top: 20px;
color: green;
}
table{
border: 2px double grey;
border-collapse: collapse;
}
thead,tbody{
border: 2px double grey;
border-collapse: collapse;
}
</style>
</head>
<body>
<h1>Factory Reset </h1>
<h3>Permanently Delete Every Think including BlackRoad,Frotu,Lend...</h3>
<button onclick="delDB()"> factory reset</button>
<p id="msg"></p>
<h3> U R Database Map</h3>
<h4 id="used"></h4>
<table border="2">
<thead>
<tr> <th> column </th> <th> data</th></tr>
</thead>
<tbody id="tbbb">
</tbody>
</table>
<script>
let tb=document.getElementById("tbbb");
function disdb() {
let req = indexedDB.open("black");
req.onsuccess = function () {
let db = req.result;
let tx = db.transaction("sst", "readonly");
let store = tx.objectStore("sst");
let keysReq = store.getAllKeys();
keysReq.onsuccess = function () {
let keys = keysReq.result;
keys.forEach((key) => {
let valReq = store.get(key);
valReq.onsuccess = function () {
let cxd=`
<td>${key}</td><td>${JSON.stringify(valReq.result)}</td>
`;
let rt= document.createElement("tr");
rt.innerHTML=cxd;
tb.appendChild(rt);
};
});
};
};
chkSize();
}
disdb();
function delDB() {
const password = prompt("Enter Password to delete everything:");
if (!password) {
alert("Password is required.");
return;
}
const request = indexedDB.open("black",2);
request.onerror = function (event) {
console.error("Database error:", event.target.error);
alert("Failed to open the database.");
};
request.onsuccess = function () {
const db = request.result;
const transaction = db.transaction("sst", "readonly");
const store = transaction.objectStore("sst");
const getRequest = store.get("user");
getRequest.onerror = function (event) {
console.error("Error retrieving data:", event.target.error);
alert("Error retrieving user data.");
};
getRequest.onsuccess = function () {
const userData = getRequest.result;
if (userData && userData["p"] === password) {
const deleteRequest = indexedDB.deleteDatabase("black");
alert("Factory Reset Successful!");
localStorage.removeItem("blackuser");
localStorage.removeItem("blogpin");
location.href = "login.html";
deleteRequest.onsuccess = function () {
};
deleteRequest.onerror = function () {
alert("Failed to delete the database.");
};
} else {
alert("Incorrect password or user not found.");
}
};
};
}
function chkSize() {
const dbN = "black";
const stN = "sst";
if (!dbN || !stN) {
alert("Enter both database and store names.");
return;
}
const req = indexedDB.open(dbN);
req.onsuccess = (e) => {
const db = e.target.result;
if (!db.objectStoreNames.contains(stN)) {
//alert(Store "${stN}" not found in "${dbN}".);
db.close();
return;
}
const txn = db.transaction(stN, "readonly");
const store = txn.objectStore(stN);
const getAll = store.getAll();
getAll.onsuccess = () => {
const size = new Blob([JSON.stringify(getAll.result)]).size;
const usedMB = (size / (1024 * 1024)).toFixed(5);
document.getElementById("used").innerHTML = `used soace ${usedMB} MB`;
db.close();
};
};
req.onerror = () => alert("Failed to open DB.");
}
</script>
</body>
</html>