Last active
January 12, 2025 07:04
-
-
Save thealphadollar/23490d05d1b0c695ea15c5cf23732aca to your computer and use it in GitHub Desktop.
Script To Accept All Facebook Friend Requests
This file contains 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
// If the script does not work, you may need to allow same site scripting https://stackoverflow.com/a/50902950 | |
Facebook = { | |
config: { | |
actionDelay: 1000, | |
scrollDelay: 5000, | |
// set to -1 for no limit | |
maxRequestsToAccept: -1, | |
totalRequestsAccepted: 0, | |
// set string to be present in names to be accepted, leave empty to accept all | |
mustIncludeInName: [], | |
}, | |
inspect: function (data, config) { | |
console.info("INFO: script initialized on the page data..."); | |
console.debug("DEBUG: finding confirm buttons..."); | |
var confirmDivEles = document.querySelectorAll('[aria-label="Confirm"]'); | |
data = []; | |
for (var i = 0; i < confirmDivEles.length; i++) { | |
if (confirmDivEles[i].getAttribute("aria-disabled") == null && confirmDivEles[i].innerText.includes("Confirm")) { | |
data.push(confirmDivEles[i]); | |
} | |
} | |
var totalRows = data.length; | |
console.debug("DEBUG: total confirm buttons found on page are " + totalRows); | |
if (totalRows > 0) { | |
this.confirm(data, config); | |
} else { | |
console.warn("INFO: end of friend requests!"); | |
this.complete(config); | |
} | |
}, | |
confirm: function(data, config) { | |
if (data.length === 0){ | |
console.info("INFO: Current friend request list exhausted! Scrolling for more..."); | |
console.debug("DEBUG: scrolling to bottom in " + config.actionDelay + " ms"); | |
setTimeout(() => this.scrollBottom(data, config), config.actionDelay); | |
} else { | |
var friendRequest = data.shift(); | |
try { | |
var friendRequestName = friendRequest.parentElement.parentElement.parentElement.parentElement.parentElement.textContent.toLowerCase().split(" ")[0]; | |
if (config.mustIncludeInName.length <= 0 || config.mustIncludeInName.some(x => friendRequestName.match(x.toLowerCase()))) { | |
friendRequest.click(); | |
config.totalRequestsAccepted += 1; | |
config.maxRequestsToAccept -= 1; | |
if (config.maxRequestsToAccept === 0) { | |
this.complete(config); | |
} else { | |
console.info("INFO: " + config.totalRequestsAccepted + " friend requests accepted!"); | |
console.debug("DEBUG: Accepting next friend request in " + config.actionDelay); | |
setTimeout(() => this.confirm(data, config), config.actionDelay); | |
} | |
} else { | |
console.debug("DEBUG: Ignoring friend request from " + friendRequestName); | |
console.debug("DEBUG: Accepting next friend request in " + config.actionDelay); | |
setTimeout(() => this.confirm(data, config), config.actionDelay); | |
} | |
} catch (e) { | |
console.debug("DEBUG: Accepting next friend request in " + config.actionDelay); | |
setTimeout(() => this.confirm(data, config), config.actionDelay); | |
} | |
} | |
}, | |
scrollBottom: function (data, config) { | |
window.scrollTo({ top: document.body.scrollHeight, behavior: 'smooth' }); | |
console.debug("DEBUG: waiting for scroll data to load, then finding buttons in " + config.scrollDelay + " ms"); | |
setTimeout(() => this.inspect(data, config), config.scrollDelay); | |
}, | |
complete: function (config) { | |
console.info('INFO: script completed after accepting ' + config.totalRequestsAccepted + ' friend requests'); | |
} | |
} | |
Facebook.inspect([], Facebook.config); |
Thanks man, impressive!
In Chrome the following warning pops up when you try to copy-paste something into the console:
Warning: Don’t paste code into the DevTools Console that you don’t understand or haven’t reviewed yourself. This could allow attackers to steal your identity or take control of your computer. Please type ‘allow pasting’ below and hit Enter to allow pasting.
Here is a picture of the warning:
To make it work, execute the following line: (If you don't do this, you will not be able to copy-paste the script into the console
.)
allow pasting
After this line, when you copy-paste the script and execute it, you'll see this picture:
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What is this?
Have you ever felt like there was a way to accept all your Facebook friend requests automatically? That's where this script fits in.
The script, once runs (instructions below), works in the background on the page and keeps on accepting friend requests on the page as long as either it meets maximum requests specified by you or there are no more friend requests. The script has an adequate amount of delay placed between actions so you are not banned 😄
How to use the above script?
https://www.facebook.com/friends/requests/
.You'll see that friend requests are being accepted now after delays set in the config of the above file. If you want to limit the number of requests to be accepted, please update
maxRequestsToAccept
above to the desired number of requests.When does the script stop gracefully?
What to configure?
If it is taking too long or you are on a very fast internet connection, you can lower the delays between each action since elements will be loading faster for you. Below is an explanation of what each of the configuration item does:
Acknowledgement
This script takes inspiration from the LinkedIn AutoConnect script (https://gist.github.com/thealphadollar/7c0ee76664cbd28aecc1bd235f0202fd).
TODO