Print a List of people you are following
/*
* Go to your Following page on ProductHunt.com
* Paste the following script on the console of Chrome's inspector window
*/
function printUsernamesFromFollowingButtons() {
let count = 0;
const processedUsernames = new Set();
function extractAndPrintUsernames() {
var buttons = document.querySelectorAll('button[data-test="follow-button"]');
let newButtonsFound = false;
buttons.forEach(button => {
if (button.innerText === "Following") {
var parent = button.parentElement;
var siblingLinks = parent.parentElement.querySelectorAll('a[href^="/@"]');
siblingLinks.forEach(link => {
var username = link.getAttribute('href').split('/@')[1];
if (username && !processedUsernames.has(username)) {
processedUsernames.add(username);
count += 1;
console.log(`${count} ${username}`); // Print the count and username
newButtonsFound = true;
}
});
}
});
return newButtonsFound;
}
function scrollAndExtract() {
const interval = setInterval(() => {
window.scrollBy(0, 1000); // Scroll down the page
setTimeout(() => {
const newButtonsFound = extractAndPrintUsernames(); // Extract and print usernames
if (!newButtonsFound) { // If no new buttons are found, stop scrolling
clearInterval(interval);
console.log("No more new buttons found.");
return;
}
}, 1000); // Wait for 1 second to load new content
}, 2000); // Scroll every 2 seconds
}
scrollAndExtract();
}
// Call the function to execute
printUsernamesFromFollowingButtons();
These shownotes, created by mjkabir, might be useful to you.