Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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! ');
@bdoner

This comment has been minimized.

Copy link

@bdoner bdoner commented Jul 7, 2017

Update 07-07-2017:

  1. --||--
  2. Click unfollow people to hide their posts.
  3. --||--
  4. Run below script in your browser console.
    var buds = document.querySelectorAll("[data-testid=\"unfollow\"] [data-testid=\"profile_grid_block\"] div[role=\"button\"]"); for(var b of buds){ b.click(); }
@reuniware

This comment has been minimized.

Copy link

@reuniware reuniware commented Jun 11, 2018

Great ! Thanks

@paulchrisluke

This comment has been minimized.

Copy link

@paulchrisluke paulchrisluke commented Aug 18, 2018

been using this for months, really grateful thank you!

@PokeYouInDaEye

This comment has been minimized.

Copy link

@PokeYouInDaEye PokeYouInDaEye commented Sep 4, 2018

Thank you!
Is there a way to reverse the code too? To re-follow everyone?

@aspirez4

This comment has been minimized.

Copy link

@aspirez4 aspirez4 commented Sep 30, 2019

Working as of 30 Sep 2019. Also there is timeout so facebook won't block unfollowing.
var unfollowButtons = document.querySelectorAll('div[data-testid=profile_grid_block_picture]'); unfollowed = 0; for(var i=0;i<unfollowButtons.length;i++) { setTimeout(function(element){ element.click(); unfollowed ++; console.log('Total unfollowed ' + unfollowed + ' out of ' + unfollowButtons.length) }, i*2000, unfollowButtons[i]) }

@doronbehar

This comment has been minimized.

Copy link

@doronbehar doronbehar commented Oct 22, 2019

Thanks @aspirez4! Worked for me.

@sastone75

This comment has been minimized.

Copy link

@sastone75 sastone75 commented Jan 21, 2020

It worked for me, unfollowed 861 pages.

@davr

This comment has been minimized.

Copy link

@davr davr commented Mar 27, 2020

Updated, worked 3/27/2020 for me

  1. arrow in upper right
  2. news feed preferences
  3. unfollow people
  4. paste this script into devtools console, come back later (it clicks one button every 2 seconds to prevent being blocked by FB, decrease the 2000 value if you want)

var unfollowButtons = document.querySelectorAll('div[aria-pressed="false"]'); unfollowed = 0; for(var i=0;i<unfollowButtons.length;i++) { setTimeout(function(element){ element.click(); unfollowed ++; console.log('Total unfollowed ' + unfollowed + ' out of ' + unfollowButtons.length) }, i*2000, unfollowButtons[i]) }

@HasnatCET

This comment has been minimized.

Copy link

@HasnatCET HasnatCET commented Apr 14, 2020

Updated, worked 3/27/2020 for me

  1. arrow in upper right
  2. news feed preferences
  3. unfollow people
  4. paste this script into devtools console, come back later (it clicks one button every 2 seconds to prevent being blocked by FB, decrease the 2000 value if you want)

var unfollowButtons = document.querySelectorAll('div[aria-pressed="false"]'); unfollowed = 0; for(var i=0;i<unfollowButtons.length;i++) { setTimeout(function(element){ element.click(); unfollowed ++; console.log('Total unfollowed ' + unfollowed + ' out of ' + unfollowButtons.length) }, i*2000, unfollowButtons[i]) }

TnQ so much

@gelsoniezzi

This comment has been minimized.

Copy link

@gelsoniezzi gelsoniezzi commented Apr 18, 2020

Updated, worked 3/27/2020 for me

  1. arrow in upper right
  2. news feed preferences
  3. unfollow people
  4. paste this script into devtools console, come back later (it clicks one button every 2 seconds to prevent being blocked by FB, decrease the 2000 value if you want)

var unfollowButtons = document.querySelectorAll('div[aria-pressed="false"]'); unfollowed = 0; for(var i=0;i<unfollowButtons.length;i++) { setTimeout(function(element){ element.click(); unfollowed ++; console.log('Total unfollowed ' + unfollowed + ' out of ' + unfollowButtons.length) }, i*2000, unfollowButtons[i]) }

Tkx, dear

@mehmetegemen

