Skip to content

Instantly share code, notes, and snippets.

@renestalder
Last active May 11, 2026 09:28
Show Gist options
  • Select an option

  • Save renestalder/c5b77635bfbec8f94d28 to your computer and use it in GitHub Desktop.

Select an option

Save renestalder/c5b77635bfbec8f94d28 to your computer and use it in GitHub Desktop.
Unfollow all on Facebook

Facebook: Unfollow people and pages

See comments section for more up-to-date versions of the script. The original script is from 2014 and will not work as is.

  1. Open news feed preferences on your Facebook menu (browser)
  2. Click people or pages
  3. Scroll down (or click see more) until your full list is loaded
  4. Run the script in your browser console

Facebook will block this feature for you while you use it, depending on how much entities you try to unfollow. It automatically unblocks in a couple of hours and you will be able to continue.

var unfollowButtons = document.querySelectorAll('[data-followed="1"]'); for(var i=0;i<unfollowButtons.length;i++){ unfollowButtons[i].click(); } alert(unfollowButtons.length+' people are now unfollowed! ');
@BayLak-Egypt
Copy link
Copy Markdown

  • FACEBOOK Unfollow Script - Specialized Version
  • Developed by: BayLak
  • Description: Automated script to handle Facebook unfollowing process via DOM manipulation.
    Usage: Run this in the browser console on the 'Following' page.
    IN 2026/5/9
    https://www.facebook.com/YourUserName/following and run the script.

console.log("%c [!] Script Started... Developed by BayLak.", "color: #00FF00; font-weight: bold;");

let intervalId = setInterval(function () {
    // Select all "More options" buttons dynamically
    let moreButtons = document.querySelectorAll('div[role="button"][aria-label*="More options"]');
    
    if (moreButtons.length > 0) {
        let currentBtn = moreButtons[0];
        currentBtn.click();
        setTimeout(() => {
            // 2. Identify the Unfollow option by role and text content
            let menuItems = document.querySelectorAll('div[role="menuitem"]');
            let unfollowBtn = Array.from(menuItems).find(item => 
                item.innerText.includes('Unfollow') || item.innerText.includes('إلغاء المتابعة')
            );

            if (unfollowBtn) {
                unfollowBtn.click();
                console.log("%c [+] Target Unfollowed.", "color: #00FF00");
            }

            let container = currentBtn.closest('div.x1gefphp');
            if (container) {
                container.remove();
            }
            window.scrollBy(0, 150);
        }, 700);

    } else {
        // Scroll down to fetch and render more items
        window.scrollBy(0, 500);
        console.log("Scanning for more targets...");
    }
}, 1800); 

@BayLak-Egypt
Copy link
Copy Markdown

  • Facebook Advanced Unfollow Bot - Stealth Version
  • Developed by: BayLak
  • Features: Auto-counting, Stealth scrolling, and Batch processing.

2026/5/9
https://www.facebook.com/YourUserName/following and run the script.


(function() {
    let unfollowCount = 0;
    const targetLimit = 100; // Set your limit here to avoid bans
    
    console.log("%c [!] BayLak Stealth Engine Activated.", "color: #FFA500; font-weight: bold;");

    async function startProcess() {
        // 1. Get all available follow buttons on the screen
        let moreButtons = document.querySelectorAll('div[role="button"][aria-label*="More options"]');
        console.log(`%c [i] Found ${moreButtons.length} accounts in current view.`, "color: #00FFFF");

        for (let btn of moreButtons) {
            if (unfollowCount >= targetLimit) {
                console.log("%c [!] Target limit reached. Stopping to stay safe.", "color: #FF0000");
                return;
            }

            // Click the more options
            btn.click();
            
            // Wait for DOM to update
            await new Promise(r => setTimeout(r, 600));

            let menuItems = document.querySelectorAll('div[role="menuitem"]');
            let unfollowBtn = Array.from(menuItems).find(item => 
                item.innerText.includes('Unfollow') || item.innerText.includes('إلغاء المتابعة')
            );

            if (unfollowBtn) {
                unfollowBtn.click();
                unfollowCount++;
                console.log(`%c [+] Unfollowed count: ${unfollowCount}`, "color: #00FF00");
            }

            // Clean up the DOM to free memory and avoid re-scanning
            btn.closest('div.x1gefphp')?.remove();

            // Dynamic delay to mimic human behavior (Randomized between 1-2 seconds)
            await new Promise(r => setTimeout(r, Math.random() * 1000 + 1000));
        }

        // 2. Scroll and repeat
        window.scrollBy({ top: 800, behavior: 'smooth' });
        console.log("%c [~] Scrolling for more...", "color: #BBBBBB");
        
        setTimeout(startProcess, 2000);
    }

    startProcess();
})();

