Skip to content

Instantly share code, notes, and snippets.

@renestalder
Last active June 5, 2025 15:14
Show Gist options
  • Save renestalder/c5b77635bfbec8f94d28 to your computer and use it in GitHub Desktop.
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! ');
@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.

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