Skip to content

Instantly share code, notes, and snippets.

@alok-mishra
Last active July 20, 2024 20:04
Show Gist options
  • Save alok-mishra/405963a24599b16280f9a535da89133b to your computer and use it in GitHub Desktop.
Save alok-mishra/405963a24599b16280f9a535da89133b to your computer and use it in GitHub Desktop.
Remove all items from Trakt collection
// Removes all items from a page of the Trakt collection
// Run script from console of user's collection page
// Must be run on each page
$(".posters .grid-item").each(function() {
actionWatch($(this).closest('.grid-item'), 'collect', true)
})
@joachimtingvold
Copy link

joachimtingvold commented Mar 2, 2022

@reconman, your solution seems to work, but I had two issues (none of which is caused by your solution);

  • Trakt seems to have some horrible caching in place, causing deleted items to show up randomly, and number of pages change between different cached versions (if you started off at 100 pages, after deleting some, you're down at 80, then back at 100, then down to 90, up to 95, back to 75, etc). This causes lot's of attempts to remove already removed stuff (and also lots of 400 response codes).
  • Trakt have their page behind Cloudflare, which seems to give 502 responses from the backend after a while. Most likely caused by some kind of rate limiting. Have to stop, wait, and then re-apply.

@EverAndy
Copy link

EverAndy commented Aug 6, 2023

Create a bookmark with the following saved as url. Makes it much easier to just select the bookmark once it switches pages. Following reconman suggestion:

javascript:function wipePage() {
    $(".grid-item").each(function(index) {
        actionWatch($(this), "collect", true);
    });

    if (localStorage.getItem('goForward') === "true") {
        $(".pagination-top .pagination .next a")[0].click();
        alert("Page cleared. Navigate to the next page and click the bookmarklet again.");
        localStorage.setItem('goForward', "false");
    } else {
        $(".pagination-top .pagination .prev a")[0].click();
        alert("Page cleared. Navigate to the previous page and click the bookmarklet again.");
        localStorage.setItem('goForward', "true");
    }
}

wipePage();

@znre
Copy link

znre commented Sep 10, 2023

@EverAndy, this works

Thank you!

@mikewesten
Copy link

The solutions worked fine until very recently. Trakt throwing up "Doh!" errors when trying to run this.

@Clndl
Copy link

Clndl commented Jun 24, 2024

The solutions worked fine until very recently. Trakt throwing up "Doh!" errors when trying to run this.

I confirm that the server responds with a Too many requests error. Due to this, I wrote the following script to clear my collection page by page. 32 pages in my case. Have fun.

function clearCollect(time = 2000) {
    var i = 0, items = $(".grid-item");
    console.log(`Start remove ${items.length} items`);
    var interval = setInterval(() => {
        if (i < items.length) {
            let item = $(items[i++]);
            actionWatch(item, "collect", true);
            console.log(`Remove item ${i - 1}`);
        } else clearInterval(interval);
    }, time);
}
clearCollect();

@uggedal
Copy link

uggedal commented Jul 20, 2024

@Clndl Your version works perfectly with the new rate limiting. You can decrease the interval to 1500ms without hitting the limit though.

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