DEV Community

Hardik Sondagar
Hardik Sondagar

Posted on

Sanitize Facebook Feed - OnlyFriends

This small script will unfollow and unlike all pages from your facebook account. It'll bring sanity to your endless feed by including more posts from your real friends.

/**
* 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);
Enter fullscreen mode Exit fullscreen mode

Top comments (0)