-
Notifications
You must be signed in to change notification settings - Fork 1
/
abc.html
295 lines (263 loc) · 9.07 KB
/
abc.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
table,
th,
td {
border: 1px solid black;
border-collapse: collapse;
padding: 5px;
}
#overview {
padding-top: 20px;
}
</style>
<script src="https://cdn.jsdelivr.net/npm/ag-grid-community/dist/ag-grid-community.min.js"></script>
</head>
<body>
<h1>FB AIO</h1>
<p>
<span> Preset:</span>
<button onclick="preset.buy()">Buy (1 month)</button>
<button onclick="preset.review()">Review (1 week)</button>
</p>
<label for="uid">UID</label>: <input id="uid" type="text" /><br />
<label for="name">Name</label>: <input id="name" type="text" /><br />
<label for="date">Date</label>: <input id="date" type="date" /><br />
<label for="password">Password</label>:
<input id="password" type="password" value="" /><br />
<button id="submit">Submit</button>
<button id="allData">All data</button>
<div id="overview"></div>
<div
id="all-data-container"
class="ag-theme-quartz"
style="height: 500px"
></div>
<script>
const inp_uid = document.getElementById("uid");
const inp_username = document.getElementById("name");
const inp_date = document.getElementById("date");
const inp_password = document.getElementById("password");
const submitBtn = document.querySelector("#submit");
const allDataBtn = document.querySelector("#allData");
const allDataContainer = document.querySelector("#all-data-container");
const overviewContainer = document.querySelector("#overview");
inp_date.setAttribute("min", new Date().toISOString().split("T")[0]);
const nextMonth = new Date();
// nextMonth.setMonth(nextMonth.getMonth() + 1);
inp_date.setAttribute("value", nextMonth.toISOString().split("T")[0]);
let gridOptions, agGridInstance;
allDataBtn.addEventListener("click", async () => {
if (!inp_password.value) {
alert("Password is required");
return;
}
const url =
"https://useful-script-statistic.glitch.me/allVIP?password=" +
inp_password.value;
const res = await fetch(url);
const text = await res.text();
console.log(text);
const json = JSON.parse(text);
const data = json.map((_, i) => ({
i,
daysLeft: Math.round(
(new Date(parseInt(_[1])).getTime() - new Date().getTime()) /
1000 /
60 /
60 /
24
),
dateStr: new Date(parseInt(_[1])).toLocaleString(),
date: _[1],
uid: _[0],
name: _[2],
}));
// .sort((a, b) => a.daysLeft - b.daysLeft);
console.log(data);
overviewContainer.innerHTML = `
<span>Total:</span> ${data.length}
<br/>
<span>in VIP:</span> ${data.filter((d) => d.daysLeft > 0).length}
<br/>
<span>Expired:</span> ${data.filter((d) => d.daysLeft <= 0).length}
<br/>
`;
if (!agGridInstance) {
gridOptions = {
enableCellTextSelection: true,
rowData: data,
columnDefs: [
{ field: "i", width: 80 },
{ field: "daysLeft", pinned: "left", width: 80 },
{ field: "dateStr" },
{
field: "uid",
cellRenderer: (params) => {
const a = document.createElement("a");
a.target = "_blank";
a.href = `https://www.facebook.com/${params.data.uid}`;
a.textContent = params.data.uid;
return a;
},
},
{ field: "name", minWidth: 200, flex: 1 },
{
field: "Action",
cellRenderer: CustomButtonComponent,
filter: false,
width: 100,
},
],
defaultColDef: {
sortable: true,
filter: true,
floatingFilter: true,
},
};
agGridInstance = agGrid.createGrid(allDataContainer, gridOptions);
} else {
agGridInstance.setGridOption("rowData", data);
}
});
submitBtn.addEventListener("click", () => {
if (
!inp_uid.value ||
!inp_username.value ||
!inp_date.value ||
!inp_password.value
) {
alert("All fields are required");
return;
}
const today = new Date();
const selectedDate = new Date(inp_date.value);
selectedDate.setHours(
today.getHours(),
today.getMinutes(),
today.getSeconds()
);
window.open(
`https://useful-script-statistic.glitch.me/addVIP?uid=${
inp_uid.value
}&name=${
inp_username.value
}&expireTime=${selectedDate.getTime()}&password=${
inp_password.value
}`,
"_blank"
);
});
document.addEventListener("click", (e) => {
if (e.target.dataset.update) {
const [uid, name, date] = e.target.dataset.update.split(";");
inp_uid.value = uid;
inp_username.value = name;
inp_date.value = date;
}
});
const preset = {
buy() {
inp_uid.value = "";
const n = prompt("How many months?", "1");
inp_username.value = " (" + n + " months)";
// n month later from now
inp_date.value = new Date(
new Date().setMonth(new Date().getMonth() + parseInt(n))
)
.toISOString()
.split("T")[0];
},
review() {
inp_uid.value = "";
inp_username.value = " (review)";
// 7 days later from now
inp_date.value = new Date(
new Date().setDate(new Date().getDate() + 7)
)
.toISOString()
.split("T")[0];
},
};
let hideExpired = false;
function toggleExpired() {
const table = document.querySelector("#all-data-container table");
const rows = Array.from(table.rows).slice(1); // Convert rows to array and skip header row
rows.forEach((row) => {
const daysLeft = parseInt(row.cells[1].innerText);
if (daysLeft <= 0) {
row.style.display = hideExpired ? "table-row" : "none";
}
});
hideExpired = !hideExpired;
}
// https://www.w3schools.com/howto/howto_js_sort_table.asp
function sortTable(n) {
const table = document.querySelector("#all-data-container table");
const rows = Array.from(table.rows).slice(1); // Convert rows to array and skip header row
// Determine sorting direction
let dir =
table.getAttribute("data-sort-dir") === "asc" ? "desc" : "asc";
table.setAttribute("data-sort-dir", dir); // Store the current direction in a data attribute
// Sort rows based on the nth cell content
rows.sort((rowA, rowB) => {
let cellA = rowA.cells[n].innerText || rowA.cells[n].textContent;
let cellB = rowB.cells[n].innerText || rowB.cells[n].textContent;
// Parse as numbers if they are numeric, otherwise compare as strings
const valA = isNaN(cellA) ? cellA : parseFloat(cellA);
const valB = isNaN(cellB) ? cellB : parseFloat(cellB);
// Sort ascending or descending
if (dir === "asc") {
return valA > valB ? 1 : valA < valB ? -1 : 0;
} else {
return valA < valB ? 1 : valA > valB ? -1 : 0;
}
});
// Append sorted rows back into the table
rows.forEach((row) => table.appendChild(row));
}
class CustomButtonComponent {
eGui;
eButton;
eventListener;
init(params) {
this.eGui = document.createElement("div");
this.eButton = document.createElement("button");
this.eButton.textContent = "Update";
this.eventListener = () => {
// copy row data to inputs
console.log(params);
inp_date.value = new Date(parseInt(params.data.date))
.toISOString()
.split("T")[0];
inp_uid.value = params.data.uid;
inp_username.value = params.data.name;
// scroll to top, smooth
window.scrollTo({
top: 0,
behavior: "smooth",
});
};
this.eButton.addEventListener("click", this.eventListener);
this.eGui.appendChild(this.eButton);
}
getGui() {
return this.eGui;
}
refresh(params) {
return true;
}
destroy() {
if (this.eButton) {
this.eButton.removeEventListener("click", this.eventListener);
}
}
}
</script>
</body>
</html>