Danbooru

Removing banned artists posts from Favorites

Posted under Bugs & Features

I have a problem with my Favorites page, in which there's two posts by banned artists, more concretely sakimichan and shikano_sumiaki and I can't take them out of my favorites. Even using the bookmarklet, these two posts are still there but I can't see them (that's obvious, though) nor do anything about them. They just add two non-existent posts to my favorite count.

Does anyone know if you can just delete all your favorites including banned posts, and how to do it?

Siwan said:

How to unfavorite in 2020? the link redirect me to somewhere.

This is no longer possible through the HTML interface. Instead, open your development console (F12) and paste the following Javascript code into the console:

(async function (user_id) {
    page = 0;
    iteration = 1;
    while (true) {
        favorites = await $.getJSON('/favorites.json',{search:{user_id:user_id},limit:200,page:'a'+page,only:'id,post_id,post[is_banned]'});
        banned_favs = favorites.filter((favorite)=>favorite.post.is_banned);
        console.log(`Batch #${iteration++}: Deleting ${banned_favs.length} favorites.`);
        for(i=0;i<banned_favs.length;i++) {
            try {
                await $.post(`/favorites/${banned_favs[i].post_id}.json`,{_method:'delete'});
            } catch(e) {
                console.warn('post #'+banned_favs[i].post_id,e?.status,e?.responseText);
            }
        }
        if (favorites.length<200) {
            break;
        }
        page=favorites[0].id;
    }
    Danbooru.Utility.notice('Done deleting banned favorites.');
})(Danbooru.CurrentUser.data('id'));

The above "should" work and I've tested out all of the components on both Chrome and Firefox, though I haven't tested deleting from either a banned artist or their paid work (double banned) as I would only get one shot.

BrokenEagle98 said:

This is no longer possible through the HTML interface. Instead, open your development console (F12) and paste the following Javascript code into the console:

(async function (user_id) {
    page = 0;
    iteration = 1;
    while (true) {
        favorites = await $.getJSON('/favorites.json',{search:{user_id:user_id},limit:200,page:'a'+page,only:'id,post_id,post[is_banned]'});
        banned_favs = favorites.filter((favorite)=>favorite.post.is_banned);
        console.log(`Batch #${iteration++}: Deleting ${banned_favs.length} favorites.`);
        for(i=0;i<banned_favs.length;i++) {
            try {
                await $.post(`/favorites/${banned_favs[i].post_id}.json`,{_method:'delete'});
            } catch(e) {
                console.warn('post #'+banned_favs[i].post_id,e?.status,e?.responseText);
            }
        }
        if (favorites.length<200) {
            break;
        }
        page=favorites[0].id;
    }
    Danbooru.Utility.notice('Done deleting banned favorites.');
})(Danbooru.CurrentUser.data('id'));

The above "should" work and I've tested out all of the components on both Chrome and Firefox, though I haven't tested deleting from either a banned artist or their paid work (double banned) as I would only get one shot.

I was wondering for the long time. Thank you very much!

1