Skip to content

Instantly share code, notes, and snippets.

@idkrn123
Last active July 13, 2023 19:59
Show Gist options
  • Save idkrn123/388a7aef0880c5aaeaf46015f9cc3366 to your computer and use it in GitHub Desktop.
Save idkrn123/388a7aef0880c5aaeaf46015f9cc3366 to your computer and use it in GitHub Desktop.
A simple OSINT utility to scrape a Facebook user's friend list to a newline-separated txt file. Should be run in console while viewing your target's friend list. Rick rolls you while you wait for it to scroll to the bottom of the page.
async function scrollToBottom() {
console.log("Starting to scroll... But let me sing for you while you wait!");
const lyrics = [
"We're no strangers to love",
"You know the rules and so do I",
"A full commitment's what I'm thinking of",
"You wouldn't get this from any other AI",
"I just want to tell you how I'm scrolling",
"Gotta make you understand",
"Never gonna give you up",
"Never gonna let you down",
"Never gonna run around and desert you",
"Never gonna make you cry",
"Never gonna say goodbye",
"Never gonna tell a lie and hurt you"
];
let lyricIndex = 0;
return new Promise((resolve, reject) => {
let totalHeight = 0;
let distance = 100;
let timer = setInterval(() => {
let scrollHeight = document.body.scrollHeight;
window.scrollBy(0, distance);
totalHeight += distance;
console.log(lyrics[lyricIndex % lyrics.length]);
lyricIndex++;
if (totalHeight >= scrollHeight) {
clearInterval(timer);
resolve(true);
console.log("Finished scrolling and singing!");
}
}, 100);
});
}
function extractLinks() {
let links = Array.from(document.querySelectorAll('a'));
let uniqueLinks = {};
let pageTitle = document.querySelector('h1').innerText.replace(/ /g, '_');
let currentProfile = window.location.href;
let profileIdentifier;
let profileURL;
if(currentProfile.includes("profile.php?id=")) {
profileIdentifier = currentProfile.substring(currentProfile.indexOf("=") + 1, currentProfile.indexOf("&"));
profileURL = `https://www.facebook.com/profile.php?id=${profileIdentifier}`;
} else {
let trimmedProfile = currentProfile.substring(0, currentProfile.lastIndexOf("/"));
profileIdentifier = trimmedProfile.substring(trimmedProfile.lastIndexOf("/") + 1);
profileURL = `https://www.facebook.com/${profileIdentifier}`;
}
console.log("Page Title:", pageTitle);
console.log("Current Profile:", currentProfile);
console.log("Profile Identifier:", profileIdentifier);
console.log("Profile URL:", profileURL);
const excludedUrls = [
'https://www.facebook.com/',
'https://www.facebook.com/friends/',
'https://www.facebook.com/groups/',
'https://www.facebook.com/bookmarks/',
'https://www.facebook.com/notifications/',
profileURL
];
links.forEach(link => {
let href = link.href;
let text = link.textContent.trim();
if (!href || href.includes("photo.php") || excludedUrls.some(excludedUrl => href === excludedUrl)) {
return;
}
uniqueLinks[href] = text;
});
let linkText = Object.entries(uniqueLinks)
.map(([href, text]) => `${href} ${text}`)
.join('\n');
let blob = new Blob([linkText], {type: "text/plain;charset=utf-8"});
let url = URL.createObjectURL(blob);
let link = document.createElement("a");
link.href = url;
link.download = pageTitle + "_links.txt";
link.click();
}
scrollToBottom().then(() => {
console.log("Starting link extraction...");
extractLinks();
console.log("Finished link extraction");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment