1. This website uses cookies to improve service and provide a tailored user experience. By using this site, you agree to this use. See our Cookie Policy.
    Dismiss Notice

[GET]JavaScript for Cancelling Outgoing Facebook Friend Requests

Discussion in 'FaceBook' started by Nonilol, Jan 15, 2019.

  1. Nonilol

    Nonilol Elite Member

    Joined:
    Mar 1, 2015
    Messages:
    1,768
    Likes Received:
    632
    Gender:
    Male
    Occupation:
    Information Technology & Management
    Location:
    Hamburg, GER / Southampton, UK
    Hey guys,

    A couple years ago I had a facebook account where I sent out tons of friend requests and I made this Javascript which helps cancelling them. I figured, this might help some of you :)


    How to use:

    Note: This is spaghetti code from multiple years ago, for the love of god do not judge my programming skills by this.


    Video demo:



    Code:
    Code:
    javascript:
    
    var delayInput = prompt("Delay between actions (ms)", "1000");
    var stopAfter = prompt("Stop after how many friend requests are cancelled?", "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);
    
    var i=0;
    var delay=0;
    var cont=true;
    
    var counter = 0;
    var countUntil = Math.floor(stopAfter/5);
    function foo() {
        if (counter <= countUntil){
            counter++;
            window.scrollTo(0,document.body.scrollHeight);
            window.setTimeout(foo, 1000+(Math.floor((Math.random()*10))));
        }
    }
    
    foo();
    
    function addFriends(){
        
        var inputs = document.querySelectorAll('._54k8._56bs._56bt');
        
        var stopAfterNumber=0;
        if(parseInt(stopAfter, 10)>inputs.length) {
            stopAfterNumber=inputs.length;
        } else {
            stopAfterNumber=parseInt(stopAfter, 10);
        }
    
        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+" friend requests cancelled! "+delay+"ms waiting...";
                cont=true;
            } else {
                document.getElementById("noni_loading").innerHTML = i+" friend requests cancelled";
                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("Done!");
                document.getElementById("noni_loading").setAttribute("style", "display: none;")
            }
        }
    }
    
    addFriends();
    Have fun!
     
    • Thanks Thanks x 1
  2. cerebration

    cerebration Jr. VIP Jr. VIP

    Joined:
    Mar 9, 2018
    Messages:
    276
    Likes Received:
    190
    Gender:
    Male
    This might be useful to cancel all the friend requests you've sent to girls that they've simply ignored.
     
  3. Nonilol

    Nonilol Elite Member

    Joined:
    Mar 1, 2015
    Messages:
    1,768
    Likes Received:
    632
    Gender:
    Male
    Occupation:
    Information Technology & Management
    Location:
    Hamburg, GER / Southampton, UK
    Guess what I originally made this for ¯\_(ツ)_/¯

    But it's also great for marketers that grow their facebook accounts by hand. If you're sending out lots of friend requests, you will eventually have to cancel pending friend requests in order to be able to add more people.
     
    • Thanks Thanks x 1
  4. negeadin

    negeadin Junior Member

    Joined:
    Feb 13, 2017
    Messages:
    128
    Likes Received:
    13
    Gender:
    Male
    Great share, thanks buddy!
     
  5. Nonilol

    Nonilol Elite Member

    Joined:
    Mar 1, 2015
    Messages:
    1,768
    Likes Received:
    632
    Gender:
    Male
    Occupation:
    Information Technology & Management
    Location:
    Hamburg, GER / Southampton, UK
    Just to clear things up:
    • Yes, this can be used with a desktop PC, but you need to be browsing facebook mobile (just click on the link in the original post and it will take you there)

    Let me know if you encounter any errors ;)
     
  6. youveggie

    youveggie Regular Member

    Joined:
    Nov 13, 2017
    Messages:
    200
    Likes Received:
    62
    Gender:
    Male
    Occupation:
    profit
    Location:
    www
    this is coming in handy
     
  7. LikePusher

    LikePusher BANNED BANNED

    Joined:
    May 30, 2018
    Messages:
    98
    Likes Received:
    17
    Will try to share the same code for desktop, guys
     
  8. Nonilol

    Nonilol Elite Member

    Joined:
    Mar 1, 2015
    Messages:
    1,768
    Likes Received:
    632
    Gender:
    Male
    Occupation:
    Information Technology & Management
    Location:
    Hamburg, GER / Southampton, UK
    You can use this on your desktop pc as well. Just open the mobile website. (m.facebook.com instead of facebook.com)