Skip to content

Instantly share code, notes, and snippets.

@renestalder
Last active November 6, 2025 18:29
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! ');
@yulose9
Copy link

yulose9 commented Apr 25, 2024

let intervalId = setInterval(function () {
let manageButtons = document.querySelectorAll('div[aria-label="J’aime déjà"]');
let manageButton = manageButtons[0];
if (manageButton) {
setTimeout(() => {
manageButton.click();
}, 800);
var unfollowButtons = null;
let unfollowInterval = setInterval(function () {
setTimeout(() => {
unfollowButtons = document.querySelector('input[aria-label="Annuler la mention J’aime"]');
console.log(unfollowButtons)
if(unfollowButtons){
// Page
unfollowButtons.click();
unfollowUpdate = document.querySelector('div[aria-label="Mettre à jour"]');
unfollowUpdate.click();
}
}, 500);
clearInterval(unfollowInterval);
}, 500);
setTimeout(() => {
manageButton.remove();
if(unfollowButtons){
unfollowButtons.click();
}
}, 1000);
} else {
}
}, 500);
let intervalGroupId = setInterval(function () {
let mangeButtons = document.querySelectorAll('div[aria-label="Abonnée"]');
let mangeButton = mangeButtons[0];
if (mangeButton) {
setTimeout(() => {
mangeButton.click();
}, 800);
var unflwButtons = null;
let unflwInterval = setInterval(function () {
setTimeout(() => {
// Group with subscription
var radio = document.querySelectorAll('div[role="radio"]')[2];
if (radio){
radio.click();
setTimeout(() => {
unflwUpdate = document.querySelector('div[aria-label="Mettre à jour"]');
unflwUpdate.click();
}, 200);
}
}, 500);
clearInterval(unflwInterval);
}, 500);
setTimeout(() => {
mangeButton.remove();
if(unflwButtons){
unflwButtons.click();
}
}, 1000);
} else {
}
}, 500);

well this is still working, thanks!!!

@ITz-SaGaR
Copy link

Anyone can provide the latest version of Script which will work with EN? Since now Unfollow comes after hovering on the Picture of the list.

@HVR88
Copy link

HVR88 commented May 3, 2024

Not going to happen. The changes to the page make it impossible to target the links the way the previous script employed.

Did anyone else come looking because of the news surrounding the "Unfollow Everything 2.0" lawsuit? That's going to fail. No extension or script will ever work for longer than a short period as Facebook are constantly changing their source and layouts. And no sourt can compell FB to not change their layout.

@ixus36900
Copy link

Encontré una manera de obtener los todos los enlaces de las personas que alguna vez les envié invitación de amistad y por defecto las empecé a seguir, es decir todos los seguidos que no se muestran normalmente. Pero ahora no se como hacer sin necesidad de API, solo con script de consola, hacer para dejar de seguir y cancelar solicitud de amistad a cada uno de esos perfiles. alguien sabe como?

@jcarroll
Copy link

jcarroll commented Sep 29, 2024

@ixus36900 asked about retracting sent (outgoing) friend requests, saying he found a way to get a list of links to the profiles of those whom he previously offered a friend request, and he's looking for a way to cancel (retract) those offers (requests).

Work in progress:

  1. https://www.facebook.com/friends/requests
  2. "View sent Requests"
    image
  3. Use the "inspect" tool to find the html class of the "cancel request" button element (today it was "x6s0dn4 x78zum5 xl56j7k x1608yet xljgi0e x1e0frkt")
    image
  4. Use the code that worked to "unfollow" all Friends, Groups, and Pages...
    https://gist.github.com/jcarroll/1b97f5f81c4668bf3dfdb97b0ac0eb02
  5. Replace [class="x1b0d499 xi3auck"] with the class from #3, above.
  6. Run code in console:

Results: It did cancel all outgoing request requests for me. However, it also accepted all incoming friend requests also.

To cancel outgoing requests and not accept incoming requests, I would next look for an htnl class that is shared by the "cancel request" elements that is not part of the accept request elements.

Unfortunately, since I just accepted all incoming friend requests, I don't have any of those elements to inspect.

I'll be very interested to see progress on this, especially anyone with steps to get it working.

