-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathFbnames.js
58 lines (57 loc) · 1.24 KB
/
Fbnames.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
javascript:
var y = document.getElementsByClassName('_zs fwb');
var flag = 0;
var p;
p = window.prompt('Enter no of names required ', 10);
function moveWin()
{
window.scroll(0, document.body.scrollHeight);
y = document.getElementsByClassName('_zs fwb');
if (y.length > p)
{
clearTimeout(stopScroll);
flag = 1;
}
else
var stopScroll = setTimeout('moveWin();', 1000);
if (flag == 1)
{
y = document.getElementsByClassName('_zs fwb');
var final = [
[' USERNAME ',
' ID ']
];
var names = [
];
var ids = [
];
var csvRows = [
];
for (var i = 0; i < p; i++)
{
var name = y[i].textContent;
names.push(name);
var url = y[i].getElementsByTagName('a') [0].href;
var id = url.slice(25, url.indexOf('?'));
ids.push(id);
final.push([name,
id]);
}
for (var i = 0 ; i < final.length ; ++i)
{
csvRows.push(final[i].join(','));
}
var csvString = csvRows.join('%0A');
var a = document.createElement('a');
a.href = 'data:attachment/csv,' + csvString;
a.target = '_blank';
a.download = 'FBnames.csv';
if (csvRows.length > 1)
{
document.body.appendChild(a);
a.click();
}
}
}
moveWin();
void (0);