Deleting Trakt Shows, Movies, and Episodes

While trakt.tv makes it very easy start adding things to track, it’s a PITA to untrack things.

Here is some Javascript to delete whatever is on your screen when you are in the History pages:

Warning: This is majorly janky code. It doesn’t handle errors at all. Consider yourself warned.

function processItemsAndNavigate() {
  var items = $(".posters .grid-item");
 
  function processItem(index) {
    if (index >= items.length) {
      // All items on the current page have been processed
      alert('Deletion for this page is complete. Click OK to proceed to the next page.');
 
      // Check for the next page link
      var nextPageLink = $("a[rel='next']").attr("href");
      if (nextPageLink) {
        // Navigate to the next page
        window.location.href = nextPageLink;
      } else {
        // No more next page link, end the process
        alert('No more pages to process. Completed!');
      }
      return;
    }
 
    var $this = $(items[index]);
    historyRemove($this, $this.data("history-id"));
 
    // Log the iteration counter
    console.log(`\n--- Item ${index + 1} ---`);
 
    // Process the next item after a delay to avoid rate limits
    setTimeout(function() {
      processItem(index + 1);
    }, 3000); // Adjust the delay as needed
  }
 
  // Start processing from the first item
  processItem(0);
}
 
// Start the process
processItemsAndNavigate();

Once you run it, you’ll see items disappearing from your screen. When it’s done, a popup will alert you that it’s done and click ok to go to the next page.

After you go to the next page, you’ll have to run the code again in the console.

If you want to use it as a bookmarklet, here is the minified code:

javascript:(function(){function formatTime(timestamp){var date=new Date(timestamp);var hours=String(date.getHours()).padStart(2,'0');var minutes=String(date.getMinutes()).padStart(2,'0');var seconds=String(date.getSeconds()).padStart(2,'0');return `${hours}:${minutes}:${seconds}`;}function processItemsAndNavigate(){var items=$(".posters .grid-item");function processItem(index){if(index>=items.length){alert('Deletion for this page is complete. Click OK to proceed to the next page.');var nextPageLink=$("a[rel='next']").attr("href");if(nextPageLink){window.location.href=nextPageLink;}else{alert('No more pages to process. Completed!');}return;}var $this=$(items[index]);historyRemove($this,$this.data("history-id"));console.log(`\n--- Item ${index+1} ---`);setTimeout(function(){processItem(index+1);},3000);}processItem(0);}processItemsAndNavigate();})();