Skip to content

Instantly share code, notes, and snippets.

@syareez
Created January 6, 2018 11:54
Show Gist options
  • Select an option

  • Save syareez/a3ccfd9ce25f60442c8814d6db4f1280 to your computer and use it in GitHub Desktop.

Select an option

Save syareez/a3ccfd9ce25f60442c8814d6db4f1280 to your computer and use it in GitHub Desktop.
Open up browser console, for Chrome, hit F12 and copy-paste and enter this
$("a").filter(function(index){return $(this).text()==="unsave"}).click();setTimeout(function(){location.reload();},500);
Repeat until all items are unsaved.
@LuisMcLovin

Copy link
Copy Markdown

Is there a way to automate the script without repeat copy/paste?

@Oikio

Oikio commented Apr 19, 2022

Copy link
Copy Markdown
Array.from(document.querySelectorAll("button")).forEach(
  (el) => {
    if (el.innerText === "unsave") el.click()
  })

Without jquery and reload, just to delete whatever you see on the "saved" page.

@dielfrag13

Copy link
Copy Markdown
Array.from(document.querySelectorAll("button")).forEach(
  (el) => {
    if (el.innerText === "unsave") el.click()
  })

Without jquery and reload, just to delete whatever you see on the "saved" page.

This still works as of 4/2023; only edit is the button text should be capitalized.

if (el.innerText === "Unsave") el.click()

I just had to refresh the page and rerun the function a couple times since Reddit does dynamic loading as you scroll

@alwei1

alwei1 commented Jun 17, 2023

Copy link
Copy Markdown

You should change that to "unsave", since that is the word it's used now for deleting saved posts. I pasted the command with the change: $("a").filter(function(index){return $(this).text()==="unsave"}).click();setTimeout(function(){location.reload();},500);

This still works as of 5/2023 on old reddit!

@gitatmax

Copy link
Copy Markdown

@alwei1 Indeed it doesβ€”thanks for confirming!

@brijazz

brijazz commented Jun 17, 2024

Copy link
Copy Markdown

Would there be any way to omit saves from a particular sub? I'd love to be able to clear out all of my saves except /r/dogpictures

@TasseDeCafe

Copy link
Copy Markdown

If you're using old reddit, you can paste this in your console once you're in the saved tab:

// Function to unsave Reddit items with randomized delays and batch pauses
function unsaveRedditItems() {
    // Find all unsave links
    const unsaveLinks = $("a").filter(function(index) {
        return $(this).text() === "unsave";
    });
    
    // Counter for current item
    let currentItem = 0;
    
    // Batch size configuration
    const BATCH_SIZE = 50;
    const BATCH_BREAK_TIME = 60000; // 60 second break between batches
    
    // Function to get random delay between 2-5 seconds (2000-5000ms)
    function getRandomDelay() {
        return Math.floor(Math.random() * (5000 - 2000 + 1)) + 2000;
    }
    
    // Function to process one item
    function processNextItem() {
        if (currentItem < unsaveLinks.length) {
            // Click the current unsave link
            $(unsaveLinks[currentItem]).click();
            
            // Get random delay for next action
            const nextDelay = getRandomDelay();
            
            // Check if we need a batch break
            const isEndOfBatch = (currentItem + 1) % BATCH_SIZE === 0;
            const actualDelay = isEndOfBatch ? BATCH_BREAK_TIME : nextDelay;
            
            // Log progress with appropriate message
            if (isEndOfBatch && currentItem + 1 < unsaveLinks.length) {
                console.log(
                    `Completed batch of ${BATCH_SIZE}. ` +
                    `Taking a ${BATCH_BREAK_TIME/1000} second break...`
                );
            } else {
                console.log(
                    `Unsaved item ${currentItem + 1} of ${unsaveLinks.length}. ` +
                    `Next action in ${(actualDelay/1000).toFixed(1)}s`
                );
            }
            
            // Move to next item after delay
            currentItem++;
            setTimeout(processNextItem, actualDelay);
        } else {
            // Reload page when done
            console.log("Finished unsaving items on this page");
            setTimeout(() => location.reload(), 3000);
        }
    }
    
    // Start processing if there are items to unsave
    if (unsaveLinks.length > 0) {
        console.log(`Found ${unsaveLinks.length} items to unsave`);
        // Add initial random delay before starting
        const initialDelay = getRandomDelay();
        console.log(`Starting in ${(initialDelay/1000).toFixed(1)}s...`);
        setTimeout(processNextItem, initialDelay);
    } else {
        console.log("No items found to unsave");
    }
}

// Run the function
unsaveRedditItems();

You might have to make the breaks between batches longer to avoid triggering the rate limiter. The random range between each action might also not be necessary. It did the job for me.

@rlewkowicz

Copy link
Copy Markdown

https://github.com/j0be/PowerDeleteSuite

So this still has lots of comments. This repo above is what you want. It's great. You'll see.

@iamxeeshankhan

iamxeeshankhan commented Dec 24, 2025

Copy link
Copy Markdown