-jFc

@jun-fajr
Copy link

Hi guys, does anyone have a new script that works? I tried this one, but it didn’t work.

@AeonShai
Copy link

AeonShai commented Jun 5, 2025

I use this script to delete comments.

const delay = ms => new Promise(res => setTimeout(res, ms));

function isVisible(elem) {
  return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length );
}

function triggerClick(el) {
  el.dispatchEvent(new MouseEvent('mousedown', { bubbles: true }));
  el.dispatchEvent(new MouseEvent('mouseup', { bubbles: true }));
  el.dispatchEvent(new MouseEvent('click', { bubbles: true }));
}

async function unlikeFromTopByClass() {
  const containerSelector = 'div.x6s0dn4.x78zum5.xdt5ytf.x193iq5w.x1t2pt76.xh8yej3';

  const container = document.querySelector(containerSelector);
  if (!container) {
    console.error("Kapsayıcı div bulunamadı.");
    return;
  }

  let iteration = 0;

  while (true) {
    const icon = container.querySelector('i.x1b0d499.xep6ejk');
    if (!icon) {
      console.log("✅ Tüm beğeniler kaldırıldı.");
      break;
    }

    icon.scrollIntoView({ behavior: 'smooth', block: 'center' });
    await delay(500);

    triggerClick(icon);
    await delay(1000);

    // Menü açıldıktan sonra class'ı .xa6wxux olan butonu bul ve tıkla
    const deleteBtn = document.querySelector('.xa6wxux');

    if (deleteBtn && isVisible(deleteBtn)) {
      triggerClick(deleteBtn);
      console.log(`✔️ ${++iteration}. beğeni kaldırıldı (Sil butonu tıklandı).`);
      await delay(500);
    } else {
      console.warn("⚠️ Sil butonu bulunamadı veya görünür değil, devam ediliyor...");
      await delay(500);
    }
  }
}

unlikeFromTopByClass();

It makes clicks according to its classes. The classes of comments and following may be different, so “.xa6wxux” should be changed or additions should be made.

@akash-ooo
Copy link

@ReighEX
Copy link

ReighEX commented Jul 4, 2025

Here is the lates working code: https://github.com/akash-ooo/facebook-auto-unfollow-friends-and-pages-script-2025.git

thank you ! still working until now.

@ReighEX
Copy link

ReighEX commented Jul 4, 2025

update : now its bugged. Error appear like this
⚠️ No visible 'Unfollow' button found after 3-dot click. VM1033
🎯 No more new 3-dot buttons found, process completed. VM1033:51
✅ Unfollow process completed. Total unfollows: 0 VM1033:84

*i didn't change code or anything

Here is the lates working code: https://github.com/akash-ooo/facebook-auto-unfollow-friends-and-pages-script-2025.git

@daviddonatoiii
Copy link

Any updates? script isn't working anymore >.<

@matsyui
Copy link

matsyui commented Oct 30, 2025

No update?

@ixus36900
Copy link

Partial Solution to Unfollow Contacts on Facebook

I've been using a partial solution these days to unfollow contacts on Facebook. So far, I've managed to unfollow over 1,800 contacts, but I still have some left.

Steps:

Install Tampermonkey Extension: Install the Tampermonkey extension on Chrome (I recommend using Chrome).

https://chrome.google.com/webstore/detail/tampermonkey/dhdgffkkebhmkfjojejmpbldmpobfkfo?hl=en

Enable User Scripts: Go to the application manager, find Tampermonkey, click on "Details," and enable the "Allow user scripts" option.

Create a New Script: Click on the Tampermonkey icon, select "Create a new script," and replace the example code with the following:

