Forked from AhsanAyaz/fb-friend-requests-automation.js
Created
December 16, 2021 08:39
-
-
Save WahabShah23/27259c6a2490f198e13fc024e7c9c477 to your computer and use it in GitHub Desktop.
Automagically accept all friend requests on your profile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @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