Last active
May 3, 2025 05:36
-
-
Save alok-mishra/405963a24599b16280f9a535da89133b to your computer and use it in GitHub Desktop.
Remove all items from Trakt collection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) | |
}) |
@Clndl Your version works perfectly with the new rate limiting. You can decrease the interval to 1500ms without hitting the limit though.
I hit limits with 1500ms. Here's a version that works and integrates pagination again: gist link
const RATE_LIMIT_DELAY = 2000; // Delay between each item collection (2 seconds)
const PAGE_CHANGE_DELAY = 5000; // Delay before changing page (5 seconds)
async function clearTraktCollection() {
// Collect current page
const items = $(".grid-item");
console.log(`Processing ${items.length} items on current page`);
// Process items one by one with delay
for (let i = 0; i < items.length; i++) {
const item = $(items[i]);
actionWatch(item, "collect", true);
console.log(`Removed item ${i + 1}/${items.length}`);
await new Promise(resolve => setTimeout(resolve, RATE_LIMIT_DELAY));
}
// Check if there's a next page
const nextPageButton = $(".pagination-top .page.active").next().find('a');
if (nextPageButton.length) {
console.log("Moving to next page...");
await new Promise(resolve => setTimeout(resolve, PAGE_CHANGE_DELAY));
nextPageButton[0].click();
// Wait for page load and continue collection
setTimeout(clearTraktCollection, PAGE_CHANGE_DELAY);
} else {
console.log("Collection cleared - no more pages");
}
}
// Start the clearing process
clearTraktCollection();
I hit limits with 1500ms. Here's a version that works and integrates pagination again: gist link
const RATE_LIMIT_DELAY = 2000; // Delay between each item collection (2 seconds) const PAGE_CHANGE_DELAY = 5000; // Delay before changing page (5 seconds) async function clearTraktCollection() { // Collect current page const items = $(".grid-item"); console.log(`Processing ${items.length} items on current page`); // Process items one by one with delay for (let i = 0; i < items.length; i++) { const item = $(items[i]); actionWatch(item, "collect", true); console.log(`Removed item ${i + 1}/${items.length}`); await new Promise(resolve => setTimeout(resolve, RATE_LIMIT_DELAY)); } // Check if there's a next page const nextPageButton = $(".pagination-top .page.active").next().find('a'); if (nextPageButton.length) { console.log("Moving to next page..."); await new Promise(resolve => setTimeout(resolve, PAGE_CHANGE_DELAY)); nextPageButton[0].click(); // Wait for page load and continue collection setTimeout(clearTraktCollection, PAGE_CHANGE_DELAY); } else { console.log("Collection cleared - no more pages"); } } // Start the clearing process clearTraktCollection();
I get a Doh! error even with this for some reason, but the one from Clndl works
Anyways, thanks everyone for the help with this. No clue why this isn't easier
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.