// ==UserScript==
// @name         Unfollow FB
// @namespace    http://tampermonkey.net/
// @version      1.8
// @description  Versión estable y optimizada con esperas híbridas, contadores y scroll inteligente.
// @author       D.
// @match        https://www.facebook.com/*/following*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // --- CONFIGURACIÓN ---
    const INTERVALO_ENTRE_ACCIONES = 3500; // 3.5 segundos entre perfiles (un buen equilibrio).
    const PAUSA_CORTA_FIJA = 1500; // Pausa fija para sub-menús.
    const TIMEOUT_ESPERA_HOVER = 4000; // Tiempo máximo para que aparezca el hover principal.

    // --- ESTADO Y CONTADORES ---
    let perfilesProcesados = new Set();
    let contadorExitos = 0;
    let contadorFallos = 0;
    let intentosScrollSinExito = 0;
    const MAX_INTENTOS_SCROLL = 3;
    let procesoActivo = false;

    // --- ELEMENTOS DE LA INTERFAZ ---
    let panelInfo, controlButton, exitosDisplay, fallosDisplay;

    // --- FUNCIONES AUXILIARES ---
    function esperar(ms) {
        return new Promise(resolve => setTimeout(resolve, ms));
    }

    async function waitForElement(selector, timeout = TIMEOUT_ESPERA_HOVER) {
        const startTime = Date.now();
        while (Date.now() - startTime < timeout) {
            const element = document.querySelector(selector);
            if (element) return element;
            await esperar(100);
        }
        return null;
    }

    function actualizarUI() {
        if (exitosDisplay) exitosDisplay.textContent = `Éxitos: ${contadorExitos}`;
        if (fallosDisplay) fallosDisplay.textContent = `Fallos: ${contadorFallos}`;
    }

    function detenerProceso(mensaje) {
        procesoActivo = false;
        controlButton.textContent = 'Proceso Detenido';
        controlButton.style.backgroundColor = '#888';
        controlButton.disabled = true;
        console.log(`[Control] ${mensaje}`);
    }

    // --- LÓGICA DE "DEJAR DE SEGUIR"---
    async function intentarDejarDeSeguir(hoverContainer) {
        // Escenario 1
        const botonDejarSeguirDirecto = hoverContainer.querySelector('div[role="button"][aria-label="Dejar de seguir"]');
        if (botonDejarSeguirDirecto) {
            console.log("[Info] Escenario 1: 'Dejar de seguir' directo.");
            botonDejarSeguirDirecto.click();
            return true;
        }

        // Escenario 2
        const botonSiguiendo = hoverContainer.querySelector('div[role="button"][aria-label="Siguiendo"]');
        if (botonSiguiendo) {
            console.log("[Info] Escenario 2: Botón 'Siguiendo'.");
            botonSiguiendo.click();
            await esperar(PAUSA_CORTA_FIJA); // Pausa fija para estabilidad
            const botonDejarSeguirMenu = Array.from(document.querySelectorAll('div[role="menuitem"]')).find(el => el.textContent.includes('Dejar de seguir'));
            if (botonDejarSeguirMenu) {
                botonDejarSeguirMenu.click();
                return true;
            }
        }

        // Escenario 3
        const botonMasOpciones = hoverContainer.querySelector('div[role="button"][aria-label*="Opciones"]');
        if (botonMasOpciones) {
            console.log("[Info] Escenario 3: Botón '...'.");
            botonMasOpciones.click();
            await esperar(PAUSA_CORTA_FIJA); // Pausa fija para estabilidad
            const botonDejarSeguirMenu = Array.from(document.querySelectorAll('div[role="menuitem"]')).find(el => el.textContent.includes('Dejar de seguir'));
            if (botonDejarSeguirMenu) {
                botonDejarSeguirMenu.click();
                return true;
            }
        }

        return false;
    }

    // --- LÓGICA PRINCIPAL ---
    async function procesarUnPerfil() {
        const contenedoresDePerfil = document.querySelectorAll('div.x78zum5.x1q0g3np.x1a02dak.x1qughib > div');
        let perfilEncontradoParaProcesar = false;

        for (const perfil of contenedoresDePerfil) {
            const enlaceElemento = perfil.querySelector('a[href*="facebook.com/"]');
            if (!enlaceElemento || perfilesProcesados.has(enlaceElemento.href)) continue;

            perfilEncontradoParaProcesar = true;
            intentosScrollSinExito = 0;
            console.log(`[Acción] Procesando: ${enlaceElemento.href}.`);

            perfil.scrollIntoView({ behavior: 'smooth', block: 'center' });
            perfil.style.border = "2px solid red";
            await esperar(500);

            enlaceElemento.dispatchEvent(new MouseEvent('mouseover', { bubbles: true, cancelable: true }));

            const hoverContainer = await waitForElement('div[aria-label="Vista previa del enlace"]');

            if (!hoverContainer) {
                console.error("[Fallo] No se encontró el pop-up del hover (timeout).");
                contadorFallos++;
                perfil.style.border = "2px solid orange";
            } else {
                const exito = await intentarDejarDeSeguir(hoverContainer);

                if (exito) {
                    console.log("[Éxito] Acción de 'dejar de seguir' completada.");
                    contadorExitos++;
                    perfil.style.border = "2px solid green";
                } else {
                    console.warn("[Fallo] Se abrió el hover, pero no se encontró ninguna acción válida.");
                    contadorFallos++;
                    perfil.style.border = "2px solid orange";
                }

                await esperar(500);

                const botonCerrar = document.querySelector('div[role="button"][aria-label="Cerrar"]');
                if (botonCerrar) botonCerrar.click();
            }

            actualizarUI();
            perfilesProcesados.add(enlaceElemento.href);
            break;
        }

        if (!perfilEncontradoParaProcesar && contenedoresDePerfil.length > 0) {
            intentosScrollSinExito++;
            console.log(`[Info] No hay perfiles nuevos. Intento de scroll ${intentosScrollSinExito}/${MAX_INTENTOS_SCROLL}.`);
            if (intentosScrollSinExito >= MAX_INTENTOS_SCROLL) {
                detenerProceso("Proceso completado: Se ha llegado al final de la lista.");
            } else {
                window.scrollTo(0, document.body.scrollHeight);
            }
        }
    }

    async function buclePrincipal() {
        while (procesoActivo) {
            await procesarUnPerfil();
            await esperar(INTERVALO_ENTRE_ACCIONES);
        }
    }

    // --- INICIO Y CREACIÓN DE INTERFAZ ---
    function inicializar() {
        panelInfo = document.createElement('div');
        panelInfo.style.cssText = 'position: fixed; top: 100px; right: 20px; z-index: 9998; background: rgba(255, 255, 255, 0.9); padding: 10px; border: 1px solid #ccc; border-radius: 5px; font-family: Arial, sans-serif;';

        exitosDisplay = document.createElement('div');
        exitosDisplay.style.cssText = 'color: green; font-weight: bold;';

        fallosDisplay = document.createElement('div');
        fallosDisplay.style.cssText = 'color: red; font-weight: bold; margin-top: 5px;';

        panelInfo.appendChild(exitosDisplay);
        panelInfo.appendChild(fallosDisplay);
        document.body.appendChild(panelInfo);

        controlButton = document.createElement('button');
        controlButton.textContent = 'Iniciar Proceso';
        controlButton.style.cssText = 'position: fixed; top: 160px; right: 20px; z-index: 9999; padding: 10px 20px; background-color: #4267B2; color: white; border: none; border-radius: 5px; cursor: pointer;';
        document.body.appendChild(controlButton);

        actualizarUI();

        controlButton.addEventListener('click', () => {
            if (procesoActivo) {
                procesoActivo = false;
                controlButton.textContent = 'Iniciar Proceso';
                controlButton.style.backgroundColor = '#4267B2';
                console.log("[Control] Proceso detenido por el usuario. Finalizará después del ciclo actual.");
            } else {
                procesoActivo = true;
                controlButton.textContent = 'Detener Proceso';
                controlButton.style.backgroundColor = '#E0245E';
                console.log(`[Control] Proceso iniciado.`);
                buclePrincipal();
            }
        });
    }

    window.addEventListener('load', inicializar);

})();