This comment has been minimized.

Copy link

@mehmetegemen mehmetegemen commented May 4, 2020

Probably your Facebook language should be English to use below.
Here is my solution as the 4th of May, 2020:

const follows = document.querySelectorAll('div[aria-label="Toggle to follow"]')
for (let i = 0; i<follows.length; i++) {
  setTimeout(() => follows[i].click(), i * 1500)
}
@alvin-chang

This comment has been minimized.

Copy link

@alvin-chang alvin-chang commented Jul 7, 2020

Updated, worked 3/27/2020 for me

  1. arrow in upper right
  2. news feed preferences
  3. unfollow people
  4. paste this script into devtools console, come back later (it clicks one button every 2 seconds to prevent being blocked by FB, decrease the 2000 value if you want)

var unfollowButtons = document.querySelectorAll('div[aria-pressed="false"]'); unfollowed = 0; for(var i=0;i<unfollowButtons.length;i++) { setTimeout(function(element){ element.click(); unfollowed ++; console.log('Total unfollowed ' + unfollowed + ' out of ' + unfollowButtons.length) }, i*2000, unfollowButtons[i]) }

Working on 7/7/2020.

@StarvingEmma

This comment has been minimized.

Copy link

@StarvingEmma StarvingEmma commented Jul 18, 2020

Probably your Facebook language should be English to use below.
Here is my solution as the 4th of May, 2020:

const follows = document.querySelectorAll('div[aria-label="Toggle to follow"]')
for (let i = 0; i<follows.length; i++) {
  setTimeout(() => follows[i].click(), i * 1500)
}

Tried every code on here, only yours worked on 18th of July 2020 for new facebook look. I wish I'd know how to make things like this. Thank you so so much.

@Tazmanian-legs

This comment has been minimized.

Copy link

@Tazmanian-legs Tazmanian-legs commented Jul 26, 2020

Probably your Facebook language should be English to use below.
Here is my solution as the 4th of May, 2020:

const follows = document.querySelectorAll('div[aria-label="Toggle to follow"]')
for (let i = 0; i<follows.length; i++) {
  setTimeout(() => follows[i].click(), i * 1500)
}

Tried every code on here, only yours worked on 18th of July 2020 for new facebook look. I wish I'd know how to make things like this. Thank you so so much.

Hello! it used to work well but today it doesn't work anymore?

@5VENY

This comment has been minimized.

Copy link

@5VENY 5VENY commented Aug 31, 2020

Probably your Facebook language should be English to use below.
Here is my solution as the 4th of May, 2020:

const follows = document.querySelectorAll('div[aria-label="Toggle to follow"]')
for (let i = 0; i<follows.length; i++) {
  setTimeout(() => follows[i].click(), i * 1500)
}

This one worked for me @31/08/2020

@laudalashan

This comment has been minimized.

Copy link

@laudalashan laudalashan commented Sep 2, 2020

How do I unfollow everyone that is not my friend on Facebook at once?

@raphodn

This comment has been minimized.

Copy link

@raphodn raphodn commented Oct 25, 2020

The latest script (two comments above) works for me on 25/10/2020.

Remember to :

  • first go to facebook.com > arrow in upper right > Settings & Privacy > News Feed Preferences > and scroll the whole list to the bottom
  • open your console and run the script, and wait. The script takes 1.5 seconds per each "unfollow", so if you have 500 for example, it will take more than 8 minutes :)
@fotisps

This comment has been minimized.

Copy link

@fotisps fotisps commented Nov 16, 2020

Totally works!

@dbuenosilva

This comment has been minimized.

Copy link

@dbuenosilva dbuenosilva commented Nov 20, 2020

Finally, I can use FB again :)

Thanks for sharing.

@didisun-zz

This comment has been minimized.

Copy link

@didisun-zz didisun-zz commented Dec 2, 2020

doesn't seem to work on my end. 0 people are unfollowed

@itady74

This comment has been minimized.

Copy link

@itady74 itady74 commented Dec 12, 2020

doesn't seem to work on my end. 0 people are unfollowed

Remember to :

