DEV Community

Cover image for Detox LinkedIn Feed :)
Yury Troynov
Yury Troynov

Posted on

3 2

Detox LinkedIn Feed :)

Problem
wen you add new connection in LinkedIn you automatically start follow person (nobody asks if you want to). And then you have feed full of unwanted posts.

It's not comfortable to go and unfollow each time and there is no button unfollow all.

Solution

  1. open page where you have a list of contacts you follow (here)

  2. open browser developer tools console and paste below script there :)

(() => {
    const selectors = {
        followingButton: "button.is-following",
        followName: ".follows-recommendation-card__name",
    };

    const waitAround = (timeout = 100) =>
        new Promise((resolve) => {
            const randomTimeout =
                Math.random() * (timeout - timeout / 2) + timeout / 2;

            setTimeout(resolve, randomTimeout);
        });

    const getAllFollowingButtons = () =>
        Array.from(document.querySelectorAll(selectors.followingButton));

    const getPendingUnfollowAll = async () => {
        const buttons = getAllFollowingButtons();

        for (const button of buttons) {
            const name = button.parentElement.querySelector(
                selectors.followName
            ).innerText;

            console.log(`Unfollow ${name}`);

            window.scrollTo(0, button.offsetTop - 260);

            button.click();
            await waitAround(300);
        }
    };

    const start = async () => {
        await getPendingUnfollowAll();

        window.scrollTo(0, document.body.scrollHeight);

        await waitAround(500);

        const buttons = getAllFollowingButtons();

        if (buttons.length) {
            await start();
        }
    };

    start().then(() => {
        console.log("unfollow all done !");
    });
})();
Enter fullscreen mode Exit fullscreen mode

hit enter and enjoy clean feed line :)

Do your career a big favor. Join DEV. (The website you're on right now)

It takes one minute, it's free, and is worth it for your career.

Get started

Community matters

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

đź‘‹ Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay