[GET] Javascript for sending Facebook Friend Request 2020

Bruzes

Newbie
Joined
Jun 14, 2020
Messages
1
Reaction score
0
Hey there,

I was looking for a Javascript that automatically clicks all 'Add Friend'-buttons and checks if there is any Confirm or Exception popup or not, if yes it either clicks on Confirm button and cancel button on exception popup. I couldn't find any good one and decided to find different codes and code one myself, but I need some HELP finishing this. I found two codes and I would love to combine them.

Perfect for people like me who grow Facebook accounts by hand.


Features:
  • Set how many friends requests you wish to send in total
  • Set delay between two friend requests
  • Set delay between Confirm/Cancel button on exception popup
  • Scrolls to the bottom to load new friends
  • Overlay that shows how many friend requests have been sent already
  • Doesn't freeze the browser

How to use:
  • Create new bookmark
  • Copy & paste the following code where you would usually put the URL
  • Click the bookmark to send friend requests


Tested in Chrome & Firefox. Please let me know if you encounter any bugs.


Enjoy!

This is the first code:
Code:
(function wrapperFunction() {
// 1st setInterval codeblock below is executed each 2 seconds, checks if there is any Confirm or Exception popup or not, if yes it either clicks on Confirm button And cancel button on exception popup
            setInterval(function() {
              $('[role="dialog"]').find('.layerConfirm').click(); //Clicks on confirm automatically
              jQuery('.uiLayer').remove();
              jQuery('._li._31e').removeClass('_31e'); // Removes exception layer if any
            }, 2000);
            var friendsArr;
      // Initially called once and internally it will call again infinitely as soon as it process visible Add friends elements.
            addFriends(); // executes once
            function addFriends() {
            friendsArr = $('.FriendRequestAdd')
              counter = 0,
                timer = setInterval(function() {
                // It triggers click event of add friend button one by one
                  $(friendsArr[counter]).click();
                  counter++
                  // When visible friends are over, loading new friends list
                  if (counter === friendsArr.length) {
                    $(friendsArr).remove(); // Remove old friends blocks
                    // Scrolls to the bottom to load new friends
                    var scrollingElement = (document.scrollingElement || document.body);
                    scrollingElement.scrollTop = scrollingElement.scrollHeight;
clearInterval(timer);
                    addFriends(); // Restart the process
                  }
                }, 9000); // Add friend each 4 seconds.
            }
})();

This code I would like to combine with the code above. (I couldn't insert my code when I write 'Javascript' so that's why I removed J from javascript.)
Code:
avascript:
var delayInput = prompt("Delay between actions (ms)", "1000");
var stopAfter = prompt("Stop after how many friend requests are sent?", "100");
var workDelay = parseInt(delayInput, 10);

var loading = document.createElement("div");
loading.setAttribute("id", "noni_loading");
loading.setAttribute("style", "position: fixed; background: rgba(255,255,255,0.8); top: 0; left: 0; width: 100%; font-size: 24px; z-index: 1000; padding: 12px;");
document.body.appendChild(loading);
document.getElementById("noni_loading").innerHTML = "No friends added.";

var inputs = document.querySelectorAll('.FriendRequestAdd:not(.hidden_elem)');


var i=0;
var delay=0;
var cont=true;
var stopAfterNumber=0;
if(parseInt(stopAfter, 10)>inputs.length) {
    stopAfterNumber=inputs.length;
} else {
    stopAfterNumber=parseInt(stopAfter, 10);
}

function addFriends(max){

    if(inputs.length<=0) {
        document.getElementById("noni_loading").setAttribute("style", "position: fixed; background: rgba(140,60,60,0.8); top: 0; left: 0; width: 100%; font-size: 24px; color: #fff; z-index: 1000; padding: 12px;");
        document.getElementById("noni_loading").innerHTML = "No 'Add Friend'-buttons found :(";
  
        alert("That didn't work...");
        document.getElementById("noni_loading").setAttribute("style", "display: none;");
  
    } else {

        if(workDelay <= 0) {
            delay=0;
        } else if(workDelay <= 10) {
            delay=workDelay+(Math.floor((Math.random()*5)));
        } else {
            delay=workDelay+(Math.floor(Math.random()*(0.1*delay))-(0.05*workDelay));
        }

        if(i<stopAfterNumber) {
            inputs[i].click();
            document.getElementById("noni_loading").innerHTML = i+" friends added. "+delay+"ms waiting...";
            cont=true;
        } else {
            document.getElementById("noni_loading").innerHTML = i+" friends successfully added!";
            document.getElementById("noni_loading").setAttribute("style", "position: fixed; background: rgba(60,140,60,0.8); top: 0; left: 0; width: 100%; font-size: 24px; color: #fff; z-index: 1000; padding: 12px;");
            cont=false;
        }

        i++;
        if(cont==true) {
            setTimeout(addFriends, delay);
        } else {
            alert("Success!");
            document.getElementById("noni_loading").setAttribute("style", "display: none;")
        }
    }
}

addFriends();
 
Last edited:
Hi
Bruzes
I too looking for a Javascript that automatically clicks all 'Add Friend'-buttons
that code should check if there is any Confirm or Exception popup or not, if yes it either clicks on Confirm button and cancel button on exception popup.
If anyone have please share here, Thanks...
 
Back
Top