Save the Script: Click "File" > "Save" and close the window.

Run the Script: Open Facebook, replace "youruser" with your username in the following link: https://www.facebook.com/youruser/following.
This will take you to the "Following" page.

Start the Process: Click the "Iniciar Proceso" (Start Process) button on the top right corner, and the script will start unfollowing contacts one by one, displaying a counter for successful and failed unfollows.

Limitations:

Doesn't unfollow:
Favorited contacts
Groups or pages
Only unfollows contacts

Manual Intervention Required: When the script encounters a page or group, you'll need to manually close the opened window to prevent the script from crashing.

To Avoid Bans: I recommend stopping the script every 400-500 contacts.

Hope this helps!

@matsyui
Copy link

matsyui commented Oct 31, 2025

Partial Solution to Unfollow Contacts on Facebook

I've been using a partial solution these days to unfollow contacts on Facebook. So far, I've managed to unfollow over 1,800 contacts, but I still have some left.

Steps:

Install Tampermonkey Extension: Install the Tampermonkey extension on Chrome (I recommend using Chrome).

https://chrome.google.com/webstore/detail/tampermonkey/dhdgffkkebhmkfjojejmpbldmpobfkfo?hl=en

Enable User Scripts: Go to the application manager, find Tampermonkey, click on "Details," and enable the "Allow user scripts" option.

