Skip to content

Instantly share code, notes, and snippets.

@hardiksondagar
Last active April 12, 2022 09:34
Show Gist options
  • Save hardiksondagar/65068f3b51258cd2d18d4869169cc5f4 to your computer and use it in GitHub Desktop.
Save hardiksondagar/65068f3b51258cd2d18d4869169cc5f4 to your computer and use it in GitHub Desktop.
Unlike or unfollow pages in Facebook
/**
* Unlike/unfollow pages in facebook.
* Open https://www.facebook.com/pages/?category=liked and scroll down till all liked/followed pages loads.
* Once all pages loads, copy paste this code in console and wait till all pages unliked/unfollowed (Use Google Chrome).
*/
var pages_followed = document.querySelectorAll('[aria-label="Following"]');
var pages_liked = document.querySelectorAll('[aria-label="Liked"]');
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function remove(pages) {
for (let i=0; i < pages.length; i++) {
try {
let page = pages[i];
page.click();
console.log(`Page ${i+1} removed`);
} catch {
console.error(`Page ${i+1} remove failed`);
} finally {
await sleep(1000);
}
}
}
await remove(pages_liked);
await remove(pages_followed);
Copy link

ghost commented Apr 12, 2022

very slow, and you can't get to the bottom of the list fast

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