-
Notifications
You must be signed in to change notification settings - Fork 0
/
getUserId3rd.js
99 lines (90 loc) · 2.44 KB
/
getUserId3rd.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
function getCsrfToken() {
return document.cookie
.split("; ")
.find((row) => row.startsWith("csrftoken"))
.split("=")[1];
}
function fetchUserId(username) {
return new Promise((resolve, reject) => {
const xhr = new XMLHttpRequest();
xhr.open("POST", "https://ilo.so/twitter-id/get/", true);
xhr.setRequestHeader(
"User-Agent",
"Mozilla/5.0 (Windows NT 10.0; rv:128.0) Gecko/20100101 Firefox/128.0",
);
xhr.setRequestHeader("Accept", "*/*");
xhr.setRequestHeader("Accept-Language", "en-US,en;q=0.5");
xhr.setRequestHeader("X-CSRFToken", getCsrfToken());
xhr.setRequestHeader("Content-Type", "text/plain;charset=UTF-8");
xhr.withCredentials = true;
xhr.onload = function () {
if (xhr.status >= 200 && xhr.status < 300) {
const data = JSON.parse(xhr.responseText);
resolve(data.user_id);
} else {
reject(new Error(`HTTP error! status: ${xhr.status}`));
}
};
xhr.onerror = function () {
reject(new Error("Network error"));
};
xhr.send(JSON.stringify({ username }));
});
}
async function fetchUserIds(usernames) {
const userIds = [];
for (const username of usernames) {
try {
const userId = await fetchUserId(username);
userIds.push({ username, userId });
console.log(`Fetched ID for ${username}: ${userId}`);
} catch (error) {
console.error(`Error fetching ID for ${username}:`, error);
userIds.push({ username, userId: null });
}
}
return userIds;
}
function main() {
const usernames = [
"Take_Care5",
"tawrth",
"0uuua",
"tthwir",
"Lata7zan_",
"Shawkiat",
"History_qq",
"KfC_kn",
"Ie_ei3",
"1abyat_sh3r",
"q9eda_",
"Differenttt5",
"ArabPysch",
"Ghrebaa",
"worldfoanimal",
"_suffering83",
"l481_",
"hhil99",
"1simple_0",
"Ouuua_",
"sweet__D26",
"1b1nl",
"Thread_ll",
"_iienglish",
"7akle",
"l123lI",
"i1li9",
]; // Replace with your list of usernames
console.log("Starting to fetch user IDs...");
fetchUserIds(usernames)
.then((results) => {
console.log("All results:", results);
// Extract just the user IDs into a separate array
const userIdsOnly = results
.map((result) => result.userId)
.filter((id) => id !== null);
console.log("All user IDs:", userIdsOnly);
})
.catch((error) => console.error("Error in main execution:", error));
}
main();