Create a New Script: Click on the Tampermonkey icon, select "Create a new script," and replace the example code with the following:

// ==UserScript==
// @name         Unfollow FB
// @namespace    http://tampermonkey.net/
// @version      1.8
// @description  Versión estable y optimizada con esperas híbridas, contadores y scroll inteligente.
// @author       D.
// @match        https://www.facebook.com/*/following*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // --- CONFIGURACIÓN ---
    const INTERVALO_ENTRE_ACCIONES = 3500; // 3.5 segundos entre perfiles (un buen equilibrio).
    const PAUSA_CORTA_FIJA = 1500; // Pausa fija para sub-menús.
    const TIMEOUT_ESPERA_HOVER = 4000; // Tiempo máximo para que aparezca el hover principal.

    // --- ESTADO Y CONTADORES ---
    let perfilesProcesados = new Set();
    let contadorExitos = 0;
    let contadorFallos = 0;
    let intentosScrollSinExito = 0;
    const MAX_INTENTOS_SCROLL = 3;
    let procesoActivo = false;

    // --- ELEMENTOS DE LA INTERFAZ ---
    let panelInfo, controlButton, exitosDisplay, fallosDisplay;

    // --- FUNCIONES AUXILIARES ---
    function esperar(ms) {
        return new Promise(resolve => setTimeout(resolve, ms));
    }

    async function waitForElement(selector, timeout = TIMEOUT_ESPERA_HOVER) {
        const startTime = Date.now();
        while (Date.now() - startTime < timeout) {
            const element = document.querySelector(selector);
            if (element) return element;
            await esperar(100);
        }
        return null;
    }

    function actualizarUI() {
        if (exitosDisplay) exitosDisplay.textContent = `Éxitos: ${contadorExitos}`;
        if (fallosDisplay) fallosDisplay.textContent = `Fallos: ${contadorFallos}`;
    }

    function detenerProceso(mensaje) {
        procesoActivo = false;
        controlButton.textContent = 'Proceso Detenido';
        controlButton.style.backgroundColor = '#888';
        controlButton.disabled = true;
        console.log(`[Control] ${mensaje}`);
    }

    // --- LÓGICA DE "DEJAR DE SEGUIR"---
    async function intentarDejarDeSeguir(hoverContainer) {
        // Escenario 1
        const botonDejarSeguirDirecto = hoverContainer.querySelector('div[role="button"][aria-label="Dejar de seguir"]');
        if (botonDejarSeguirDirecto) {
            console.log("[Info] Escenario 1: 'Dejar de seguir' directo.");
            botonDejarSeguirDirecto.click();
            return true;
        }

        // Escenario 2
        const botonSiguiendo = hoverContainer.querySelector('div[role="button"][aria-label="Siguiendo"]');
        if (botonSiguiendo) {
            console.log("[Info] Escenario 2: Botón 'Siguiendo'.");
            botonSiguiendo.click();
            await esperar(PAUSA_CORTA_FIJA); // Pausa fija para estabilidad
            const botonDejarSeguirMenu = Array.from(document.querySelectorAll('div[role="menuitem"]')).find(el => el.textContent.includes('Dejar de seguir'));
            if (botonDejarSeguirMenu) {
                botonDejarSeguirMenu.click();
                return true;
            }
        }

        // Escenario 3
        const botonMasOpciones = hoverContainer.querySelector('div[role="button"][aria-label*="Opciones"]');
        if (botonMasOpciones) {
            console.log("[Info] Escenario 3: Botón '...'.");
            botonMasOpciones.click();
            await esperar(PAUSA_CORTA_FIJA); // Pausa fija para estabilidad
            const botonDejarSeguirMenu = Array.from(document.querySelectorAll('div[role="menuitem"]')).find(el => el.textContent.includes('Dejar de seguir'));
            if (botonDejarSeguirMenu) {
                botonDejarSeguirMenu.click();
                return true;
            }
        }

        return false;
    }

    // --- LÓGICA PRINCIPAL ---
    async function procesarUnPerfil() {
        const contenedoresDePerfil = document.querySelectorAll('div.x78zum5.x1q0g3np.x1a02dak.x1qughib > div');
        let perfilEncontradoParaProcesar = false;

        for (const perfil of contenedoresDePerfil) {
            const enlaceElemento = perfil.querySelector('a[href*="facebook.com/"]');
            if (!enlaceElemento || perfilesProcesados.has(enlaceElemento.href)) continue;

            perfilEncontradoParaProcesar = true;
            intentosScrollSinExito = 0;
            console.log(`[Acción] Procesando: ${enlaceElemento.href}.`);

            perfil.scrollIntoView({ behavior: 'smooth', block: 'center' });
            perfil.style.border = "2px solid red";
            await esperar(500);

            enlaceElemento.dispatchEvent(new MouseEvent('mouseover', { bubbles: true, cancelable: true }));

            const hoverContainer = await waitForElement('div[aria-label="Vista previa del enlace"]');

            if (!hoverContainer) {
                console.error("[Fallo] No se encontró el pop-up del hover (timeout).");
                contadorFallos++;
                perfil.style.border = "2px solid orange";
            } else {
                const exito = await intentarDejarDeSeguir(hoverContainer);

                if (exito) {
                    console.log("[Éxito] Acción de 'dejar de seguir' completada.");
                    contadorExitos++;
                    perfil.style.border = "2px solid green";
                } else {
                    console.warn("[Fallo] Se abrió el hover, pero no se encontró ninguna acción válida.");
                    contadorFallos++;
                    perfil.style.border = "2px solid orange";
                }

                await esperar(500);

                const botonCerrar = document.querySelector('div[role="button"][aria-label="Cerrar"]');
                if (botonCerrar) botonCerrar.click();
            }

            actualizarUI();
            perfilesProcesados.add(enlaceElemento.href);
            break;
        }

        if (!perfilEncontradoParaProcesar && contenedoresDePerfil.length > 0) {
            intentosScrollSinExito++;
            console.log(`[Info] No hay perfiles nuevos. Intento de scroll ${intentosScrollSinExito}/${MAX_INTENTOS_SCROLL}.`);
            if (intentosScrollSinExito >= MAX_INTENTOS_SCROLL) {
                detenerProceso("Proceso completado: Se ha llegado al final de la lista.");
            } else {
                window.scrollTo(0, document.body.scrollHeight);
            }
        }
    }

    async function buclePrincipal() {
        while (procesoActivo) {
            await procesarUnPerfil();
            await esperar(INTERVALO_ENTRE_ACCIONES);
        }
    }

    // --- INICIO Y CREACIÓN DE INTERFAZ ---
    function inicializar() {
        panelInfo = document.createElement('div');
        panelInfo.style.cssText = 'position: fixed; top: 100px; right: 20px; z-index: 9998; background: rgba(255, 255, 255, 0.9); padding: 10px; border: 1px solid #ccc; border-radius: 5px; font-family: Arial, sans-serif;';

        exitosDisplay = document.createElement('div');
        exitosDisplay.style.cssText = 'color: green; font-weight: bold;';

        fallosDisplay = document.createElement('div');
        fallosDisplay.style.cssText = 'color: red; font-weight: bold; margin-top: 5px;';

        panelInfo.appendChild(exitosDisplay);
        panelInfo.appendChild(fallosDisplay);
        document.body.appendChild(panelInfo);

        controlButton = document.createElement('button');
        controlButton.textContent = 'Iniciar Proceso';
        controlButton.style.cssText = 'position: fixed; top: 160px; right: 20px; z-index: 9999; padding: 10px 20px; background-color: #4267B2; color: white; border: none; border-radius: 5px; cursor: pointer;';
        document.body.appendChild(controlButton);

        actualizarUI();

        controlButton.addEventListener('click', () => {
            if (procesoActivo) {
                procesoActivo = false;
                controlButton.textContent = 'Iniciar Proceso';
                controlButton.style.backgroundColor = '#4267B2';
                console.log("[Control] Proceso detenido por el usuario. Finalizará después del ciclo actual.");
            } else {
                procesoActivo = true;
                controlButton.textContent = 'Detener Proceso';
                controlButton.style.backgroundColor = '#E0245E';
                console.log(`[Control] Proceso iniciado.`);
                buclePrincipal();
            }
        });
    }

    window.addEventListener('load', inicializar);

})();