@BayLak-Egypt
Copy link
Copy Markdown

  • FACEBOOK ATTACKER Unfollow + Live Analytics
  • Developed by: BayLak
  • Priority: Maximum Speed | Mode: Aggressive with Logging
    2026/5/9

https://www.facebook.com/YourUserName/following and run the script.


(function() {
    let totalUnfollowed = 0;
    let startTime = Date.now();

    console.clear();
    console.log(
        "%c" + 
        "██████╗  █████╗ ██╗   ██╗██╗      █████╗ ██╗  ██╗\n" +
        "██╔══██╗██╔══██╗╚██╗ ██╔╝██║     ██╔══██╗██║ ██╔╝\n" +
        "██████╔╝███████║ ╚████╔╝ ██║     ███████║█████╔╝ \n" +
        "██╔══██╗██╔══██║  ╚██╔╝  ██║     ██╔══██║██╔═██╗ \n" +
        "██████╔╝██║  ██║   ██║   ███████╗██║  ██║██║  ██╗\n" +
        "╚═════╝ ╚═╝  ╚═╝   ╚═╝   ╚══════╝╚═╝  ╚═╝╚═╝  ╚═╝\n" +
        "Developed by: Mohamed Hamada (BayLak Egypt)", 
        "color: #00FF00; font-weight: bold; font-family: monospace;"
    );

    console.log("%c [!] Hyper-Speed Engine Started. Monitoring Live...", "color: #FFFF00;");

    let hyperInterval = setInterval(() => {
        let buttons = document.querySelectorAll('div[role="button"][aria-label*="More options"]');
        
        if (buttons.length === 0) {
            window.scrollBy(0, 1000);
            return;
        }

        buttons.forEach((btn) => {
            btn.click();
            
            setTimeout(() => {
                let menuItems = document.querySelectorAll('div[role="menuitem"]');
                let found = false;
                
                menuItems.forEach((item) => {
                    if (item.innerText.includes('Unfollow') || item.innerText.includes('إلغاء المتابعة')) {
                        item.click();
                        found = true;
                    }
                });

                if (found) {
                    totalUnfollowed++;
                    let duration = ((Date.now() - startTime) / 1000).toFixed(1);
                    // Live Update in Console
                    console.log(
                        `%c [+] Unfollowed: ${totalUnfollowed} | Speed: ${(totalUnfollowed / duration).toFixed(2)} ops/sec | Time: ${duration}s`, 
                        "color: #00FF00; background: #000; border-left: 4px solid #00FF00; padding: 2px 10px;"
                    );
                }

                btn.closest('div.x1gefphp')?.remove();
            }, 5); // Near-zero delay for extreme speed
        });

        window.scrollBy(0, 600);

    }, 150); // Checks for new targets every 150ms

    // To stop the script and see final report
    window.stopBayLak = () => {
        clearInterval(hyperInterval);
        console.log(`%c [FINISH] Total Processed: ${totalUnfollowed} accounts.`, "color: #FF00FF; font-size: 16px; font-weight: bold;");
    };
})();

Screenshot from 2026-05-09 22-23-21

@reyhzer
Copy link
Copy Markdown

reyhzer commented May 11, 2026

anyone has working code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment