Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WahabShah23/27259c6a2490f198e13fc024e7c9c477 to your computer and use it in GitHub Desktop.
Save WahabShah23/27259c6a2490f198e13fc024e7c9c477 to your computer and use it in GitHub Desktop.
Automagically accept all friend requests on your profile
/**
* @author Muhammad Ahsan Ayaz
* Usage:
* Go to https://www.facebook.com/friends/requests/
* Run the following code
*/
function acceptRequests (container, mutualThreshold, timerDelay) {
var rows = container.querySelectorAll('[aria-label="Confirm"]:not([aria-disabled="true"])')
rows.forEach((row, index) => {
try {
if (mutualThreshold > 0) {
const friendsCountLabel = row.closest('a').querySelector('[aria-labelledby$="friends"]')
const friendsCount = Number(friendsCountLabel.getAttribute('aria-labelledby').split(' mutual')[0]);
if (friendsCount < mutualThreshold) {
return;
}
}
setTimeout(() => {
row.click();
if (index === rows.length - 1) {
container.scrollTop = container.scrollHeight;
}
}, index * timerDelay)
}
catch (e) {
console.log(e);
}
})
}
function acceptAllFriendRequests (containerClass, mutualThreshold = 0, timerDelay = 500) {
var container = document.querySelectorAll(containerClass);
container = container[container.length - 1]
acceptRequests(container, mutualThreshold, timerDelay);
setInterval(() => {
acceptRequests(container, mutualThreshold, timerDelay);
}, 7000)
}
/**
* Make sure to pass the correct css selector for the container element of the friend requests row
*/
acceptAllFriendRequests('.rpm2j7zs.k7i0oixp.gvuykj2m', 3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment