-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathscript.js
199 lines (174 loc) · 8.13 KB
/
script.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
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
let newsletterLink = null;
document.getElementById('email').addEventListener('keypress', async function (event) {
if (event.key === 'Enter') {
const email = this.value;
const url = `http://localhost:8080/?email=${encodeURIComponent(email)}`;
// Clear table content
document.getElementById('result').innerHTML = '';
document.getElementById('image-container').innerHTML = '';
// Show loading element
document.getElementById('loading').classList.remove('hidden');
// Hide table header
document.getElementById('result-table').querySelector('thead').innerHTML = '';
// Remove newsletter link if it exists
if (newsletterLink) {
newsletterLink.remove();
newsletterLink = null;
}
try {
const response = await fetch(url);
const result = await response.json();
displayResults(result);
} catch (error) {
console.error('Error fetching data:', error);
document.getElementById('result').textContent = 'Error: Unable to fetch data.';
} finally {
// Hide loading element
document.getElementById('loading').classList.add('hidden');
}
}
});
function displayResults(data) {
const resultTable = document.getElementById('result');
resultTable.innerHTML = '';
let nameRowCreated = false;
// Create and insert the Name row at the top of the table
const nameRow = document.createElement('tr');
const namePlatformCell = document.createElement('td');
namePlatformCell.textContent = 'Name';
nameRow.appendChild(namePlatformCell);
const nameResultCell = document.createElement('td');
nameRow.appendChild(nameResultCell);
resultTable.insertBefore(nameRow, resultTable.firstChild);
for (const category in data) {
if (category === 'profiles') {
for (const platform in data[category]) {
const row = document.createElement('tr');
const platformCell = document.createElement('td');
platformCell.textContent = platform;
row.appendChild(platformCell);
const resultCell = document.createElement('td');
const iconWrapper = document.createElement('div');
const icon = document.createElement('img');
icon.width = 16;
icon.height = 16;
if (data[category][platform] === 'true') {
icon.src = './img/true.png';
iconWrapper.setAttribute('data-tooltip', 'Profile found');
} else if (data[category][platform] === 'unknown') {
icon.src = './img/unknown.png';
iconWrapper.setAttribute('data-tooltip', 'Profile status unknown');
} else {
icon.src = './img/false.png';
iconWrapper.setAttribute('data-tooltip', 'Profile not found');
}
iconWrapper.appendChild(icon);
resultCell.appendChild(iconWrapper);
row.appendChild(resultCell);
resultTable.appendChild(row);
}
} else {
if (category !== 'Image' && category !== 'Duolingo Name' && category !== 'GitHub Name') {
const row = document.createElement('tr');
const platformCell = document.createElement('td');
platformCell.textContent = category;
row.appendChild(platformCell);
const resultCell = document.createElement('td');
const iconWrapper = document.createElement('div');
const icon = document.createElement('img');
icon.width = 16;
icon.height = 16;
if (category === 'Location') {
if (data[category] === 'N/A') {
icon.src = './img/false.png';
iconWrapper.setAttribute('data-tooltip', 'No location found');
iconWrapper.appendChild(icon);
resultCell.appendChild(iconWrapper);
} else {
resultCell.textContent = data[category];
}
} else {
if (data[category] === 'true') {
icon.src = './img/true.png';
if (category === 'Deliverable') {
iconWrapper.setAttribute('data-tooltip', 'Email is deliverable');
} else if (category === 'Disposable') {
iconWrapper.setAttribute('data-tooltip', 'Email is disposable');
} else if (category === 'Spam') {
iconWrapper.setAttribute('data-tooltip', 'Email is spam');
}
} else {
icon.src = './img/false.png';
if (category === 'Deliverable') {
iconWrapper.setAttribute('data-tooltip', 'Email is not deliverable');
} else if (category === 'Disposable') {
iconWrapper.setAttribute('data-tooltip', 'Email is not disposable');
} else if (category === 'Spam') {
iconWrapper.setAttribute('data-tooltip', 'Email is not spam');
}
}
iconWrapper.appendChild(icon);
resultCell.appendChild(iconWrapper);
}
row.appendChild(resultCell);
resultTable.appendChild(row);
}
}
}
let names = [];
if (data['Duolingo Name'] !== 'N/A') {
names.push(data['Duolingo Name']);
}
if (data['GitHub Name'] !== 'N/A') {
names.push(data['GitHub Name']);
}
if (names.length > 0) {
nameResultCell.textContent = names.join(', ');
} else {
const iconWrapper = document.createElement('div');
const icon = document.createElement('img');
icon.width = 16;
icon.height = 16;
icon.src = './img/false.png';
iconWrapper.setAttribute('data-tooltip', 'No information found');
iconWrapper.appendChild(icon);
nameResultCell.appendChild(iconWrapper);
}
document.getElementById('result-table').querySelector('thead').classList.remove('hidden');
if (!newsletterLink) {
const tableContainer = document.getElementById('result-table');
newsletterLink = document.createElement('p');
newsletterLink.innerHTML = '<a href="https://osintnewsletter.com" target="_blank">Subscribe to The OSINT Newsletter</a>';
newsletterLink.id = 'newsletter-link';
tableContainer.parentNode.insertBefore(newsletterLink, tableContainer.nextSibling);
}
if (data.Image && data.Image !== 'false') {
const imageContainer = document.getElementById('image-container');
imageContainer.innerHTML = '';
if (data.Image) {
for (const platform in data.Image) {
// Add a check to ensure the image URL is not 'false' for Gravatar
if (data.Image[platform] !== 'false' && data.Image[platform] !== null) {
let imageUrl = data.Image[platform];
if (platform === 'Duolingo') {
imageUrl = 'https:' + imageUrl + '/xlarge';
} else if (platform === 'Gravatar') {
imageUrl = imageUrl + '?s=400';
}
// Only display the image if the URL is not 'N/A'
if (imageUrl !== 'N/A') {
const img = document.createElement('img');
img.src = imageUrl;
img.alt = `${platform} profile image`;
img.width = 175;
img.height = 175;
imageContainer.appendChild(img);
}
}
}
}
} else {
// Clear image container if no image is found
document.getElementById('image-container').innerHTML = '';
}
}