first go to facebook.com > arrow in upper right > Settings & Privacy > News Feed Preferences > and scroll the whole list to the bottom
open your console and run the script, and wait. The script takes 1.5 seconds per each "unfollow", so if you have 500 for example, it will take more than 8 minutes :)
@Bedete94

This comment has been minimized.

Copy link

@Bedete94 Bedete94 commented Dec 15, 2020

I am trying to do this step by step but it doesnt do nothing... I am at the bottom of the list, press inspect. my console popup, i write the command and nothing happens. Should i see any process or anything that would say me it is working and doing the job? I dont see any difference after few minutes, what i am doing wrong?

@renestalder

This comment has been minimized.

Copy link
Owner Author

@renestalder renestalder commented Dec 15, 2020

Sorry folks, can't really help debugging this. Deleted my Facebook account around 2 years ago.

Try the latest script as in the comment from 31. Aug. 2020 with the manual in the comment from the 25th of October.

If that doesn't work, it might mean the interface changed again and somebody would need to adapt the script to the new interface, again.

@mehmetegemen

This comment has been minimized.

Copy link

@mehmetegemen mehmetegemen commented Dec 15, 2020

I tried the script again on my account and it still works. Are you sure you use the new Facebook in the English language?

@Bedete94

This comment has been minimized.

Copy link

@Bedete94 Bedete94 commented Dec 15, 2020

Sorry for distraction, i left my computer overnight and it really worked out, i just had too much friends to see effects in real time, now i follow 0 people!

So yes, this one worked for me very well, but dont be confused when u dont see any process happening, it is working in the background, silently like ninja 💯

const follows = document.querySelectorAll('div[aria-label="Toggle to follow"]')
for (let i = 0; i<follows.length; i++) {
setTimeout(() => follows[i].click(), i * 1500)
}

Thanks for the help!

@casey

This comment has been minimized.

Copy link

@casey casey commented Jan 27, 2021

Here's a modified version of the script, working as of January 27th, 2021, that prints a message to the console and the time remaining after each unfollow:

var follows = document.querySelectorAll('div[aria-label="Toggle to follow"]');
var delay = 1500;

var i = 0;

function unfollow() {
  if (i == follows.length) {
    return;
  }

  var remaining = ((follows.length - i) * delay / 1000).toFixed(2);

  console.log("Unfollowing", i + 1, "of", follows.length + ",", remaining + "s", "remaining…");

  follows[i].click();

  i = i + 1;

  setTimeout(unfollow, delay);
}

unfollow();
@AnirudhVyas

This comment has been minimized.

Copy link

@AnirudhVyas AnirudhVyas commented Feb 5, 2021

Probably your Facebook language should be English to use below.
Here is my solution as the 4th of May, 2020:

const follows = document.querySelectorAll('div[aria-label="Toggle to follow"]')
for (let i = 0; i<follows.length; i++) {
  setTimeout(() => follows[i].click(), i * 1500)
}

This is the only one that has worked for me as of Feb 4 2021.

@AnirudhVyas

This comment has been minimized.

Copy link

@AnirudhVyas AnirudhVyas commented Feb 5, 2021

Here's a modified version of the script, working as of January 27th, 2021, that prints a message to the console and the time remaining after each unfollow:

var follows = document.querySelectorAll('div[aria-label="Toggle to follow"]');
var delay = 1500;

var i = 0;

function unfollow() {
  if (i == follows.length) {
    return;
  }

  var remaining = ((follows.length - i) * delay / 1000).toFixed(2);

  console.log("Unfollowing", i + 1, "of", follows.length + ",", remaining + "s", "remaining…");

  follows[i].click();

  i = i + 1;

  setTimeout(unfollow, delay);
}

unfollow();

your script is even better (Feb 4 2021)

@Dileep-Vidyadara

This comment has been minimized.

Copy link

@Dileep-Vidyadara Dileep-Vidyadara commented Apr 8, 2021

Probably your Facebook language should be English to use below.
Here is my solution as the 4th of May, 2020:

const follows = document.querySelectorAll('div[aria-label="Toggle to follow"]')
for (let i = 0; i<follows.length; i++) {
  setTimeout(() => follows[i].click(), i * 1500)
}

This code worked for me on 08-April-2021.
Thanks man ! Helped alot ❤️❤️

