12

I read How do I unfollow a post?, but that has no real answer to it yet.

When I visit the page with the list of questions that I follow (https://stackoverflow.com/users/724039/luuk?tab=following), I see 16+ pages of questions.

I can also see the posts that I had followed and were later deleted. For instance this question:

deleted question that I followed

I do not need to follow these deleted posts any longer.

Is there a way (like an API) that I can use to get those deleted questions from the list?

0

1 Answer 1

12

There doesn't appear to be anything that references followed posts in the SE API.

Luckily, this is pretty trivial to automate because navigating between pages of followed posts doesn't require a full page refresh. Open your browser's devtools (with Chrome on Windows, this can be done with control-shift-I) and open the Console tab. Open your last page of followed posts. Paste the following code into the console and press enter. It'll iterate backwards through the pages until it reaches the first.

const delay = ms => new Promise(res => setTimeout(res, ms));
const unfollowAllOnPage = async () => {
  const summaries = document.querySelectorAll('#user-tab-following .s-post-summary__deleted');
  for (const [i, summary] of summaries.entries()) {
    summary.querySelector('.js-unfollow-post').click();
    console.log(`Done with ${i + 1} of ${summaries.length}`);
    await delay(2000);
  }
  const prev = document.querySelector('#user-tab-following .js-pagination-item[rel="prev"]');
  if (prev) {
    prev.click();
    setTimeout(unfollowAllOnPage, 2000);
  }
};
unfollowAllOnPage();

That said, I notice that you're very close to 10k reputation - sometimes, you may have followed a post because you thought it was interesting. I don't know if those under 10k have the ability to view the entirety of posts they've followed that have been deleted. (You can see the summary - the title and a couple sentences - but what about the full post?) If not, you might want to wait a little bit before clearing your followed list so you can double check them individually - perhaps some that you found interesting were deleted, in case you might want to do further research on it or re-ask a similar question. (That's what I do, at least)

2
  • I added a screenshot to my question with a 'deleted' post, showing that I am able to see those. Thanks for the code, I will give it a try (tomorrow, not now... )
    – Luuk
    Commented Oct 9, 2022 at 18:53
  • It works (now I am going to (try to) change it to also delete questions older than 180 days ) The list was 16 pages long, now it's still 12 pages long.
    – Luuk
    Commented Oct 10, 2022 at 11:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .