-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathFBFriendExtractor.js
48 lines (39 loc) · 1.18 KB
/
FBFriendExtractor.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
javascript:
function Scrolling() {
const scrollInterval = 50;
const scrollStep = 50;
let scrollPosition = 0;
function scrollToBottom() {
if (scrollPosition < document.body.scrollHeight) {
scrollPosition += scrollStep;
window.scrollTo(0, scrollPosition);
setTimeout(scrollToBottom, scrollInterval);
} else {
extractFB();
}
}
setTimeout(scrollToBottom, 2000);
}
Scrolling();
function extractFB() {
const links = document.getElementsByTagName('a');
const uniqueLinks = new Set();
for (let i = 0; i < links.length; i++) {
const href = links[i].getAttribute('href');
if (href && href.includes('facebook.com') && !href.includes('/photo') && !href.includes(location.href)) {
uniqueLinks.add(href);
}
}
const facebookLinks = Array.from(uniqueLinks);
if (facebookLinks.length > 0) {
const resultWindow = window.open();
resultWindow.document.write(
'<h2>Links containing "facebook.com" found:</h2>' + location.href + ('<ul>') +
facebookLinks.map(link => `<li>${link}</li>`).join('') +
'</ul>'
);
resultWindow.document.close();
} else {
alert('No relevant links found on this page.');
}
}