@zeeshu191

This comment has been minimized.

Copy link

@zeeshu191 zeeshu191 commented May 22, 2021

const follows = document.querySelectorAll('div[aria-label="Toggle to follow"]')
for (let i = 0; i<follows.length; i++) {
setTimeout(() => follows[i].click(), i * 1500)
}

THIS CODE RETURNS WITH THIS ERROR
"Uncaught SyntaxError: Identifier 'follows' has already been declared"
using on fb 22/5/2021
HELP!!!!!!!!!!!

@zeeshu191

This comment has been minimized.

Copy link

@zeeshu191 zeeshu191 commented May 22, 2021

Please recommend me an script as of 22/5/2021
seems fb has updated the interface and previous script dont seem to work
need your help guys!!

wanna unfollow people from my following list on FB

@renestalder

This comment has been minimized.

Copy link
Owner Author

@renestalder renestalder commented May 25, 2021

When this error pops up, try running only the for-loop:

for (let i = 0; i<follows.length; i++) {
  setTimeout(() => follows[i].click(), i * 1500)
}

Can't test it for you, I don't have a Facebook account any more. But the error suggests you are trying to run the first line declaring the variable a second time, which then ends in this error.

@zeeshu191

This comment has been minimized.

Copy link

@zeeshu191 zeeshu191 commented May 25, 2021

@renestalder I get the following error as stated below, if you can help im grateful
for (let i = 0; i<follows.length; i++) {
setTimeout(() => follows[i].click(), i * 1500)
}

Uncaught ReferenceError: follows is not defined
at :1:19

@renestalder

This comment has been minimized.

Copy link
Owner Author

@renestalder renestalder commented May 25, 2021

If you get "Uncaught ReferenceError: follows is not defined":

const follows = document.querySelectorAll('div[aria-label="Toggle to follow"]')
for (let i = 0; i<follows.length; i++) {
  setTimeout(() => follows[i].click(), i * 1500)
}

And if you get "Uncaught SyntaxError: Identifier 'follows' has already been declared", only:

for (let i = 0; i<follows.length; i++) {
  setTimeout(() => follows[i].click(), i * 1500)
}

The second error might happen, because you tried to run the script multiple times, so the first line that declares the variable follows already exists.

Alternatively you can try this:

window.follows = document.querySelectorAll('div[aria-label="Toggle to follow"]')
for (let i = 0; i<window.follows.length; i++) {
  setTimeout(() => window.follows[i].click(), i * 1500)
}
@zeeshu191

This comment has been minimized.

Copy link

@zeeshu191 zeeshu191 commented May 25, 2021

@renestalder

const follows = document.querySelectorAll('div[aria-label="Toggle to follow"]')
for (let i = 0; i<follows.length; i++) {
setTimeout(() => follows[i].click(), i * 1500)
}

it returns undefined upon execution

@mccrodp

This comment has been minimized.

Copy link

@mccrodp mccrodp commented Jul 19, 2021

for (let i = 0; i<window.follows.length; i++) {
  setTimeout(() => window.follows[i].click(), i * 150)
}

This works for me, I reduced timer and it's nice n snappy. Thanks folks!

@Ahmedrsayed

This comment has been minimized.

Copy link

@Ahmedrsayed Ahmedrsayed commented Jul 24, 2021

Alternatively you can try this:

window.follows = document.querySelectorAll('div[aria-label="Toggle to follow"]') for (let i = 0; i<window.follows.length; i++) { setTimeout(() => window.follows[i].click(), i * 1500) }

This Worked For Me 23-7-2021
Thanks renestalder

@EKUbro

This comment has been minimized.

Copy link

@EKUbro EKUbro commented Aug 10, 2021

Probably your Facebook language should be English to use below.
Here is my solution as the 4th of May, 2020:

const follows = document.querySelectorAll('div[aria-label="Toggle to follow"]')
for (let i = 0; i<follows.length; i++) {
  setTimeout(() => follows[i].click(), i * 1500)
}

worked for me August 10-2021.. Thanks

@jaideejung007

This comment has been minimized.

Copy link

@jaideejung007 jaideejung007 commented Aug 13, 2021