Save the Script: Click "File" > "Save" and close the window.

Run the Script: Open Facebook, replace "youruser" with your username in the following link: https://www.facebook.com/youruser/following. This will take you to the "Following" page.

Start the Process: Click the "Iniciar Proceso" (Start Process) button on the top right corner, and the script will start unfollowing contacts one by one, displaying a counter for successful and failed unfollows.

Limitations:

Doesn't unfollow: Favorited contacts Groups or pages Only unfollows contacts

Manual Intervention Required: When the script encounters a page or group, you'll need to manually close the opened window to prevent the script from crashing.

To Avoid Bans: I recommend stopping the script every 400-500 contacts.

Hope this helps!

No need for extension.
https://github.com/matsyui/Facebook-Scripts/blob/main/auto-unfollow.md
image

@matsyui
Copy link

matsyui commented Oct 31, 2025

@ixus36900 i have also added support for Unlike

@Makharaa
Copy link

Makharaa commented Nov 5, 2025

@matsyui it does not work
Untitled

@matsyui
Copy link

matsyui commented Nov 5, 2025

@matsyui it does not work Untitled

For processOneProfile try to update the div.x78zum5.x1q0g3np.x1a02dak.x1qughib > div with your own selector.

test

@Makharaa
Copy link

Makharaa commented Nov 5, 2025