I tested many existing methods. Most do not work, likely because they are outdated. Some rely on old.reddit.com, which is throttled and frequently returns 429 Too Many Requests errors. Because of this, I wrote my own script that is fast and reliable.

I tested it on over 900 posts and it performed very well. At the moment, it does not support comments or text-only posts and cannot unsave them.

(Not self-promotion. Just a community service.)

The code is available in this repository: https://github.com/iamxeeshankhan/reddit-posts-actions

@Zakaboy26

Zakaboy26 commented Feb 9, 2026

Copy link
Copy Markdown

Hey, everything here was outdated or required some manual stuff for me, so I made a quick userscript that works for old.reddit.com. Just copy-paste it into Tampermonkey/Greasemonkey and it handles unsaving posts automatically, it refreshes the page etc so you can just run it in the background.

Check it out here: https://github.com/Zakaboy26/auto-unsave-reddit

@Qwertin

Qwertin commented Mar 22, 2026

Copy link
Copy Markdown

this is working

(async () => {
    
    const sleep = (ms) => new Promise(r => setTimeout(r, ms));

    const querySelectorAllDeep = (selector, root = document) => {
        let nodes = Array.from(root.querySelectorAll(selector));
        for (const child of root.querySelectorAll('*')) {
            if (child.shadowRoot) {
                nodes = nodes.concat(querySelectorAllDeep(selector, child.shadowRoot));
            }
        }
        return nodes;
    };

    const doScrollBatch = async () => {
        console.log("⏬ Scrolling 5x to load more content...");
        for (let i = 0; i < 5; i++) {
            window.scrollBy(0, 2000);
            await sleep(2000);
        }
        console.log("βœ… Scrolling done, resuming deletions.");
    };

    let totalDeleted = parseInt(localStorage.getItem("unsave_total") || "0");
    let batchCount = 0;

    console.log(`πŸš€ Starting script. Total deleted so far: ${totalDeleted}`);

    await doScrollBatch();

    while (true) {
        const allSpans = querySelectorAllDeep('span');
        const unsaveBtn = allSpans.find(el => el.innerText?.trim() === 'Remove from saved');

        if (unsaveBtn) {
            unsaveBtn.click();
            totalDeleted++;
            batchCount++;
            localStorage.setItem("unsave_total", totalDeleted);
            console.log(`πŸ—‘οΈ Removed: ${totalDeleted} total (Batch: ${batchCount}/15)`);
            await sleep(2500 + Math.random() * 500);

            if (batchCount >= 15) {
                batchCount = 0;
                await doScrollBatch();
            }
            continue;
        }

        const menuTrackers = querySelectorAllDeep('faceplate-tracker[noun="overflow_menu"]');
        if (menuTrackers.length > 0) {
            menuTrackers[0].click();
            await sleep(1000);
            continue;
        }

        console.log("⬇️ Nothing found, scrolling...");
        window.scrollBy(0, 1500);
        await sleep(3000);
    }
})();

@Siddheshkr

Copy link
Copy Markdown

this is working

(async () => {
    
    const sleep = (ms) => new Promise(r => setTimeout(r, ms));

    const querySelectorAllDeep = (selector, root = document) => {
        let nodes = Array.from(root.querySelectorAll(selector));
        for (const child of root.querySelectorAll('*')) {
            if (child.shadowRoot) {
                nodes = nodes.concat(querySelectorAllDeep(selector, child.shadowRoot));
            }
        }
        return nodes;
    };

    const doScrollBatch = async () => {
        console.log("⏬ Scrolling 5x to load more content...");
        for (let i = 0; i < 5; i++) {
            window.scrollBy(0, 2000);
            await sleep(2000);
        }
        console.log("βœ… Scrolling done, resuming deletions.");
    };

    let totalDeleted = parseInt(localStorage.getItem("unsave_total") || "0");
    let batchCount = 0;

    console.log(`πŸš€ Starting script. Total deleted so far: ${totalDeleted}`);

    await doScrollBatch();

    while (true) {
        const allSpans = querySelectorAllDeep('span');
        const unsaveBtn = allSpans.find(el => el.innerText?.trim() === 'Remove from saved');

        if (unsaveBtn) {
            unsaveBtn.click();
            totalDeleted++;
            batchCount++;
            localStorage.setItem("unsave_total", totalDeleted);
            console.log(`πŸ—‘οΈ Removed: ${totalDeleted} total (Batch: ${batchCount}/15)`);
            await sleep(2500 + Math.random() * 500);

            if (batchCount >= 15) {
                batchCount = 0;
                await doScrollBatch();
            }
            continue;
        }

        const menuTrackers = querySelectorAllDeep('faceplate-tracker[noun="overflow_menu"]');
        if (menuTrackers.length > 0) {
            menuTrackers[0].click();
            await sleep(1000);
            continue;
        }

        console.log("⬇️ Nothing found, scrolling...");
        window.scrollBy(0, 1500);
        await sleep(3000);
    }
})();

thanks man πŸ‘πŸ»

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment