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.
@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