@matsyui It works on pages but doesn't unfollow persons. It gives me the error unfollow dialog not found.

@matsyui
Copy link

matsyui commented Nov 6, 2025

@matsyui It works on pages but doesn't unfollow persons. It gives me the error unfollow dialog not found.

You have to update this div.x78zum5.x1q0g3np.x1a02dak.x1qughib > div to your own elements

Step 1. right click name then click inspect element
image

Step 2. Find your selector
image

@daokethinh-tech
Copy link

image I am getting this error how to solve it?

@matsyui
Copy link

matsyui commented Nov 6, 2025

image I am getting this error how to solve it?

  1. Is your internet good? try increasing HOVER_WAIT_TIMEOUT
  2. Is your selector setup? Read the one above. should be like div.XXXXX.XXXXX.XXXX.XXXXX > div

@daokethinh-tech
Copy link

ảnh Tôi gặp lỗi này làm thế nào để giải quyết nó?

  1. Internet của bạn có tốt không? Thử tăng HOVER_WAIT_TIMEOUT
  2. Bộ chọn của bạn đã được thiết lập chưa? Đọc một ở trên. nên giống như div.XXXXX.XXXXX.XXXX.XXXXX > div

My internet is 100mb/s very good, has set the filter on Tampermonkey. Can you support me with Teamview or Ultraview? Thank you very much!
image

@matsyui
Copy link

matsyui commented Nov 6, 2025

ảnh Tôi gặp lỗi này làm thế nào để giải quyết nó?

  1. Internet của bạn có tốt không? Thử tăng HOVER_WAIT_TIMEOUT
  2. Bộ chọn của bạn đã được thiết lập chưa? Đọc một ở trên. nên giống như div.XXXXX.XXXXX.XXXX.XXXXX > div

My internet is 100mb/s very good, has set the filter on Tampermonkey. Can you support me with Teamview or Ultraview? Thank you very much! image

Do the step 2, after that paste the script in the console.

I dont do remote view

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