Here's a modified version of the script, working as of January 27th, 2021, that prints a message to the console and the time remaining after each unfollow:

var follows = document.querySelectorAll('div[aria-label="Toggle to follow"]');
var delay = 1500;

var i = 0;

function unfollow() {
  if (i == follows.length) {
    return;
  }

  var remaining = ((follows.length - i) * delay / 1000).toFixed(2);

  console.log("Unfollowing", i + 1, "of", follows.length + ",", remaining + "s", "remaining…");

  follows[i].click();

  i = i + 1;

  setTimeout(unfollow, delay);
}

unfollow();

This method works for me! (13/8/2021)

Big thanks.

@MR-Yunus

This comment has been minimized.

Copy link

@MR-Yunus MR-Yunus commented Sep 28, 2021

Here's a modified version of the script, working as of January 27th, 2021, that prints a message to the console and the time remaining after each unfollow:

var follows = document.querySelectorAll('div[aria-label="Toggle to follow"]');
var delay = 1500;

var i = 0;

function unfollow() {
  if (i == follows.length) {
    return;
  }

  var remaining = ((follows.length - i) * delay / 1000).toFixed(2);

  console.log("Unfollowing", i + 1, "of", follows.length + ",", remaining + "s", "remaining…");

  follows[i].click();

  i = i + 1;

  setTimeout(unfollow, delay);
}

unfollow();

This method works for me! (13/8/2021)

Big thanks.

if you have a tall list of followed pages and friends.... you have to scrolling down to the last followed page/friend/...
anyway thank you for this

@kuberlog

This comment has been minimized.

Copy link

@kuberlog kuberlog commented Oct 7, 2021

I find it hilarious that this pops up when I open the console. I suppose there is valid concern for selfxss of other settings though

                                            
 .d8888b.  888                       888    
d88P  Y88b 888                       888    
Y88b.      888                       888    This is a browser feature intended for 
 "Y888b.   888888  .d88b.  88888b.   888    developers. If someone told you to copy-paste 
    "Y88b. 888    d88""88b 888 "88b  888    something here to enable a Facebook feature 
      "888 888    888  888 888  888  Y8P    or "hack" someone's account, it is a 
Y88b  d88P Y88b.  Y88..88P 888 d88P         scam and will give them access to your 
 "Y8888P"   "Y888  "Y88P"  88888P"   888    Facebook account.
                           888              
                           888              
                           888              

See https://www.facebook.com/selfxss for more information.

@MR-Yunus

This comment has been minimized.

Copy link

@MR-Yunus MR-Yunus commented Oct 7, 2021

I find it hilarious that this pops up when I open the console. I suppose there is valid concern for selfxss of other settings though

                                            
 .d8888b.  888                       888    
d88P  Y88b 888                       888    
Y88b.      888                       888    This is a browser feature intended for 
 "Y888b.   888888  .d88b.  88888b.   888    developers. If someone told you to copy-paste 
    "Y88b. 888    d88""88b 888 "88b  888    something here to enable a Facebook feature 
      "888 888    888  888 888  888  Y8P    or "hack" someone's account, it is a 
Y88b  d88P Y88b.  Y88..88P 888 d88P         scam and will give them access to your 
 "Y8888P"   "Y888  "Y88P"  88888P"   888    Facebook account.
                           888              
                           888              
                           888              

See https://www.facebook.com/selfxss for more information.

Thank You ... But i use ( two-factor authentication facebook ) and i did unfollow all my followed pages/friends... by this script succesfully without then i changed my password ... i know this stupid steps haha but as a person know little about coding i didnt saw any dangerous thing ... i think that you master or you have advanced knowldge about this things ... again thank so much

@renestalder

This comment has been minimized.

Copy link
Owner Author

@renestalder renestalder commented Oct 8, 2021

If anybody ever feels unsure whether they should copy/paste a script here to their console, ping me and I take a look at it, whether it contains something suspicious or not. As I posted the initial script 7 years ago and don't have a Facebook account for years now, we are kind of dependent on people adapting the script from time to time. I frequently look at this conversation here, and I would delete any harmful scripts as soon as I see them.

That said: Yes, don't copy/paste any scripts into your browser console if you are not sure what you do.

