21

This question is a little bit challenging to find an answer to in search engines...

My SO 'favourites' list has got so large over the years that I don't bother using it much anymore to find older posts I want to revisit (using web browser bookmarks instead).

Obviously one can unclick favourites manually ... but what if it's many pages++ long and clicking one by one feels like a mentally excruciating experience?

Does a quick and easy way to delete all my favourite marked posts exist, so I can start again from scratch and only selectively save questions of interest going forward?

5
  • 2
    Maybe it’s possible to crawl the fav list and call POST https://stackoverflow.com/posts/{id}/vote/5?undo=true on all of them. Mar 29, 2019 at 8:37
  • 2
    But... you're already using the far superior method of saving interesting questions - bookmarks. Just forget the favorites function exists.
    – Gimby
    Mar 29, 2019 at 9:13
  • 7
    Before you move forward on you quest to purge your favorites, did you know that you can limit a search to your favorites via infavorites:mine or infavorites:1717729? For example, to search within your favorites for questions tagged [r-faq]. I consider my numerous collection of favorites to be my own personal corner of SO and use this focused search capability frequently to limit my search results to Q&A I have previously found particularly helpful.
    – DavidRR
    Mar 29, 2019 at 11:49
  • 4
    @DavidRR ... the favorites just got a little bit more useful, thanks for sharing that.
    – Gimby
    Mar 29, 2019 at 11:56
  • 2
    @DavidRR +1 Thanks for the reminder. I have read about this option to search favourites before, but I guess 'my corner of SO' is so large with many favourites that are no longer relevant to me anymore (favourites are from years ago) ... but you make a good point Mar 29, 2019 at 11:57

1 Answer 1

8

For a client-side solution, here's a userscript which will remove all of your favorites - just install it with something like Tampermonkey, go to your profile's favorites tab, e.g.,

https://stackoverflow.com/users/9515207/certainperformance?tab=favorites

and it'll do the work from there, ending once all favorites and pages have been iterated through and removed:

// ==UserScript==
// @name             Stack Remove Favorites
// @author           CertainPerformance
// @include          /^https?://stackoverflow\.com/users/\d+/.+\?.*tab=(bookmarks|favorites).*$/
// @grant            none
// ==/UserScript==

const RATE_LIMIT = 1000;

const delay = ms => new Promise(res => setTimeout(res, ms));

const unfavorite = (questionId) => (
  fetch(
    `https://stackoverflow.com/posts/${questionId}/vote/5?undo=true`,
    {
      method: 'POST',
      credentials: 'same-origin',
      headers: {
        'content-type': 'application/x-www-form-urlencoded; charset=UTF-8'
      },
      body: `fkey=${StackExchange.options.user.fkey}`
    }
  )
  .then(res => res.json())
);

const getFavoriteQuestionIds = () => Array.from(document.querySelectorAll(
  '#user-tab-bookmarks .s-post-summary--content-title.s-link'
)).map(x => x.href.match(/\d+/)[0]);

const removeFavoritesAndRefreshPage = async () => {
  const favs = getFavoriteQuestionIds();

  if (favs.length === 0)
    return;

  for (let i = 0; i < favs.length; i++) {
    const questionId = favs[i];
    console.log(`Unfavoriting ${questionId}...`)
    await unfavorite(questionId);
    await delay(RATE_LIMIT);
  };

  // Refresh page.
  window.location.href = window.location.href;
};


setTimeout(removeFavoritesAndRefreshPage, RATE_LIMIT);

(Remember to disable or uninstall it afterwards if you want to be able to continue using favorites.)

4

You must log in to answer this question.

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