@Lukortech

This comment has been minimized.

Copy link

@Lukortech Lukortech commented Oct 8, 2021

@MR-Yunus

Thanks, great piece although had to tweak delay a bit.

@tmldoc

This comment has been minimized.

Copy link

@tmldoc tmldoc commented Oct 8, 2021

Here's a modified version of the script, working as of January 27th, 2021, that prints a message to the console and the time remaining after each unfollow:

var follows = document.querySelectorAll('div[aria-label="Toggle to follow"]');
var delay = 1500;

var i = 0;

function unfollow() {
  if (i == follows.length) {
    return;
  }

  var remaining = ((follows.length - i) * delay / 1000).toFixed(2);

  console.log("Unfollowing", i + 1, "of", follows.length + ",", remaining + "s", "remaining…");

  follows[i].click();

  i = i + 1;

  setTimeout(unfollow, delay);
}

unfollow();

HERO.

@erix-nistor

This comment has been minimized.

Copy link

@erix-nistor erix-nistor commented Oct 8, 2021

Here's a modified version of the script, working as of January 27th, 2021, that prints a message to the console and the time remaining after each unfollow:

var follows = document.querySelectorAll('div[aria-label="Toggle to follow"]');
var delay = 1500;

var i = 0;

function unfollow() {
  if (i == follows.length) {
    return;
  }

  var remaining = ((follows.length - i) * delay / 1000).toFixed(2);

  console.log("Unfollowing", i + 1, "of", follows.length + ",", remaining + "s", "remaining…");

  follows[i].click();

  i = i + 1;

  setTimeout(unfollow, delay);
}

unfollow();

Thank you. Works perfect.

@Hs293Go

This comment has been minimized.

Copy link

@Hs293Go Hs293Go commented Oct 9, 2021

Here's a modified version of the script, working as of January 27th, 2021, that prints a message to the console and the time remaining after each unfollow:

Reddit brought me here. Casey's script works! On 10-9-2021.

I added a bunch of comments. I hope they help explain this script to regular, non-tech FB users who want to Unfollow Everything or newcomers to Javascript (like myself :) ) Let me know if I made any mistake.

// Get a list of elements that match selectors, i.e. "Toggle to follow" buttons. 
// Maintainers probably need to change the selector string for new FB versions
var follows = document.querySelectorAll('div[aria-label="Toggle to follow"]');
// If you want to make sure this script doesn't click on the wrong buttons, go
// to the Elements tab, press Ctrl-F, enter "Toggle to follow" in the search
// bar, then find the button that is highlighed

var delay = 1500;  // Delay between clicks to prevent being blocked by FB

var i = 0;  // Initialize a counter of unfollows

function unfollow() {
  // unfollow() calls itself recursively. If counter of unfollows reaches length
  // of friend list, return
  if (i == follows.length) {
    return;
  }

  // Calculate remaining time based on the num. of friends not yet unfollowed
  var remaining = ((follows.length - i) * delay / 1000).toFixed(2);

  console.log(
      'Unfollowing', i + 1, 'of', follows.length + ',', remaining + 's',
      'remaining…');

  follows[i].click();  // Click!

  i = i + 1;  // Increment the counter of unfollows

  // Recursively call itself with a 1500 s delay to keep on unfollowing
  setTimeout(unfollow, delay);
}

unfollow(); // IMPORTANT: the previous lines defined the unfollow() function. This line calls ("activates") it! 

EDIT: Thanks @aaronwe for pointing out my missing the last line. Added it back in with comment highlights.

@chesterbr

This comment has been minimized.

Copy link

@chesterbr chesterbr commented Oct 10, 2021

Thanks! (not that I'm using it 😉)

For those that are, I'd suggest replacing the setTimeout with, say:

  setTimeout(unfollow, Math.floor(Math.random() * delay * 2));

That way, instead of waiting exactly the delay time (e.g., 1.5s), it will wait a random value whose average will be (statistically) the delay time; just to make it look less like a script on FB's server logs.

EDIT: for added human simulation, insert a minimum, e.g., for a minimum time of 0.5s:

  setTimeout(unfollow, Math.floor(500 + Math.random() * delay * 2));

I didn't bother, but you may want to patch the remaining time calculation to take that in account,. e.g:

  var remaining = ((follows.length - i) * (delay+500) / 1000).toFixed(2);
@aaronwe

This comment has been minimized.

Copy link

@aaronwe aaronwe commented Oct 12, 2021

All of this works great!

@Hs293Go's commented version of @casey's masterful script from 2021-01-28 is missing the final unfollow();, and @chesterbr's randomization seems like a good idea, so here's an updated version integrating it all, with a few minor copy/readability edits. Please let me know if there are any typos.

To use this script:

  1. Navigate to facebook.com
  2. Down arrow > Settings and Privacy > News Feed Preferences > Unfollow
    (Use the drop-down filter to only select friends/pages/groups if you want)
  3. Scroll to the bottom of the list to load everything. If you have lots of friends, this will take a while.
  4. Open Developer Tools (Usually Cmd-Option-I or Ctrl-Option-I)
  5. Click Console
  6. Paste all of the following script into the Javascript console and press enter
    (The console might give you a warning and make you type something before letting you paste a script in. You should heed that warning and carefully read the following script to make sure it's safe. Never assume a random script you find on the internet is safe.)
  7. Watch as the script unfollows every person/page you've scrolled past!
// Get a list of elements that match selectors, i.e. "Toggle to follow" buttons. 
// Maintainers probably need to change the selector string for new FB versions

var follows = document.querySelectorAll('div[aria-label="Toggle to follow"]');

// If you want to make sure this script doesn't click on the wrong buttons, go
// to the Elements tab, press Ctrl-F, enter "Toggle to follow" in the search
// bar, then find the button that is highlighted

var delay = 1500;  // Delay between clicks to prevent being blocked by FB

var i = 0;  // Initialize a counter of unfollows

function unfollow() {
  // unfollow() calls itself recursively. If counter of unfollows reaches length
  // of friend list, stop
  if (i == follows.length) {
    return;
  }

  // Calculate remaining time based on the num. of friends not yet unfollowed
  var remaining = ((follows.length - i) * (delay+500) / 1000).toFixed(0);

  console.log(
      'Unfollowing', i + 1, 'of', follows.length + ', ~', remaining + 's',
      'remaining…');

  follows[i].click();  // Click!

  i = i + 1;  // Increment the counter of unfollows

  // Recursively call itself with a randomized delay of 500-2000ms to keep 
  // on unfollowing
  setTimeout(unfollow, Math.floor(500 + Math.random() * delay * 2));
}

// run the unfollow function
unfollow();
@casey

This comment has been minimized.

Copy link

@casey casey commented Oct 12, 2021

@casey's masterful script from 2021-01-28…

Awww, so nice to hear it's useful ^_^

@ChaosEmpire

This comment has been minimized.

Copy link

@ChaosEmpire ChaosEmpire commented Oct 13, 2021

grafik
thats the only thing happening for me in FF

@PabloLN

This comment has been minimized.

Copy link

@PabloLN PabloLN commented Oct 14, 2021

Thank you very much everyone, you saved my profile from when I was a kid😅 (I used the translator) 🇧🇷
image

@MSPTW

This comment has been minimized.

Copy link

@MSPTW MSPTW commented Oct 14, 2021

Worked great for me... with over 1600 entries. Well done :)

@Homwer

This comment has been minimized.

Copy link

@Homwer Homwer commented Oct 20, 2021

Works! Thanks a lot.
If you'r FB is in another language, remember to lookup [aria-label="Toggle to follow"] and replace Toggle to follow with whatever FB uses in your language.

This works for the german FB version:

var follows = document.querySelectorAll('div[aria-label="Einstellung für Abonnements"]');

@Emil23501

This comment has been minimized.

Copy link

@Emil23501 Emil23501 commented Oct 20, 2021

Works! Thanks a lot. If you'r FB is in another language, remember to lookup [aria-label="Toggle to follow"] and replace Toggle to follow with whatever FB uses in your language.

This works for the german FB version:

var follows = document.querySelectorAll('div[aria-label="Einstellung für Abonnements"]');

Hi Homwer, now it works, thanks a lot!!

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